Search in sources :

Example 6 with TableScan

use of org.apache.iceberg.TableScan in project presto by prestodb.

the class IcebergSplitManager method getSplits.

@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingContext splitSchedulingContext) {
    IcebergTableLayoutHandle layoutHandle = (IcebergTableLayoutHandle) layout;
    IcebergTableHandle table = layoutHandle.getTable();
    if (!table.getSnapshotId().isPresent()) {
        return new FixedSplitSource(ImmutableList.of());
    }
    Table icebergTable;
    if (catalogType == HADOOP) {
        icebergTable = getHadoopIcebergTable(resourceFactory, session, table.getSchemaTableName());
    } else {
        ExtendedHiveMetastore metastore = ((IcebergHiveMetadata) transactionManager.get(transaction)).getMetastore();
        icebergTable = getHiveIcebergTable(metastore, hdfsEnvironment, session, table.getSchemaTableName());
    }
    TableScan tableScan = icebergTable.newScan().filter(toIcebergExpression(table.getPredicate())).useSnapshot(table.getSnapshotId().get());
    // TODO Use residual. Right now there is no way to propagate residual to presto but at least we can
    // propagate it at split level so the parquet pushdown can leverage it.
    IcebergSplitSource splitSource = new IcebergSplitSource(session, tableScan.planTasks());
    return splitSource;
}
Also used : TableScan(org.apache.iceberg.TableScan) Table(org.apache.iceberg.Table) IcebergUtil.getHiveIcebergTable(com.facebook.presto.iceberg.IcebergUtil.getHiveIcebergTable) IcebergUtil.getHadoopIcebergTable(com.facebook.presto.iceberg.IcebergUtil.getHadoopIcebergTable) FixedSplitSource(com.facebook.presto.spi.FixedSplitSource) ExtendedHiveMetastore(com.facebook.presto.hive.metastore.ExtendedHiveMetastore)

Example 7 with TableScan

use of org.apache.iceberg.TableScan in project drill by apache.

the class IcebergGroupScan method initTableScan.

public static TableScan initTableScan(IcebergFormatPlugin formatPlugin, String path, LogicalExpression condition) {
    TableScan tableScan = new HadoopTables(formatPlugin.getFsConf()).load(path).newScan();
    Map<String, String> properties = formatPlugin.getConfig().getProperties();
    if (properties != null) {
        for (Map.Entry<String, String> entry : properties.entrySet()) {
            tableScan = tableScan.option(entry.getKey(), entry.getValue());
        }
    }
    if (condition != null) {
        Expression expression = condition.accept(DrillExprToIcebergTranslator.INSTANCE, null);
        tableScan = tableScan.filter(expression);
    }
    Snapshot snapshot = formatPlugin.getConfig().getSnapshot();
    if (snapshot != null) {
        tableScan = snapshot.apply(tableScan);
    }
    Boolean caseSensitive = formatPlugin.getConfig().getCaseSensitive();
    if (caseSensitive != null) {
        tableScan = tableScan.caseSensitive(caseSensitive);
    }
    Boolean includeColumnStats = formatPlugin.getConfig().getIncludeColumnStats();
    if (includeColumnStats != null && includeColumnStats) {
        tableScan = tableScan.includeColumnStats();
    }
    Boolean ignoreResiduals = formatPlugin.getConfig().getIgnoreResiduals();
    if (ignoreResiduals != null && ignoreResiduals) {
        tableScan = tableScan.ignoreResiduals();
    }
    return tableScan;
}
Also used : TableScan(org.apache.iceberg.TableScan) Snapshot(org.apache.drill.exec.store.iceberg.snapshot.Snapshot) Expression(org.apache.iceberg.expressions.Expression) LogicalExpression(org.apache.drill.common.expression.LogicalExpression) HadoopTables(org.apache.iceberg.hadoop.HadoopTables) Map(java.util.Map)

Aggregations

TableScan (org.apache.iceberg.TableScan)7 Table (org.apache.iceberg.Table)4 Map (java.util.Map)3 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)2 TypeManager (com.facebook.presto.common.type.TypeManager)2 ExtendedHiveMetastore (com.facebook.presto.hive.metastore.ExtendedHiveMetastore)2 TypeConverter.toPrestoType (com.facebook.presto.iceberg.TypeConverter.toPrestoType)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 List (java.util.List)2 Optional (java.util.Optional)2 DataFile (org.apache.iceberg.DataFile)2 Expression (org.apache.iceberg.expressions.Expression)2 NullableValue (com.facebook.presto.common.predicate.NullableValue)1 ArrayType (com.facebook.presto.common.type.ArrayType)1 HdfsContext (com.facebook.presto.hive.HdfsContext)1 HdfsEnvironment (com.facebook.presto.hive.HdfsEnvironment)1 HiveColumnConverterProvider (com.facebook.presto.hive.HiveColumnConverterProvider)1