This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit b58966b98391209a073cda61f538d84056343b75
Author: LPL <[email protected]>
AuthorDate: Sat May 14 18:18:30 2022 +0800

    IMPALA-11289: Push-down compound predicates to iceberg
    
    This patch implements pushing compound predicates down to Iceberg. The
    compound predicates include NOT, AND, and OR.
    
    Testing:
     - Added end-to-end test
    
    Change-Id: I27bc67b71033900c466183da5b1907ac90844177
    Reviewed-on: http://gerrit.cloudera.org:8080/18535
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 .../org/apache/impala/planner/IcebergScanNode.java | 131 ++++--
 .../java/org/apache/impala/util/IcebergUtil.java   |  50 ++-
 .../iceberg-compound-predicate-push-down.test      | 461 +++++++++++++++++++++
 tests/query_test/test_iceberg.py                   |   6 +-
 4 files changed, 593 insertions(+), 55 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/planner/IcebergScanNode.java 
b/fe/src/main/java/org/apache/impala/planner/IcebergScanNode.java
index f3d521d13..547b02e0d 100644
--- a/fe/src/main/java/org/apache/impala/planner/IcebergScanNode.java
+++ b/fe/src/main/java/org/apache/impala/planner/IcebergScanNode.java
@@ -26,6 +26,7 @@ import java.util.List;
 import org.apache.hadoop.fs.Path;
 import org.apache.iceberg.DataFile;
 import org.apache.iceberg.Schema;
+import org.apache.iceberg.expressions.Expression;
 import org.apache.iceberg.expressions.Expressions;
 import org.apache.iceberg.expressions.Expression.Operation;
 import org.apache.iceberg.expressions.UnboundPredicate;
@@ -33,6 +34,7 @@ import org.apache.iceberg.types.Types;
 import org.apache.impala.analysis.Analyzer;
 import org.apache.impala.analysis.BinaryPredicate;
 import org.apache.impala.analysis.BoolLiteral;
+import org.apache.impala.analysis.CompoundPredicate;
 import org.apache.impala.analysis.DateLiteral;
 import org.apache.impala.analysis.Expr;
 import org.apache.impala.analysis.InPredicate;
@@ -76,8 +78,8 @@ public class IcebergScanNode extends HdfsScanNode {
 
   private final FeIcebergTable icebergTable_;
 
-  // Exprs in icebergConjuncts_ converted to UnboundPredicate.
-  private final List<UnboundPredicate> icebergPredicates_ = new ArrayList<>();
+  // Exprs in icebergConjuncts_ converted to Expression.
+  private final List<Expression> icebergPredicates_ = new ArrayList<>();
 
   private TimeTravelSpec timeTravelSpec_;
 
@@ -208,87 +210,162 @@ public class IcebergScanNode extends HdfsScanNode {
     }
   }
 
+  /**
+   * Returns Iceberg operator by CompoundPredicate operator, or null if the 
operation
+   * is not supported by Iceberg.
+   */
+  private Operation getIcebergOperator(CompoundPredicate.Operator op) {
+    switch (op) {
+      case AND: return Operation.AND;
+      case OR: return Operation.OR;
+      case NOT: return Operation.NOT;
+      default: return null;
+    }
+  }
+
   /**
    * Transform impala predicate to iceberg predicate
    */
   private void tryConvertIcebergPredicate(Analyzer analyzer, Expr expr)
       throws ImpalaException {
+    Expression predicate = convertIcebergPredicate(analyzer, expr);
+    if (predicate != null) {
+      icebergPredicates_.add(predicate);
+      LOG.debug("Push down the predicate: " + predicate + " to iceberg");
+    }
+  }
+
+  private Expression convertIcebergPredicate(Analyzer analyzer, Expr expr)
+      throws ImpalaException {
     if (expr instanceof BinaryPredicate) {
-      convertIcebergPredicate(analyzer, (BinaryPredicate) expr);
+      return convertIcebergPredicate(analyzer, (BinaryPredicate) expr);
     } else if (expr instanceof InPredicate) {
-      convertIcebergPredicate(analyzer, (InPredicate) expr);
+      return convertIcebergPredicate(analyzer, (InPredicate) expr);
     } else if (expr instanceof IsNullPredicate) {
-      convertIcebergPredicate((IsNullPredicate) expr);
+      return convertIcebergPredicate((IsNullPredicate) expr);
+    } else if (expr instanceof CompoundPredicate) {
+      return convertIcebergPredicate(analyzer, (CompoundPredicate) expr);
+    } else {
+      return null;
     }
   }
 
-  private void convertIcebergPredicate(Analyzer analyzer, BinaryPredicate 
predicate)
-      throws ImpalaException {
+  private UnboundPredicate<Object> convertIcebergPredicate(Analyzer analyzer,
+      BinaryPredicate predicate) throws ImpalaException {
     Operation op = getIcebergOperator(predicate.getOp());
-    if (op == null) return;
+    if (op == null) {
+      return null;
+    }
 
     // Do not convert if there is an implicit cast
-    if (!(predicate.getChild(0) instanceof SlotRef)) return;
+    if (!(predicate.getChild(0) instanceof SlotRef)) {
+      return null;
+    }
     SlotRef ref = (SlotRef) predicate.getChild(0);
 
-    if (!(predicate.getChild(1) instanceof LiteralExpr)) return;
+    if (!(predicate.getChild(1) instanceof LiteralExpr)) {
+      return null;
+    }
     LiteralExpr literal = (LiteralExpr) predicate.getChild(1);
 
     // If predicate contains map/struct, this column would be null
     Column col = ref.getDesc().getColumn();
-    if (col == null) return;
+    if (col == null) {
+      return null;
+    }
 
     Object value = getIcebergValue(analyzer, ref, literal);
-    if (value == null) return;
+    if (value == null) {
+      return null;
+    }
 
-    icebergPredicates_.add(Expressions.predicate(op, col.getName(), value));
+    return Expressions.predicate(op, col.getName(), value);
   }
 
-  private void convertIcebergPredicate(Analyzer analyzer, InPredicate 
predicate)
-      throws ImpalaException {
+  private UnboundPredicate<Object> convertIcebergPredicate(Analyzer analyzer,
+      InPredicate predicate) throws ImpalaException {
     // TODO: convert NOT_IN predicate
-    if (predicate.isNotIn()) return;
+    if (predicate.isNotIn()) {
+      return null;
+    }
 
     // Do not convert if there is an implicit cast
-    if (!(predicate.getChild(0) instanceof SlotRef)) return;
+    if (!(predicate.getChild(0) instanceof SlotRef)) {
+      return null;
+    }
     SlotRef ref = (SlotRef) predicate.getChild(0);
 
     // If predicate contains map/struct, this column would be null
     Column col = ref.getDesc().getColumn();
-    if (col == null) return;
+    if (col == null) {
+      return null;
+    }
 
     // Expressions takes a list of values as Objects
     List<Object> values = new ArrayList<>();
     for (int i = 1; i < predicate.getChildren().size(); ++i) {
-      if (!Expr.IS_LITERAL.apply(predicate.getChild(i))) return;
+      if (!Expr.IS_LITERAL.apply(predicate.getChild(i))) {
+        return null;
+      }
       LiteralExpr literal = (LiteralExpr) predicate.getChild(i);
 
       // Cannot push IN or NOT_IN predicate with null literal values
-      if (Expr.IS_NULL_LITERAL.apply(literal)) return;
+      if (Expr.IS_NULL_LITERAL.apply(literal)) {
+        return null;
+      }
 
       Object value = getIcebergValue(analyzer, ref, literal);
-      if (value == null) return;
+      if (value == null) {
+        return null;
+      }
 
       values.add(value);
     }
 
-    icebergPredicates_.add(Expressions.in(col.getName(), values));
+    return Expressions.in(col.getName(), values);
   }
 
-  private void convertIcebergPredicate(IsNullPredicate predicate) {
+  private UnboundPredicate<Object> convertIcebergPredicate(IsNullPredicate 
predicate) {
     // Do not convert if there is an implicit cast
-    if (!(predicate.getChild(0) instanceof SlotRef)) return;
+    if (!(predicate.getChild(0) instanceof SlotRef)) {
+      return null;
+    }
     SlotRef ref = (SlotRef) predicate.getChild(0);
 
     // If predicate contains map/struct, this column would be null
     Column col = ref.getDesc().getColumn();
-    if (col == null) return;
+    if (col == null) {
+      return null;
+    }
 
     if (predicate.isNotNull()) {
-      icebergPredicates_.add(Expressions.notNull(col.getName()));
+      return Expressions.notNull(col.getName());
     } else{
-      icebergPredicates_.add(Expressions.isNull(col.getName()));
+      return Expressions.isNull(col.getName());
+    }
+  }
+
+  private Expression convertIcebergPredicate(Analyzer analyzer,
+      CompoundPredicate predicate) throws ImpalaException {
+    Operation op = getIcebergOperator(predicate.getOp());
+    if (op == null) {
+      return null;
+    }
+
+    Expression left = convertIcebergPredicate(analyzer, predicate.getChild(0));
+    if (left == null) {
+      return null;
+    }
+    if (op.equals(Operation.NOT)) {
+      return Expressions.not(left);
+    }
+
+    Expression right = convertIcebergPredicate(analyzer, 
predicate.getChild(1));
+    if (right == null) {
+      return null;
     }
+    return op.equals(Operation.AND) ? Expressions.and(left, right)
+        : Expressions.or(left, right);
   }
 
   private Object getIcebergValue(Analyzer analyzer, SlotRef ref, LiteralExpr 
literal)
diff --git a/fe/src/main/java/org/apache/impala/util/IcebergUtil.java 
b/fe/src/main/java/org/apache/impala/util/IcebergUtil.java
index 8f4fca0df..5c70bfa85 100644
--- a/fe/src/main/java/org/apache/impala/util/IcebergUtil.java
+++ b/fe/src/main/java/org/apache/impala/util/IcebergUtil.java
@@ -17,6 +17,14 @@
 
 package org.apache.impala.util;
 
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
+import com.google.common.primitives.Ints;
+import com.google.common.primitives.Longs;
+import com.google.flatbuffers.FlatBufferBuilder;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.time.Instant;
@@ -32,36 +40,20 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
-import com.google.common.primitives.Ints;
-import com.google.common.primitives.Longs;
-import com.google.flatbuffers.FlatBufferBuilder;
-
-import org.apache.impala.common.Pair;
-import org.apache.impala.fb.FbFileMetadata;
-import org.apache.impala.fb.FbIcebergDataFileFormat;
-import org.apache.impala.fb.FbIcebergMetadata;
-import org.apache.impala.fb.FbIcebergPartitionTransformValue;
-import org.apache.impala.fb.FbIcebergTransformType;
-import org.apache.iceberg.Transaction;
-import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.DataFile;
 import org.apache.iceberg.FileFormat;
 import org.apache.iceberg.FileScanTask;
-import org.apache.iceberg.TableScan;
-import org.apache.iceberg.expressions.UnboundPredicate;
-import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.PartitionField;
 import org.apache.iceberg.PartitionSpec;
 import org.apache.iceberg.Schema;
 import org.apache.iceberg.Snapshot;
 import org.apache.iceberg.StructLike;
 import org.apache.iceberg.Table;
+import org.apache.iceberg.TableScan;
+import org.apache.iceberg.Transaction;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.expressions.Expression;
+import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.mr.Catalogs;
 import org.apache.iceberg.transforms.PartitionSpecVisitor;
 import org.apache.iceberg.types.Conversions;
@@ -77,12 +69,18 @@ import org.apache.impala.catalog.FeIcebergTable;
 import org.apache.impala.catalog.HdfsFileFormat;
 import org.apache.impala.catalog.IcebergTable;
 import org.apache.impala.catalog.TableLoadingException;
+import org.apache.impala.catalog.iceberg.IcebergCatalog;
+import org.apache.impala.catalog.iceberg.IcebergCatalogs;
 import org.apache.impala.catalog.iceberg.IcebergHadoopCatalog;
 import org.apache.impala.catalog.iceberg.IcebergHadoopTables;
 import org.apache.impala.catalog.iceberg.IcebergHiveCatalog;
-import org.apache.impala.catalog.iceberg.IcebergCatalog;
-import org.apache.impala.catalog.iceberg.IcebergCatalogs;
 import org.apache.impala.common.ImpalaRuntimeException;
+import org.apache.impala.common.Pair;
+import org.apache.impala.fb.FbFileMetadata;
+import org.apache.impala.fb.FbIcebergDataFileFormat;
+import org.apache.impala.fb.FbIcebergMetadata;
+import org.apache.impala.fb.FbIcebergPartitionTransformValue;
+import org.apache.impala.fb.FbIcebergTransformType;
 import org.apache.impala.thrift.TCompressionCodec;
 import org.apache.impala.thrift.THdfsCompression;
 import org.apache.impala.thrift.THdfsFileFormat;
@@ -523,17 +521,17 @@ public class IcebergUtil {
    * DataFiles in the first element.
    */
   public static Pair<List<DataFile>, Boolean> 
getIcebergDataFiles(FeIcebergTable table,
-      List<UnboundPredicate> predicates, TimeTravelSpec timeTravelSpec)
+      List<Expression> predicates, TimeTravelSpec timeTravelSpec)
         throws TableLoadingException {
     if (table.snapshotId() == -1) return new Pair<>(Collections.emptyList(), 
false);
 
     TableScan scan = createScanAsOf(table, timeTravelSpec);
-    for (UnboundPredicate predicate : predicates) {
+    for (Expression predicate : predicates) {
       scan = scan.filter(predicate);
     }
 
     List<DataFile> dataFileList = new ArrayList<>();
-    Boolean hasDeleteFile = false;
+    boolean hasDeleteFile = false;
     try (CloseableIterable<FileScanTask> fileScanTasks = scan.planFiles()) {
       for (FileScanTask task : fileScanTasks) {
         if (!task.deletes().isEmpty()) {
diff --git 
a/testdata/workloads/functional-query/queries/QueryTest/iceberg-compound-predicate-push-down.test
 
b/testdata/workloads/functional-query/queries/QueryTest/iceberg-compound-predicate-push-down.test
new file mode 100644
index 000000000..8e7afedb2
--- /dev/null
+++ 
b/testdata/workloads/functional-query/queries/QueryTest/iceberg-compound-predicate-push-down.test
@@ -0,0 +1,461 @@
+====
+---- QUERY
+create table ice_compound_pred_pd (
+  col_i INT,
+  col_bi BIGINT,
+  col_db DOUBLE,
+  col_str STRING,
+  col_ts TIMESTAMP
+) partitioned by spec (col_i) stored as iceberg tblproperties 
('write.format.default' = 'parquet');
+---- RESULTS
+'Table has been created.'
+====
+---- QUERY
+insert into
+  ice_compound_pred_pd
+values
+  (0, NULL, 2.71820, '_1700-01-01 00:00:00', '1400-01-01 00:00:00'),
+  (1, 12345678901, NULL, 'A1700-01-01 00:00:00', '1400-01-01 01:01:01'),
+  (2, 12345678902, 2.71822, NULL, '1400-01-01 02:02:02'),
+  (3, 12345678903, 2.71823, '1700-01-01 00:00:00', '1500-01-01 00:00:00'),
+  (4, 12345678904, 2.71824, '1700-01-01 00:00:00', NULL),
+  (5, 12345678908, 2.71828, '1700-01-01 00:00:00', '1600-01-01 02:02:02'),
+  (0, NULL, 2.71820, '_1700-01-01 00:00:00', '1400-01-01 00:00:00'),
+  (1, 12345678901, NULL, 'A1700-01-01 00:00:00', '1400-01-01 01:01:01'),
+  (2, 12345678902, 2.71822, NULL, '1400-01-01 02:02:02'),
+  (3, 12345678903, 2.71823, '1700-01-01 00:00:00', '1500-01-01 00:00:00'),
+  (4, 12345678904, 2.71824, '1700-01-01 00:00:00', NULL),
+  (5, 12345678908, 2.71828, '1700-01-01 00:00:00', '1600-01-01 02:02:02'),
+  (6, NULL, 2.71820, '_1700-01-01 00:00:00', '1400-01-01 00:00:00'),
+  (7, 12345678901, NULL, 'A1700-01-01 00:00:00', '1400-01-01 01:01:01'),
+  (8, 12345678902, 2.71822, NULL, '1400-01-01 02:02:02'),
+  (9, 12345678903, 2.71823, '1700-01-01 00:00:00', '1500-01-01 00:00:00'),
+  (10, 12345678904, 2.71824, '1700-01-01 00:00:00', NULL),
+  (11, 12345678908, 2.71828, '1700-01-01 00:00:00', '1600-01-01 02:02:02');
+select count(1) from ice_compound_pred_pd;
+---- RESULTS
+18
+---- TYPES
+BIGINT
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 0
+aggregation(SUM, NumFileMetadataRead): 12
+====
+---- QUERY
+show files in ice_compound_pred_pd;
+---- RESULTS
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=0/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=1/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=10/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=11/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=2/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=3/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=4/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=5/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=6/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=7/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=8/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd/data/col_i=9/.*.0.parq','.*',''
+---- TYPES
+STRING, STRING, STRING
+====
+---- QUERY
+# icebergPredicates_:
+# 0: in_list
+# 1: in_list or eq
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  col_str in ('1700-01-01 00:00:00')
+  and (
+    col_ts in ('1500-01-01 00:00:00')
+    or col_db = 2.71823
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+# 0: eq or in_list
+# 1: in_list
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_db = 2.71823
+    or col_ts in ('1500-01-01 00:00:00')
+  )
+  and col_str in ('1700-01-01 00:00:00');
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+# 0: eq or is_null
+# 1: not_null or eq
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_bi = 12345678902
+    or col_str is null
+  )
+  and (
+    col_ts is not null
+    or col_db = 2.71823
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+# 0: eq or in_list
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_bi != -1
+    or cast(col_str as timestamp) in ('1700-01-01 00:00:00')
+  )
+  and (
+    col_db = 2.71823
+    or col_ts in ('1500-01-01 00:00:00')
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+# 0: in_list or eq
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  cast(col_str as timestamp) in ('1700-01-01 00:00:00')
+  and (
+    col_ts in ('1500-01-01 00:00:00')
+    or cast(col_db as double) = 2.71823
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  cast(col_str as timestamp) in ('1700-01-01 00:00:00')
+  and (
+    cast(col_db as bigint) = 2.71823
+    or col_ts in ('1500-01-01 00:00:00')
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 12
+====
+---- QUERY
+# icebergPredicates_:
+# 0: eq or in_list
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  col_bi = 12345678902
+  or col_db in (2.71823);
+---- RESULTS
+6
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 4
+====
+---- QUERY
+# icebergPredicates_:
+# 0: in_list or (in_list and eq)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  col_bi in (12345678902)
+  or (
+    col_ts in ('1500-01-01 00:00:00')
+    and col_db = 2.71823
+  );
+---- RESULTS
+6
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 4
+====
+---- QUERY
+# icebergPredicates_:
+# 0: (eq and in_list) or in_list
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_db = 2.71823
+    and col_ts in ('1500-01-01 00:00:00')
+  )
+  or col_bi in (12345678902);
+---- RESULTS
+6
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 4
+====
+---- QUERY
+# icebergPredicates_:
+# 0: (eq and in_list) or (in_list and not_null)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_db = 1.71823 + 1
+    and col_ts in ('1500-01-01 00:00:00')
+  )
+  or (
+    col_bi in (12345678902)
+    and col_str is not null
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_db = 2.71823
+    and cast(col_ts as string) in ('1500-01-01 00:00:00')
+  )
+  or (
+    col_bi in (12345678902)
+    and col_str is not null
+  );
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 12
+====
+---- QUERY
+# icebergPredicates_:
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  (
+    col_db = 1.71823 + col_db
+    and col_ts in ('1500-01-01 00:00:00')
+  )
+  or (
+    col_bi in (12345678902)
+    and col_str is not null
+  );
+---- RESULTS
+0
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 12
+====
+---- QUERY
+# icebergPredicates_:
+# 0: not(not_null)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  not col_bi is not null;
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+# 0: (not(not_null)) or (eq)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  not col_bi is not null
+  or col_bi = 12345678908;
+---- RESULTS
+6
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 4
+====
+---- QUERY
+# icebergPredicates_:
+# 0: not(not_eq)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  not (col_bi != 12345678901);
+---- RESULTS
+3
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 2
+====
+---- QUERY
+# icebergPredicates_:
+# 0: not(not_eq or eq)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  not (
+    col_bi != 123
+    or col_db = 2.71822
+  );
+---- RESULTS
+0
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 0
+====
+---- QUERY
+# icebergPredicates_:
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  not (
+    col_bi + 1 != 123
+    or col_db = 2.71822
+  );
+---- RESULTS
+0
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 12
+====
+---- QUERY
+# icebergPredicates_:
+# 0: is_null or (gt_eq and lt_eq)
+select
+  count(1)
+from
+  ice_compound_pred_pd
+where
+  col_bi is null
+  or col_bi between 12345678901
+  and 12345678902;
+---- RESULTS
+9
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 6
+====
+---- QUERY
+create table ice_compound_pred_pd1 (
+  col_i INT,
+  col_bi_0 BIGINT,
+  col_bi_1 BIGINT,
+  col_bi_2 BIGINT,
+  col_bi_3 BIGINT,
+  col_bi_4 BIGINT,
+  col_bi_5 BIGINT,
+  col_bi_6 BIGINT,
+  col_bi_7 BIGINT,
+  col_bi_8 BIGINT,
+  col_bi_9 BIGINT
+) partitioned by spec (col_i) stored as iceberg tblproperties 
('write.format.default' = 'parquet');
+---- RESULTS
+'Table has been created.'
+====
+---- QUERY
+insert into
+  ice_compound_pred_pd1
+values
+  (0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9),
+  (1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19),
+  (2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29),
+  (3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39),
+  (4, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49),
+  (5, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59),
+  (6, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69),
+  (7, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79),
+  (8, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89),
+  (9, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99);
+select count(1) from ice_compound_pred_pd1;
+---- RESULTS
+10
+---- TYPES
+BIGINT
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 0
+aggregation(SUM, NumFileMetadataRead): 10
+====
+---- QUERY
+show files in ice_compound_pred_pd1;
+---- RESULTS
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=0/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=1/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=2/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=3/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=4/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=5/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=6/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=7/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=8/.*.0.parq','.*',''
+row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/ice_compound_pred_pd1/data/col_i=9/.*.0.parq','.*',''
+---- TYPES
+STRING, STRING, STRING
+====
+---- QUERY
+select
+  count(1)
+from
+  ice_compound_pred_pd1
+where
+  col_bi_0 = 0
+  or col_bi_1 is null
+  or not(
+    col_bi_2 < 22
+    or col_bi_2 > 22
+  )
+  or col_bi_3 is null
+  or col_bi_4 = 44
+  or col_bi_5 is null
+  or col_bi_6 = 66
+  or col_bi_7 is null
+  or col_bi_8 = 88
+  or col_bi_9 is null;
+---- RESULTS
+5
+---- RUNTIME_PROFILE
+aggregation(SUM, NumRowGroups): 5
+====
diff --git a/tests/query_test/test_iceberg.py b/tests/query_test/test_iceberg.py
index 727540449..c5ff5a539 100644
--- a/tests/query_test/test_iceberg.py
+++ b/tests/query_test/test_iceberg.py
@@ -613,12 +613,14 @@ class TestIcebergTable(ImpalaTestSuite):
         split_stats = collect_split_stats(profile)
         assert ref_split_stats == split_stats
 
-  @pytest.mark.execute_serially
   def test_in_predicate_push_down(self, vector, unique_database):
     self.run_test_case('QueryTest/iceberg-in-predicate-push-down', vector,
                        use_db=unique_database)
 
-  @pytest.mark.execute_serially
   def test_is_null_predicate_push_down(self, vector, unique_database):
     self.run_test_case('QueryTest/iceberg-is-null-predicate-push-down', vector,
                        use_db=unique_database)
+
+  def test_compound_predicate_push_down(self, vector, unique_database):
+      self.run_test_case('QueryTest/iceberg-compound-predicate-push-down', 
vector,
+                         use_db=unique_database)

Reply via email to