Skip to content

Add a simple optimization of LambdaExpression#18057

Merged
martint merged 2 commits intotrinodb:masterfrom
guiyanakuang:optimize_lambda_body
Aug 12, 2023
Merged

Add a simple optimization of LambdaExpression#18057
martint merged 2 commits intotrinodb:masterfrom
guiyanakuang:optimize_lambda_body

Conversation

@guiyanakuang
Copy link
Copy Markdown
Member

Description

This pr is aimed at optimizing the body expressions in LambdaExpression using existing optimization capabilities.

Additional context and related issues

Release notes

(X) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jun 27, 2023

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: zhangyiqun.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@guiyanakuang guiyanakuang force-pushed the optimize_lambda_body branch from ec1b485 to a3fe246 Compare June 27, 2023 08:19
@cla-bot cla-bot bot added the cla-signed label Jun 27, 2023
@guiyanakuang guiyanakuang marked this pull request as draft June 28, 2023 06:13
@guiyanakuang guiyanakuang force-pushed the optimize_lambda_body branch 2 times, most recently from fde8b2c to e92b9e9 Compare June 28, 2023 06:35
@guiyanakuang guiyanakuang marked this pull request as ready for review June 28, 2023 08:06
@guiyanakuang guiyanakuang requested review from dain and martint June 28, 2023 08:07
@guiyanakuang guiyanakuang force-pushed the optimize_lambda_body branch from e92b9e9 to 5e351c8 Compare June 28, 2023 09:47
Comment on lines +291 to +302
assertOptimizedEquals("\"" + TryFunction.NAME + "\"(() -> 100 * 100)",
"\"" + TryFunction.NAME + "\"(() -> 10000)");
assertOptimizedEquals("\"" + TryFunction.NAME + "\"(() -> CAST('123' as BIGINT))",
"\"" + TryFunction.NAME + "\"(() -> BIGINT '123')");
assertOptimizedEquals("\"" + TryFunction.NAME + "\"(() -> CAST('abc' as BIGINT))",
"\"" + TryFunction.NAME + "\"(() -> CAST('abc' as BIGINT))");
assertOptimizedEquals("\"" + TryFunction.NAME + "\"(() -> IF(false, 1, 0 / 0))",
"\"" + TryFunction.NAME + "\"(() -> 0 / 0)");
assertOptimizedEquals("\"" + TryFunction.NAME + "\"(() -> 5 / 0)",
"\"" + TryFunction.NAME + "\"(() -> 5 / 0)");
assertOptimizedEquals("\"" + TryFunction.NAME + "\"(() -> nullif(true, true))",
"\"" + TryFunction.NAME + "\"(() -> CAST(null AS Boolean))");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rewrite these tests to use a function other that TryFunction.NAME, which is an internal implementation detail and not meant to be used directly. We don't want to introduce dependencies on it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, I replaced TryFunction.NAME with transform.

@guiyanakuang guiyanakuang requested a review from martint August 10, 2023 04:00
@martint martint merged commit 0f4b813 into trinodb:master Aug 12, 2023
@github-actions github-actions bot added this to the 424 milestone Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants