[
https://issues.apache.org/jira/browse/HIVE-14719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15475971#comment-15475971
]
Rui Li commented on HIVE-14719:
-------------------------------
Thanks [~ashutoshc] for your input. I just did some more debug.
# Suppose originally we have Tree1:
{noformat}
WHERE1
|
AND1
/ \
=1 =2
/ \ / \
DOT1 DOT2 DOT3 DOT4
{noformat}
# Then we replace DOT1 with DOT5, and DOT5's rootNode is null. Then we replace
DOT3 with DOT6. In the process, DOT5's rootNode is re-evaluated as the root of
Tree1. DOT6's rootNode is null. So far everything is fine.
# Then we create AND2 and add =1 and =2 as its children. So we have Tree2:
{noformat}
AND2
/ \
=1 =2
/ \ / \
DOT5 DOT2 DOT6 DOT4
{noformat}
Note that now =1 and =2's parent points to AND2. However, they are not deleted
from Tree1, so that AND1 still considers them as its children.
# At last, we create a new node to replace AND1 (whole subtree) in Tree1.
# DOT5's rootNode still points to Tree1. Suppose Tree1 re-evaluated its AST
string and then we call DOT5::toStringTree, we'll get wrong result.
My v1 patch just coincidentally fixed the issue in step 4 - it clears rootNode
in the subtree of AND1, relying on that AND1 still holds =1 and =2 as its
children.
If deleted node can be considered inaccessible, maybe we should clear rootNode
info when adding a node to a tree?
As for CBO, it takes another code path to parse the query. I haven't looked at
that yet.
> ASTNode rootNode is not maintained properly when changing child/parent
> relation
> -------------------------------------------------------------------------------
>
> Key: HIVE-14719
> URL: https://issues.apache.org/jira/browse/HIVE-14719
> Project: Hive
> Issue Type: Bug
> Reporter: Rui Li
> Assignee: Rui Li
> Attachments: HIVE-14719.1.patch
>
>
> When I run some query like:
> {code}
> set hive.cbo.enable=false;
> select * from A where exists (select * from B where B.k1=A.k1 and B.k2=A.k2);
> {code}
> It gets error like:
> {noformat}
> FAILED: SemanticException Line 0:-1 Invalid table alias or column reference
> 'sq_1': (possible column names are: _table_or_col b) k2) sq_corr_1)) (tok, (.
> (tok_table_or_col sq_1) sq_corr_1))
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)