Search in sources :

Example 6 with MetastoreColumn

use of org.apache.drill.metastore.MetastoreColumn in project drill by apache.

the class TestFilterTransformer method testToFilterConditionsFour.

@Test
public void testToFilterConditionsFour() {
    Map<MetastoreColumn, Object> conditions = new LinkedHashMap<>();
    conditions.put(MetastoreColumn.STORAGE_PLUGIN, "dfs");
    conditions.put(MetastoreColumn.WORKSPACE, "tmp");
    conditions.put(MetastoreColumn.TABLE_NAME, "nation");
    conditions.put(MetastoreColumn.ROW_GROUP_INDEX, 4);
    Expression expected = Expressions.and(Expressions.equal(MetastoreColumn.STORAGE_PLUGIN.columnName(), "dfs"), Expressions.equal(MetastoreColumn.WORKSPACE.columnName(), "tmp"), Expressions.equal(MetastoreColumn.TABLE_NAME.columnName(), "nation"), Expressions.equal(MetastoreColumn.ROW_GROUP_INDEX.columnName(), 4));
    assertEquals(expected.toString(), transformer.transform(conditions).toString());
}
Also used : FilterExpression(org.apache.drill.metastore.expressions.FilterExpression) Expression(org.apache.iceberg.expressions.Expression) MetastoreColumn(org.apache.drill.metastore.MetastoreColumn) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Example 7 with MetastoreColumn

use of org.apache.drill.metastore.MetastoreColumn in project drill by apache.

the class IcebergRead method internalExecute.

@Override
protected List<T> internalExecute() {
    String[] selectedColumns = columns.isEmpty() ? defaultColumns : columns.stream().map(MetastoreColumn::columnName).toArray(String[]::new);
    FilterTransformer filterTransformer = context.transformer().filter();
    Expression rowFilter = filterTransformer.combine(filterTransformer.transform(metadataTypes), filterTransformer.transform(filter));
    Iterable<Record> records = IcebergGenerics.read(context.table()).select(selectedColumns).where(rowFilter).build();
    return context.transformer().outputData().columns(selectedColumns).records(Lists.newArrayList(records)).execute();
}
Also used : Expression(org.apache.iceberg.expressions.Expression) Record(org.apache.iceberg.data.Record) MetastoreColumn(org.apache.drill.metastore.MetastoreColumn) FilterTransformer(org.apache.drill.metastore.iceberg.transform.FilterTransformer)

Aggregations

MetastoreColumn (org.apache.drill.metastore.MetastoreColumn)7 Expression (org.apache.iceberg.expressions.Expression)5 FilterExpression (org.apache.drill.metastore.expressions.FilterExpression)3 IcebergBaseTest (org.apache.drill.metastore.iceberg.IcebergBaseTest)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 TableMetadataUnit (org.apache.drill.metastore.components.tables.TableMetadataUnit)2 FilterTransformer (org.apache.drill.metastore.iceberg.transform.FilterTransformer)2 File (java.io.File)1 Field (java.lang.reflect.Field)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Objects (java.util.Objects)1 MetastoreFieldDefinition (org.apache.drill.metastore.MetastoreFieldDefinition)1 IcebergMetastoreException (org.apache.drill.metastore.iceberg.exceptions.IcebergMetastoreException)1 Overwrite (org.apache.drill.metastore.iceberg.operate.Overwrite)1 FilterTransformer (org.apache.drill.metastore.mongo.transform.FilterTransformer)1