Skip to content

Conversation

@EmmyMiao87
Copy link
Contributor

Proposed changes

Issue Number: close #7823

After the subquery is rewritten, the rewritten stmt needs to be reset
(that is, the content of the first analyze semantic analysis is cleared),
and then the rewritten stmt can be reAnalyzed.

The lateral view ref in the previous implementation forgot to implement the reset function.
This caused him to keep the first error message in the second analyze.
Eventually, two duplicate tupleIds appear in the new stmt and are marked with different tuple.
From the explain string, the following syntax will have an additional wrong join predicate.

Query: explain select k1 from test_explode lateral view explode_split(k2, ",") tmp as e1  where k1 in (select k3 from tbl1);
Error equal join conjunct: `k3` = `k3`

This pr mainly adds the reset function of the lateral view
to avoid possible errors in the second analyze
when the lateral view and subquery rewrite occur at the same time.

After the subquery is rewritten, the rewritten stmt needs to be reset
(that is, the content of the first analyze semantic analysis is cleared),
and then the rewritten stmt can be reAnalyzed.

The lateral view ref in the previous implementation forgot to implement the reset function.
This caused him to keep the first error message in the second analyze.
Eventually, two duplicate tupleIds appear in the new stmt and are marked with different tuple.
From the explain string, the following syntax will have an additional wrong join predicate.
```
Query: explain select k1 from test_explode lateral view explode_split(k2, ",") tmp as e1  where k1 in (select k3 from tbl1);
Error equal join conjunct: `k3` = `k3`
```

This pr mainly adds the reset function of the lateral view
to avoid possible errors in the second analyze
when the lateral view and subquery rewrite occur at the same time.
@EmmyMiao87 EmmyMiao87 added kind/fix Categorizes issue or PR as related to a bug. area/lateral-view labels Jan 21, 2022
morningman added a commit that referenced this pull request Jan 28, 2022
…#7865)

fix bugs of lateral view with CTE or where clause.
The error case can be found in newly added tests in `TableFunctionPlanTest.java`
But there are still some bugs not being fixed, so the unit test is annotated with @ignore

This PR contains the change is #7824 :

> Issue Number: close #7823
> 
> After the subquery is rewritten, the rewritten stmt needs to be reset
> (that is, the content of the first analyze semantic analysis is cleared),
> and then the rewritten stmt can be reAnalyzed.
> 
> The lateral view ref in the previous implementation forgot to implement the reset function.
> This caused him to keep the first error message in the second analyze.
> Eventually, two duplicate tupleIds appear in the new stmt and are marked with different tuple.
> From the explain string, the following syntax will have an additional wrong join predicate.
> ```
> Query: explain select k1 from test_explode lateral view explode_split(k2, ",") tmp as e1  where k1 in (select k3 from tbl1);
> Error equal join conjunct: `k3` = `k3`
> ```
> 
> This pr mainly adds the reset function of the lateral view
> to avoid possible errors in the second analyze
> when the lateral view and subquery rewrite occur at the same time.
@morningman
Copy link
Contributor

closed, fixed it #7865

@morningman morningman closed this Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/lateral-view kind/fix Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] lateral view + subquery leads to the error predicate

2 participants