Skip to content

Conversation

@morningman
Copy link
Contributor

@morningman morningman commented Jan 24, 2022

Proposed changes

Issue Number: close #xxx

Problem Summary:

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.

Checklist(Required)

  1. Does it affect the original behavior: (No)
  2. Has unit tests been added: (Yes)
  3. Has document been added or modified: (No Need)
  4. Does it need to update dependencies: (No)
  5. Are there any changes that cannot be rolled back: (No)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@morningman morningman added kind/fix Categorizes issue or PR as related to a bug. area/lateral-view labels Jan 24, 2022
// tbl1
// tbl1 alias_tbl1
// tbl1 alias_tbl1 lateral view explode_split(k1, ",") tmp1 as e1
String tblName = name.toSql() + ((aliasSql != null) ? " " + aliasSql : "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which printing will be mainly affected after the change here?


@Ignore
// errCode = 2, detailMessage = Unknown column 'e1' in 'table list'
public void testLaterViewWithCTEBug() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore this single test


@Ignore
// errCode = 2, detailMessage = Unknown column 'e1' in 'table list'
public void testLaterViewUnknowColumnBug() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore this single test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leaves to you to fix it. LOL

@EmmyMiao87 EmmyMiao87 self-assigned this Jan 28, 2022
Copy link
Contributor

@EmmyMiao87 EmmyMiao87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jan 28, 2022
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/lateral-view kind/fix Categorizes issue or PR as related to a bug. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants