[ 
https://issues.apache.org/jira/browse/HIVE-26924?focusedWorklogId=839767&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-839767
 ]

ASF GitHub Bot logged work on HIVE-26924:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Jan/23 21:39
            Start Date: 17/Jan/23 21:39
    Worklog Time Spent: 10m 
      Work Description: scarlin-cloudera commented on code in PR #3936:
URL: https://github.com/apache/hive/pull/3936#discussion_r1072857383


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/alter/rewrite/AlterMaterializedViewRewriteAnalyzer.java:
##########
@@ -68,10 +68,12 @@ public void analyzeInternal(ASTNode root) throws 
SemanticException {
     Table materializedViewTable = getTable(tableName, true);
 
     // One last test: if we are enabling the rewrite, we need to check that 
query
-    // only uses transactional (MM and ACID) tables
+    // only uses transactional (MM and ACID and Iceberg) tables
     if (rewriteEnable) {
       for (SourceTable sourceTable : 
materializedViewTable.getMVMetadata().getSourceTables()) {
-        if (!AcidUtils.isTransactionalTable(sourceTable.getTable())) {
+        Table table = new Table(sourceTable.getTable());
+        if (!AcidUtils.isTransactionalTable(sourceTable.getTable()) &&
+                !(table.isNonNative() && 
table.getStorageHandler().areSnapshotsSupported())) {

Review Comment:
   Out of curiosity (and I don't know this code at all), what is the reason for 
the "isNonNative()" check?  I guess there's a native table where 
"areSnapshotsSupported()" returns true?  From the name, it sounds like this 
alone should have been enough.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 839767)
    Time Spent: 40m  (was: 0.5h)

> Alter materialized view enable rewrite throws SemanticException for source 
> iceberg table
> ----------------------------------------------------------------------------------------
>
>                 Key: HIVE-26924
>                 URL: https://issues.apache.org/jira/browse/HIVE-26924
>             Project: Hive
>          Issue Type: Bug
>          Components: Iceberg integration
>            Reporter: Dharmik Thakkar
>            Assignee: Krisztian Kasa
>            Priority: Critical
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> alter materialized view enable rewrite throws SemanticException for source 
> iceberg table
> SQL test
> {code:java}
> >>> create materialized view mv_rewrite as select t, si from all100k where 
> >>> t>115;
> >>> analyze table mv_rewrite compute statistics for columns;
> >>> set hive.explain.user=false;
> >>> explain select si,t from all100k where t>116 and t<120;
> !!! match row_contains
>           alias: iceberg_test_db_hive.mv_rewrite
> >>> alter materialized view mv_rewrite disable rewrite;
> >>> explain select si,t from all100k where t>116 and t<120;
> !!! match row_contains
>           alias: all100k
> >>> alter materialized view mv_rewrite enable rewrite;
> >>> explain select si,t from all100k where t>116 and t<120;
> !!! match row_contains
>           alias: iceberg_test_db_hive.mv_rewrite
> >>> drop materialized view mv_rewrite; {code}
>  
> Error
> {code:java}
> 2023-01-10T18:40:34,303 INFO  [pool-3-thread-1] jdbc.TestDriver: Query: alter 
> materialized view mv_rewrite enable rewrite
> 2023-01-10T18:40:34,365 INFO  [Thread-10] jdbc.TestDriver: INFO  : Compiling 
> command(queryId=hive_20230110184034_f557b4a6-40a0-42ba-8e67-2f273f50af36): 
> alter materialized view mv_rewrite enable rewrite
> 2023-01-10T18:40:34,426 INFO  [Thread-10] jdbc.TestDriver: ERROR : FAILED: 
> SemanticException Automatic rewriting for materialized view cannot be enabled 
> if the materialized view uses non-transactional tables
> 2023-01-10T18:40:34,426 INFO  [Thread-10] jdbc.TestDriver: 
> org.apache.hadoop.hive.ql.parse.SemanticException: Automatic rewriting for 
> materialized view cannot be enabled if the materialized view uses 
> non-transactional tables
> 2023-01-10T18:40:34,426 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.ddl.view.materialized.alter.rewrite.AlterMaterializedViewRewriteAnalyzer.analyzeInternal(AlterMaterializedViewRewriteAnalyzer.java:75)
> 2023-01-10T18:40:34,426 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:313)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:222)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:105)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.Driver.compile(Driver.java:201)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:657)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:603)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:597)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:127)
> 2023-01-10T18:40:34,427 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:206)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:336)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.security.AccessController.doPrivileged(Native Method)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/javax.security.auth.Subject.doAs(Subject.java:423)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:358)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> 2023-01-10T18:40:34,428 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> 2023-01-10T18:40:34,429 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> 2023-01-10T18:40:34,429 INFO  [Thread-10] jdbc.TestDriver:      at 
> java.base/java.lang.Thread.run(Thread.java:829)
> 2023-01-10T18:40:34,429 INFO  [Thread-10] jdbc.TestDriver:
> 2023-01-10T18:40:34,429 INFO  [Thread-10] jdbc.TestDriver: INFO  : Completed 
> compiling 
> command(queryId=hive_20230110184034_f557b4a6-40a0-42ba-8e67-2f273f50af36); 
> Time taken: 0.03 seconds
> 2023-01-10T18:40:34,520 ERROR [pool-3-thread-1] jdbc.TestDriver: Error while 
> compiling statement: FAILED: SemanticException Automatic rewriting for 
> materialized view cannot be enabled if the materialized view uses 
> non-transactional tables {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to