Fix error categorization for empty DWRF files
@@ -20,6 +20,7 @@ import com.facebook.presto.hive.HiveColumnHandle;
import com.facebook.presto.hive.HivePageSourceFactory;
import com.facebook.presto.spi.ConnectorPageSource;
import com.facebook.presto.spi.ConnectorSession;
+import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.predicate.TupleDomain;
import com.facebook.presto.spi.type.TypeManager;
import org.apache.hadoop.conf.Configuration;
@@ -32,6 +33,7 @@ import java.util.List;
import java.util.Optional;
import java.util.Properties;
+import static com.facebook.presto.hive.HiveErrorCode.HIVE_BAD_DATA;
import static com.facebook.presto.hive.HiveSessionProperties.getOrcLazyReadSmallRanges;
import static com.facebook.presto.hive.HiveSessionProperties.getOrcMaxBufferSize;
import static com.facebook.presto.hive.HiveSessionProperties.getOrcMaxMergeDistance;
@@ -73,6 +75,10 @@ public class DwrfPageSourceFactory
return Optional.empty();
}
+ if (fileSize == 0) {
+ throw new PrestoException(HIVE_BAD_DATA, "ORC file is empty: " + path);
+ }
+
return Optional.of(createOrcPageSource(
DWRF,
hdfsEnvironment,
