zhangbutao commented on code in PR #6380:
URL: https://github.com/apache/hive/pull/6380#discussion_r3292987154


##########
iceberg/iceberg-handler/src/test/queries/positive/iceberg_partition_pruner_cache_key.q:
##########
@@ -0,0 +1,49 @@
+set hive.fetch.task.conversion=none;
+set hive.explain.user=false;
+
+create external table tbl_ice_pp_key(a int, b string) stored by iceberg;
+
+insert into tbl_ice_pp_key values (1, 'one'), (2, 'two');
+alter table tbl_ice_pp_key create tag s1;
+
+insert into tbl_ice_pp_key values
+  (3, 'three'), (4, 'four'), (5, 'five'),
+  (6, 'six'), (7, 'seven'),(8, 'eight'),
+  (9, 'nine'),  (10, 'ten');
+
+explain select count(*) from tbl_ice_pp_key;
+select count(*) from tbl_ice_pp_key;
+
+explain select count(*) from tbl_ice_pp_key for system_version as of 's1';
+select count(*) from tbl_ice_pp_key for system_version as of 's1';
+
+explain
+select cur.cnt as cur_cnt, snap.cnt as snap_cnt
+from (
+  select count(*) as cnt from tbl_ice_pp_key
+) cur
+cross join (
+  select count(*) as cnt from tbl_ice_pp_key for system_version as of 's1'
+) snap;
+
+select cur.cnt as cur_cnt, snap.cnt as snap_cnt
+from (
+  select count(*) as cnt from tbl_ice_pp_key
+) cur
+cross join (
+  select count(*) as cnt from tbl_ice_pp_key for system_version as of 's1'
+) snap;
+
+-- with a partition predicate

Review Comment:
   The table `tbl_ice_pp_key` is not a partitioned table, so why is the` 
partition predicate` being tested here?



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionPruner.java:
##########
@@ -184,8 +184,11 @@ public static PrunedPartitionList prune(Table tab, 
ExprNodeDesc prunerExpr,
     String key = tab.getFullyQualifiedName() + ";";
     if (tab.getMetaTable() != null) {
       key = tab.getFullyQualifiedName() + "." + tab.getMetaTable() + ";";
-    } else if (tab.getSnapshotRef() != null) {
-      key = tab.getFullyQualifiedName() + "." + tab.getSnapshotRef() + ";";
+    } else if (tab.isNonNative()) {
+      long snapshotId = tab.getStorageHandler().getSnapshotId(tab);
+      if (snapshotId > 0) {
+        key = tab.getFullyQualifiedName() + "." + snapshotId + ";";

Review Comment:
   Sure, that's fine.



##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/Table.java:
##########
@@ -1355,6 +1356,12 @@ public void setSnapshotRef(String snapshotRef) {
     this.snapshotRef = snapshotRef;
   }
 
+  public String getQualifier() {
+    return Stream.of(metaTable, snapshotRef, asOfVersion, asOfTimestamp)
+        .filter(Objects::nonNull).findFirst()
+        .orElse("");

Review Comment:
   The `metaTable, snapshotRef, asOfVersion, and asOfTimestamp` can only have 
at most one non-null value at a time, or they can all be null. 
   So this comment shouldn't be an issue. Right? @deniskuzZ 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to