kasakrisz commented on code in PR #4869:
URL: https://github.com/apache/hive/pull/4869#discussion_r1407856582


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveAugmentSnapshotMaterializationRule.java:
##########
@@ -125,11 +129,20 @@ public void onMatch(RelOptRuleCall call) {
     Table table = hiveTable.getHiveTableMD();
 
     SnapshotContext mvMetaTableSnapshot = 
mvMetaStoredSnapshot.get(table.getFullyQualifiedName());
-    if 
(mvMetaTableSnapshot.equals(table.getStorageHandler().getCurrentSnapshotContext(table)))
 {
+    if (table.getStorageHandler() == null) {
+      throw new UnsupportedOperationException(String.format("Table %s does not 
have Storage handler defined. " +
+          "Mixing native and non-native tables in a materialized view 
definition is currently not supported!",
+          table.getFullyQualifiedName()));
+    }
+    if (Objects.equals(mvMetaTableSnapshot, 
table.getStorageHandler().getCurrentSnapshotContext(table))) {
       return;
     }
 
-    
table.setVersionIntervalFrom(Long.toString(mvMetaTableSnapshot.getSnapshotId()));
+    Long snapshotId = null;
+    if (mvMetaTableSnapshot != null) {

Review Comment:
   refactored



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HivePushdownSnapshotFilterRule.java:
##########
@@ -116,15 +116,16 @@ private boolean setSnapShotId(RexNode op1, RexNode op2) {
         return false;
       }
 
-      long snapshotId = literal.getValueAs(Long.class);
+      Long snapshotId = literal.getValueAs(Long.class);
 
       RelOptTable relOptTable = getRelOptTableOf(op2);
       if (relOptTable == null) {
         return false;
       }
 
       RelOptHiveTable hiveTable = (RelOptHiveTable) relOptTable;
-      
hiveTable.getHiveTableMD().setVersionIntervalFrom(Long.toString(snapshotId));
+      String snapshotIdText = snapshotId != null ? Long.toString(snapshotId) : 
null;

Review Comment:
   refactored



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveAugmentSnapshotMaterializationRule.java:
##########
@@ -141,11 +154,8 @@ public void onMatch(RelOptRuleCall call) {
     relBuilder.push(tableScan);
     List<RexNode> conds = new ArrayList<>();
     final RexNode literalHighWatermark = rexBuilder.makeLiteral(
-        mvMetaTableSnapshot.getSnapshotId(), snapshotIdType(relBuilder), 
false);
-    conds.add(
-        rexBuilder.makeCall(
-            SqlStdOperatorTable.LESS_THAN_OR_EQUAL,
-            ImmutableList.of(snapshotIdInputRef, literalHighWatermark)));
+        snapshotId, snapshotIdType(relBuilder.getTypeFactory()), false);
+    conds.add(rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN_OR_EQUAL, 
snapshotIdInputRef, literalHighWatermark));

Review Comment:
   refactored



-- 
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