Search in sources :

Example 31 with Expression

use of org.apache.iceberg.expressions.Expression in project drill by apache.

the class TestFilterTransformer method testToFilterLessThanOrEqual.

@Test
public void testToFilterLessThanOrEqual() {
    Expression expected = Expressions.lessThanOrEqual(MetastoreColumn.ROW_GROUP_INDEX.columnName(), 1);
    Expression actual = transformer.transform(FilterExpression.lessThanOrEqual(MetastoreColumn.ROW_GROUP_INDEX, 1));
    assertEquals(expected.toString(), actual.toString());
}
Also used : FilterExpression(org.apache.drill.metastore.expressions.FilterExpression) Expression(org.apache.iceberg.expressions.Expression) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Example 32 with Expression

use of org.apache.iceberg.expressions.Expression 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)

Example 33 with Expression

use of org.apache.iceberg.expressions.Expression in project drill by apache.

the class TestTablesOperationTransformer method testToDeleteOperation.

@Test
public void testToDeleteOperation() {
    Expression expected = Expressions.equal(MetastoreColumn.STORAGE_PLUGIN.columnName(), "dfs");
    org.apache.drill.metastore.operate.Delete delete = org.apache.drill.metastore.operate.Delete.builder().metadataType(MetadataType.ALL).filter(FilterExpression.equal(MetastoreColumn.STORAGE_PLUGIN, "dfs")).build();
    Delete operation = transformer.toDelete(delete);
    assertEquals(expected.toString(), operation.filter().toString());
}
Also used : Delete(org.apache.drill.metastore.iceberg.operate.Delete) FilterExpression(org.apache.drill.metastore.expressions.FilterExpression) Expression(org.apache.iceberg.expressions.Expression) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Example 34 with Expression

use of org.apache.iceberg.expressions.Expression in project drill by apache.

the class TestTablesOperationTransformer method testToDeleteOperationByFilter.

@Test
public void testToDeleteOperationByFilter() {
    FilterExpression filter = FilterExpression.and(FilterExpression.equal(MetastoreColumn.STORAGE_PLUGIN, "dfs"), FilterExpression.equal(MetastoreColumn.WORKSPACE, "tmp"));
    Expression expected = Expressions.and(Expressions.equal(MetastoreColumn.STORAGE_PLUGIN.columnName(), "dfs"), Expressions.equal(MetastoreColumn.WORKSPACE.columnName(), "tmp"));
    Delete operation = transformer.toDelete(filter);
    assertEquals(expected.toString(), operation.filter().toString());
}
Also used : Delete(org.apache.drill.metastore.iceberg.operate.Delete) FilterExpression(org.apache.drill.metastore.expressions.FilterExpression) Expression(org.apache.iceberg.expressions.Expression) FilterExpression(org.apache.drill.metastore.expressions.FilterExpression) Test(org.junit.Test) IcebergBaseTest(org.apache.drill.metastore.iceberg.IcebergBaseTest)

Example 35 with Expression

use of org.apache.iceberg.expressions.Expression in project drill by apache.

the class FilterExpressionVisitor method visit.

@Override
public Expression visit(DoubleExpressionPredicate.Or expression) {
    Expression right = expression.right().accept(this);
    Expression left = expression.left().accept(this);
    return Expressions.or(right, left);
}
Also used : Expression(org.apache.iceberg.expressions.Expression) FilterExpression(org.apache.drill.metastore.expressions.FilterExpression)

Aggregations

Expression (org.apache.iceberg.expressions.Expression)40 FilterExpression (org.apache.drill.metastore.expressions.FilterExpression)28 IcebergBaseTest (org.apache.drill.metastore.iceberg.IcebergBaseTest)26 Test (org.junit.Test)26 MetastoreColumn (org.apache.drill.metastore.MetastoreColumn)5 Map (java.util.Map)4 Path (org.apache.hadoop.fs.Path)3 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)2 HashMap (java.util.HashMap)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 TableMetadataUnit (org.apache.drill.metastore.components.tables.TableMetadataUnit)2 Delete (org.apache.drill.metastore.iceberg.operate.Delete)2 MapWork (org.apache.hadoop.hive.ql.plan.MapWork)2 TableScan (org.apache.iceberg.TableScan)2 Domain (com.facebook.presto.common.predicate.Domain)1 Marker (com.facebook.presto.common.predicate.Marker)1 Range (com.facebook.presto.common.predicate.Range)1 SortedRangeSet (com.facebook.presto.common.predicate.SortedRangeSet)1 ValueSet (com.facebook.presto.common.predicate.ValueSet)1 ArrayType (com.facebook.presto.common.type.ArrayType)1