Skip to content

Fix MaterializedView select with CTE bug - #5165

Merged
kangkaisen merged 2 commits into
apache:masterfrom
kangkaisen:mv
Jan 4, 2021
Merged

Fix MaterializedView select with CTE bug#5165
kangkaisen merged 2 commits into
apache:masterfrom
kangkaisen:mv

Conversation

@kangkaisen

Copy link
Copy Markdown
Contributor

Fix#5164

For different Analyzer scopes, the id for SelectStmt maybe the same, but the Analyzer instance always unique

private final PlannerContext ctx_;
private final ArrayList<ScanNode> scanNodes = Lists.newArrayList();
private Map<UUID, List<ScanNode>> selectStmtToScanNodes = Maps.newHashMap();
private Map<Analyzer, List<ScanNode>> selectStmtToScanNodes = Maps.newHashMap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the Analyzer of CTE same as outer query?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

No.
For SQL

select id, t1 from(
select id, a as t1 from t
union all
select id, aaa as t1 from t
) k2;

The analyzer instances for select id, a as t1 from t and select id, aaa as t1 from t are different.
Such as, The analyzer instances for select id, a as t1 from t is 6177, which ancestors are[6219,6220,6221],
The analyzer instances for select id, aaa as t1 from t is 6225, which ancestors are[6247,6220,6221].

@EmmyMiao87EmmyMiao87 added area/materialized-view Issues or PRs related to materialized view kind/fix Categorizes issue or PR as related to a bug. labels Dec 29, 2020
morningman
morningman previously approved these changes Jan 3, 2021

@morningmanmorningman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@morningmanmorningman added the approved Indicates a PR has been approved by one committer. label Jan 3, 2021
@morningmanmorningman self-assigned this Jan 3, 2021
@morningman

Copy link
Copy Markdown
Contributor

Hi, @kangkaisen , there are unused imports:

SingleNodePlanner.java:76:8: Unused import - java.util.UUID. [UnusedImports]

Please fix it first.

@kangkaisen

Copy link
Copy Markdown
ContributorAuthor

Hi, @kangkaisen , there are unused imports:

SingleNodePlanner.java:76:8: Unused import - java.util.UUID. [UnusedImports]

Please fix it first.

@morningman done

@morningmanmorningman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kangkaisen
kangkaisen merged commit bcf1091 into apache:masterJan 4, 2021
EmmyMiao87 pushed a commit to EmmyMiao87/incubator-doris that referenced this pull request Jan 26, 2021
Change-Id: I48d6e57ec0beb91606a464f9eb4c45aadec1fc27
@yangzhgyangzhg mentioned this pull request Feb 9, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.area/materialized-viewIssues or PRs related to materialized viewkind/fixCategorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MaterializedView select result is wrong when union all CTE

3 participants

@kangkaisen@morningman@EmmyMiao87