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

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

                Author: ASF GitHub Bot
            Created on: 21/Jul/20 19:32
            Start Date: 21/Jul/20 19:32
    Worklog Time Spent: 10m 
      Work Description: jcamachor commented on a change in pull request #1263:
URL: https://github.com/apache/hive/pull/1263#discussion_r458335606



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
##########
@@ -12566,38 +12565,44 @@ void analyzeInternal(ASTNode ast, 
Supplier<PlannerContext> pcf) throws SemanticE
       createVwDesc.setTablesUsed(getTablesUsed(pCtx));
     }
 
-    // 6. Generate table access stats if required
-    if (HiveConf.getBoolVar(this.conf, 
HiveConf.ConfVars.HIVE_STATS_COLLECT_TABLEKEYS)) {
-      TableAccessAnalyzer tableAccessAnalyzer = new TableAccessAnalyzer(pCtx);
-      setTableAccessInfo(tableAccessAnalyzer.analyzeTableAccess());
-    }
+    //If we're creating views and ColumnAccessInfo is already created, we 
should not run these.
+    if(!forViewCreation ||  getColumnAccessInfo() == null) {
+      // 6. Generate table access stats if required
+      if (HiveConf.getBoolVar(this.conf, 
HiveConf.ConfVars.HIVE_STATS_COLLECT_TABLEKEYS)) {
+        TableAccessAnalyzer tableAccessAnalyzer = new 
TableAccessAnalyzer(pCtx);
+        setTableAccessInfo(tableAccessAnalyzer.analyzeTableAccess());
+      }
+      AuxOpTreeSignature.linkAuxSignatures(pCtx);
+      // 7. Perform Logical optimization
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Before logical optimization\n" + 
Operator.toString(pCtx.getTopOps().values()));
+      }
+      Optimizer optm = new Optimizer();
+      optm.setPctx(pCtx);
+      optm.initialize(conf);
+      pCtx = optm.optimize();
+      if (pCtx.getColumnAccessInfo() != null) {
+        // set ColumnAccessInfo for view column authorization
+        setColumnAccessInfo(pCtx.getColumnAccessInfo());
+      }
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("After logical optimization\n" + 
Operator.toString(pCtx.getTopOps().values()));
+      }
 
-    AuxOpTreeSignature.linkAuxSignatures(pCtx);
-    // 7. Perform Logical optimization
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Before logical optimization\n" + 
Operator.toString(pCtx.getTopOps().values()));
-    }
-    Optimizer optm = new Optimizer();
-    optm.setPctx(pCtx);
-    optm.initialize(conf);
-    pCtx = optm.optimize();
-    if (pCtx.getColumnAccessInfo() != null) {
-      // set ColumnAccessInfo for view column authorization
-      setColumnAccessInfo(pCtx.getColumnAccessInfo());
+      // 8. Generate column access stats if required - wait until column 
pruning

Review comment:
       Can we add information to the comment above about why we are skipping 
those specific steps 6-8?

##########
File path: ql/src/test/results/clientpositive/llap/ppd_deterministic_expr.q.out
##########
@@ -198,6 +198,9 @@ PREHOOK: query: create view viewDeterministicUDFA 
partitioned on (vpart1, vpart2
 where part1 in ('US', 'CA')
 PREHOOK: type: CREATEVIEW
 PREHOOK: Input: default@testa
+PREHOOK: Input: default@testa@part1=CA/part2=ABC/part3=300

Review comment:
       This is a CREATE VIEW. Why are partitions that are not accessed part of 
the entities accessed? This should not have changed? This happens in all these 
different tests so the root cause should be the same.




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

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 461724)
    Time Spent: 1h 40m  (was: 1.5h)

> Hive skips the creation of ColumnAccessInfo when creating a view
> ----------------------------------------------------------------
>
>                 Key: HIVE-23849
>                 URL: https://issues.apache.org/jira/browse/HIVE-23849
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Barnabas Maidics
>            Assignee: Barnabas Maidics
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> When creating a view, Hive skips the creation of ColumnAccessInfo that should 
> be created at [step 8|#L12601]. This causes Authorization error. 
> Currently, this issue is "hidden" when CBO is enabled. By introducing 
> HIVE-14496, CalcitePlanner creates this ColumnAccessInfo at [step 
> 2|https://github.com/apache/hive/blob/11e069b277fd1a18899b8ca1d2926fcbe73f17f2/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java#L12459].
>  But after turning off CBO, the issue is still there. 
> I think the return statement in [step 
> 5|https://github.com/apache/hive/blob/11e069b277fd1a18899b8ca1d2926fcbe73f17f2/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java#L12574]
>  is not necessary.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to