Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Enchance output of explain for optimized plan #33718

Closed
wants to merge 2 commits into from

Conversation

matriv
Copy link
Contributor

@matriv matriv commented Sep 14, 2018

When a literal expression is replaced with its evaluated value,
in the optimizer, then use this new evaluated value in the explain plan
instead of the original expression.

@elasticdog
Copy link
Contributor

This job triggered CI during a migration of the master. Kicking off an additional build for you manually...

Jenkins, test this please.

1 similar comment
@elasticdog
Copy link
Contributor

This job triggered CI during a migration of the master. Kicking off an additional build for you manually...

Jenkins, test this please.

@matriv matriv added the :Analytics/SQL SQL querying label Sep 14, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@matriv matriv added the v7.0.0 label Sep 14, 2018
@matriv
Copy link
Contributor Author

matriv commented Sep 14, 2018

@elasticmachine retest this please

1 similar comment
@matriv
Copy link
Contributor Author

matriv commented Sep 14, 2018

@elasticmachine retest this please

assertThat(command("EXPLAIN (PLAN OPTIMIZED) SELECT POWER(i, (1 - 2)) * ABS(10 + 20) FROM test"),
containsString("plan"));
assertThat(readLine(), startsWith("----------"));
assertThat(readLine(), startsWith("Project[[((POWER(i,(1 - 2))) * ABS((10 + 20)))#"));
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this plan have the constants (1-2 and ABS(10+20)) folded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM

@costin costin added the v6.5.0 label Sep 14, 2018
@costin
Copy link
Member

costin commented Sep 14, 2018

Added 6.5 as label

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

@matriv matriv added the WIP label Oct 16, 2018
@colings86 colings86 added v6.6.0 and removed v6.5.0 labels Oct 25, 2018
When a literal expression is replaced with its evaluated value,
in the optimizer, then use this new evaluated value in the explain plan
instead of the original expression.
@matriv matriv added v6.5.1 and removed WIP labels Oct 30, 2018
@costin
Copy link
Member

costin commented Nov 5, 2018

Can we conclude this PR? is it still needed or was it solved already in the meantime?

@matriv
Copy link
Contributor Author

matriv commented Nov 5, 2018

@costin I think it's ready now. I added this: 66fccef#diff-0d1503677f70eae9fa10767e44075cecR96 (Unfortunately I messed up something and I forced pushed). The literal expressions are now folded: 66fccef#diff-694b8d3dd996b57e56c623dfa0a796fdR177
66fccef#diff-694b8d3dd996b57e56c623dfa0a796fdR170

StringJoiner sj = new StringJoiner(",", "(", ")");
for (Expression child : children()) {
String val;
if (child instanceof Function) {
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a good case of overloading/method dispatch.
Literal already returns its value or, in case it is named, name=value.
Function does something similar I believe (especially for operators).

@matriv
Copy link
Contributor Author

matriv commented Jan 30, 2020

Closing as obsolete.

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

Successfully merging this pull request may close these issues.

None yet