[ https://issues.apache.org/jira/browse/HIVE-27187?focusedWorklogId=854218&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-854218 ]
ASF GitHub Bot logged work on HIVE-27187: ----------------------------------------- Author: ASF GitHub Bot Created on: 31/Mar/23 15:49 Start Date: 31/Mar/23 15:49 Worklog Time Spent: 10m Work Description: deniskuzZ commented on code in PR #4166: URL: https://github.com/apache/hive/pull/4166#discussion_r1154638925 ########## ql/src/java/org/apache/hadoop/hive/ql/ddl/view/materialized/alter/rebuild/AlterMaterializedViewRebuildAnalyzer.java: ########## @@ -564,30 +582,38 @@ private void fixUpASTAggregateIncrementalRebuild( HiveParser.TOK_INSERT, HiveParser.TOK_SELECT); ASTNode selectExprNodeInputROJ = (ASTNode) ParseDriver.adaptor.create( HiveParser.TOK_SELEXPR, "TOK_SELEXPR"); - ASTNode tableName = createRowIdNode(TableName.getDbTable( + astBuilder.createAcidSortNodes(TableName.getDbTable( materializationNode.getChild(0).getText(), - materializationNode.getChild(1).getText())); - ParseDriver.adaptor.addChild(selectExprNodeInputROJ, tableName); - ParseDriver.adaptor.addChild(selectNodeInputROJ, selectExprNodeInputROJ); + materializationNode.getChild(1).getText())) + .forEach(astNode -> ParseDriver.adaptor.addChild(selectNodeInputROJ, astNode)); // 4) Transform first INSERT branch into an UPDATE - // 4.1) Adding ROW__ID field - ASTNode selectNodeInUpdate = (ASTNode) updateNode.getChild(1); - if (selectNodeInUpdate.getType() != HiveParser.TOK_SELECT) { - throw new SemanticException("TOK_SELECT expected in incremental rewriting"); - } - ASTNode selectExprNodeInUpdate = (ASTNode) ParseDriver.adaptor.dupNode(selectExprNodeInputROJ); - ParseDriver.adaptor.addChild(selectExprNodeInUpdate, createRowIdNode((ASTNode) subqueryNodeInputROJ.getChild(1))); - selectNodeInUpdate.insertChild(0, selectExprNodeInUpdate); - // 4.2) Modifying filter condition. + // 4.1) Modifying filter condition. ASTNode whereClauseInUpdate = findWhereClause(updateNode); if (whereClauseInUpdate.getChild(0).getType() != HiveParser.KW_OR) { throw new SemanticException("OR clause expected below TOK_WHERE in incremental rewriting"); } // We bypass the OR clause and select the first disjunct for the Update branch ParseDriver.adaptor.setChild(whereClauseInUpdate, 0, disjuncts.get(Context.DestClausePrefix.UPDATE)); + ASTNode updateDeleteNode = (ASTNode) ParseDriver.adaptor.dupTree(updateNode); + // 4.2) Adding ROW__ID field + ASTNode selectNodeInUpdateDelete = (ASTNode) updateDeleteNode.getChild(1); + if (selectNodeInUpdateDelete.getType() != HiveParser.TOK_SELECT) { + throw new SemanticException("TOK_SELECT expected in incremental rewriting"); Review Comment: should we print the actual type? Issue Time Tracking ------------------- Worklog Id: (was: 854218) Time Spent: 1h 20m (was: 1h 10m) > Incremental rebuild of materialized view having aggregate and stored by > iceberg > ------------------------------------------------------------------------------- > > Key: HIVE-27187 > URL: https://issues.apache.org/jira/browse/HIVE-27187 > Project: Hive > Issue Type: Improvement > Components: Iceberg integration, Materialized views > Reporter: Krisztian Kasa > Assignee: Krisztian Kasa > Priority: Major > Labels: pull-request-available > Time Spent: 1h 20m > Remaining Estimate: 0h > > Currently incremental rebuild of materialized view stored by iceberg which > definition query contains aggregate operator is transformed to an insert > overwrite statement which contains a union operator if the source tables > contains insert operations only. One branch of the union scans the view the > other produces the delta. > This can be improved further: transform the statement to a multi insert > statement representing a merge statement to insert new aggregations and > update existing. -- This message was sent by Atlassian Jira (v8.20.10#820010)