This is an automated email from the ASF dual-hosted git repository. jcamacho pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new 505fd69 HIVE-23130: User friendly error message when MV rewriting fails (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez) 505fd69 is described below commit 505fd6935540e234fb28bcc7e42991f81b1951ac Author: Krisztian Kasa <kk...@cloudera.com> AuthorDate: Fri Apr 3 16:27:57 2020 -0700 HIVE-23130: User friendly error message when MV rewriting fails (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez) --- .../calcite/HiveRelOptMaterializationValidator.java | 15 ++++++++++++++- .../clientnegative/materialized_view_no_cbo_rewrite.q.out | 2 +- .../materialized_view_no_cbo_rewrite_2.q.out | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptMaterializationValidator.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptMaterializationValidator.java index 110136d..1aa1731 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptMaterializationValidator.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptMaterializationValidator.java @@ -46,6 +46,7 @@ import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveIntersect; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveProject; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSemiJoin; +import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortExchange; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveSortLimit; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan; import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveUnion; @@ -123,7 +124,6 @@ public class HiveRelOptMaterializationValidator extends HiveRelShuttleImpl { @Override public RelNode visit(RelNode node) { - setAutomaticRewritingInvalidReason(node); // There are several Hive RelNode types which do not have their own visit() method // defined in the HiveRelShuttle interface, which need to be handled appropriately here. // Per jcamachorodriguez we should not encounter HiveMultiJoin/HiveSortExchange @@ -132,6 +132,8 @@ public class HiveRelOptMaterializationValidator extends HiveRelShuttleImpl { return visit((HiveUnion) node); } else if (node instanceof HiveSortLimit) { return visit((HiveSortLimit) node); + } else if (node instanceof HiveSortExchange) { + return visit((HiveSortExchange) node); } else if (node instanceof HiveSemiJoin) { return visit((HiveSemiJoin) node); } else if (node instanceof HiveExcept) { @@ -225,18 +227,27 @@ public class HiveRelOptMaterializationValidator extends HiveRelShuttleImpl { // Note: Not currently part of the HiveRelNode interface private RelNode visit(HiveUnion union) { + setAutomaticRewritingInvalidReason("Statement has unsupported operator: union."); return visitChildren(union); } // Note: Not currently part of the HiveRelNode interface private RelNode visit(HiveSortLimit sort) { + setAutomaticRewritingInvalidReason("Statement has unsupported clause: order by."); checkExpr(sort.getFetchExpr()); checkExpr(sort.getOffsetExpr()); return visitChildren(sort); } // Note: Not currently part of the HiveRelNode interface + private RelNode visit(HiveSortExchange sort) { + setAutomaticRewritingInvalidReason("Statement has unsupported clause: sort by."); + return visitChildren(sort); + } + + // Note: Not currently part of the HiveRelNode interface private RelNode visit(HiveSemiJoin semiJoin) { + setAutomaticRewritingInvalidReason("Statement has unsupported join type: semi join."); checkExpr(semiJoin.getCondition()); checkExpr(semiJoin.getJoinFilter()); return visitChildren(semiJoin); @@ -244,11 +255,13 @@ public class HiveRelOptMaterializationValidator extends HiveRelShuttleImpl { // Note: Not currently part of the HiveRelNode interface private RelNode visit(HiveExcept except) { + setAutomaticRewritingInvalidReason("Statement has unsupported operator: except."); return visitChildren(except); } // Note: Not currently part of the HiveRelNode interface private RelNode visit(HiveIntersect intersect) { + setAutomaticRewritingInvalidReason("Statement has unsupported operator: intersect."); return visitChildren(intersect); } diff --git a/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite.q.out b/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite.q.out index 8e55c2c..159e2dc 100644 --- a/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite.q.out +++ b/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite.q.out @@ -19,4 +19,4 @@ POSTHOOK: Output: default@cmv_basetable POSTHOOK: Lineage: cmv_basetable.a SCRIPT [] POSTHOOK: Lineage: cmv_basetable.b SCRIPT [] POSTHOOK: Lineage: cmv_basetable.c SCRIPT [] -FAILED: SemanticException Cannot enable automatic rewriting for materialized view. Unsupported RelNode type HiveSortExchange encountered in the query plan +FAILED: SemanticException Cannot enable automatic rewriting for materialized view. Statement has unsupported clause: sort by. diff --git a/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite_2.q.out b/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite_2.q.out index b9de681..7e22225 100644 --- a/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite_2.q.out +++ b/ql/src/test/results/clientnegative/materialized_view_no_cbo_rewrite_2.q.out @@ -33,4 +33,4 @@ PREHOOK: query: alter materialized view cmv_mat_view enable rewrite PREHOOK: type: ALTER_MATERIALIZED_VIEW_REWRITE PREHOOK: Input: default@cmv_mat_view PREHOOK: Output: default@cmv_mat_view -FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.ddl.DDLTask. org.apache.hadoop.hive.ql.metadata.HiveException: Cannot enable rewriting for materialized view. Unsupported RelNode type HiveSortExchange encountered in the query plan +FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.ddl.DDLTask. org.apache.hadoop.hive.ql.metadata.HiveException: Cannot enable rewriting for materialized view. Statement has unsupported clause: sort by.