Eric Wohlstadter created HIVE-21163:
---------------------------------------

             Summary: ParseUtils.parseQueryAndGetSchema fails on views with 
global limit
                 Key: HIVE-21163
                 URL: https://issues.apache.org/jira/browse/HIVE-21163
             Project: Hive
          Issue Type: Bug
            Reporter: Eric Wohlstadter


{code:java}
hive> USE tpcds_bin_partitioned_orc_1000;
hive> CREATE VIEW profit_view AS SELECT ss_net_profit, d_date FROM store_sales, 
date_dim WHERE d_date = ss_sold_date LIMIT 100;
hive> SELECT get_splits("SELECT * from profit_view", 0);

Error: java.io.IOException: org.apache.hadoop.hive.ql.parse.SemanticException: 
View profit_view is corresponding to HiveSortLimit#3447, rather than a 
HiveProject. (state=,code=0)
{code}

This works fine if the view doesn't have a global limit. 
It also works fine if you define a view without a global limit, and then apply 
a limit on top of the view. 

{{Calcite.genLogicalPlan}} is expecting a {{HiveProject}} root but when going 
through {{ParseUtils.parseQueryAndGetSchema}} the {{HiveSortLimit}} appears at 
the root. Perhaps it is simply missing a step to wrap the limit with a 
projection?

{code}
Caused by: org.apache.hadoop.hive.ql.parse.SemanticException: View profit_view 
is corresponding to HiveSortLimit#2275, rather than a HiveProject.
  at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.genLogicalPlan(CalcitePlanner.java:4931)
  at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:1741)
  at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:1689)
  at org.apache.calcite.tools.Frameworks$1.apply(Frameworks.java:118)
  at 
org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:1043)
  at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:154)
  at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:111)
  at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner.logicalPlan(CalcitePlanner.java:1448)
  at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner.genLogicalPlan(CalcitePlanner.java:395)
  at 
org.apache.hadoop.hive.ql.parse.ParseUtils.parseQueryAndGetSchema(ParseUtils.java:561)
  at 
org.apache.hadoop.hive.ql.udf.generic.GenericUDTFGetSplits.createPlanFragment(GenericUDTFGetSplits.java:254)
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to