Skip to content

Conversation

@EmmyMiao87
Copy link
Contributor

@EmmyMiao87 EmmyMiao87 commented Oct 12, 2020

If the materialized slot is empty in inline view, the scanner will throw exception 'no materialized slot!'.
When the outer query does not need any real columns of the inner query at all, such as the outer query only contains constant calculations,
all slots in the inner query will not be materialized.
For example:

select c1 from (select 'xx' c1, k1 from test) t1;

But this does not mean that the inner query (select 'xx' c1, k1 from test) does not need to be executed.
Because the number of rows in the outer result needs to be determined by the number of rows in the inner query.
In this case, the inner query scan node needs to add a column to ensure the correct result.
At the same time it can avoid the scan node reporting errors.

Fixed #4716

Change-Id: I86bb52efab65b658ea78094037543cb23dbff1d4

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] Documentation Update (if none of the other choices apply)
  • [] Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have create an issue on (Fix #ISSUE), and have described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • [] I have added tests that prove my fix is effective or that my feature works
  • [] If this change need a document change, I have updated the document
  • [] Any dependent changes have been merged

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

If the materilized slot is empty in inline view, the scanner will throw exception 'no materialized slot!'.
When the outer query does not need any real columns of the inner query at all, such as the outer query only contains constant calculations,
all slots in the inner query will not be materialized.
For example:
```
select c1 from (select 'xx' c1, k1 from test) t1;
```

But this does not mean that the inner query (select 'xx' c1, k1 from test) does not need to be executed.
Because the number of rows in the outer result needs to be determined by the number of rows in the inner query.
In this case, the inner query scan node needs to add a column to ensure the correct result.
At the same time it can avoid the scan node reporting errors.

Fixed apache#4716

Change-Id: I86bb52efab65b658ea78094037543cb23dbff1d4
@EmmyMiao87 EmmyMiao87 added kind/fix Categorizes issue or PR as related to a bug. area/planner Issues or PRs related to the query planner labels Oct 12, 2020
@kangkaisen
Copy link
Contributor

+1. But please add a UT for this bug.

@EmmyMiao87
Copy link
Contributor Author

+1. But please add a UT for this bug.

This single test is a bit difficult to add, because the slot information is not displayed in the explain.

Or should I just add a single test for this function materializeBaseTableRefResultForCrossJoinOrCountStar ?

@kangkaisen
Copy link
Contributor

+1. But please add a UT for this bug.

This single test is a bit difficult to add, because the slot information is not displayed in the explain.

Or should I just add a single test for this function materializeBaseTableRefResultForCrossJoinOrCountStar ?

OK

Change-Id: Ide230180dfe8d240693c585648b3fb5d514cbd48
kangkaisen
kangkaisen previously approved these changes Oct 12, 2020
Copy link
Contributor

@kangkaisen kangkaisen left a comment

Choose a reason for hiding this comment

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

+1

@kangkaisen kangkaisen added the approved Indicates a PR has been approved by one committer. label Oct 12, 2020
* @param tblRef
* @param analyzer
*/
private void materializeBaseTableRefResultForCrossJoinOrCountStar(BaseTableRef tblRef, Analyzer analyzer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method name should be changed to a more common name?
like: materializeSlotForEmptyMaterializedTableRef()?
And add examples in comment to explain why we call it.

Change-Id: I51d5e71acdabfb4e48389436391e19917c36f52c
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman merged commit bf8f68f into apache:master Oct 13, 2020
@yangzhg yangzhg mentioned this pull request Feb 9, 2021
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/planner Issues or PRs related to the query planner kind/fix Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to query constant which is in inline view

3 participants