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

[Enhancement] Add Trino HLL Function Compatibility Mapping and last_day_of_month Support(StarRocks#40894) #47122

Closed
wants to merge 137 commits into from

Conversation

happut
Copy link
Contributor

@happut happut commented Jun 17, 2024

Why I'm doing:

In version 3.0 and later, StarRocks supports Trino's SQL_dialect mode; however, ongoing enhancements are necessary to further optimize this functionality, so I added the Trino HLL Function Compatibility Mapping and last_day_of_month Support(#40894)

What I'm doing:

Add Trino HLL Function Compatibility Mapping and last_day_of_month Support(#40894)

Fixes #issue
#40894

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
  • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@happut
Copy link
Contributor Author

happut commented Jun 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

This problem has been resolved with new commit.

@LiShuMing
Copy link
Contributor

@mergify rerun

Copy link
Contributor

mergify bot commented Jun 18, 2024

rerun

❌ Sorry but I didn't understand the command. Please consult the commands documentation 📚.

Copy link

[FE Incremental Coverage Report]

pass : 67 / 67 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/connector/parser/trino/Trino2SRFunctionCallTransformer.java 67 67 100.00% []

// todo: support more function transform
}

private static void registerAggregateFunctionTransformer() {
// 1.approx_distinct
registerFunctionTransformer("approx_distinct", 1,
"approx_count_distinct", ImmutableList.of(Expr.class));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this? ImmutableList is fine if use lower java's version(List.of should be used in higher jdk9)?

Copy link
Contributor Author

@happut happut Jun 24, 2024

Choose a reason for hiding this comment

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

image

Because this problem, it make the code be 'B'. So I change the code. Teacher Li, May the problem not be resolved?

LiShuMing
LiShuMing previously approved these changes Jun 24, 2024
FunctionCallTransformer transformer = new FunctionCallTransformer(starRocksFunctionCall, trinoFnArgNums);
FunctionCallTransformer transformer;
if (trinoFnArgNums == 0) {
transformer = new FunctionCallTransformer(starRocksFunctionCall, false);
Copy link
Contributor

@Youngwb Youngwb Jun 25, 2024

Choose a reason for hiding this comment

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

when trinoFnArgNums == 0, what's the difference of these two ctor. and i think you do not need if-else here

Suggested change
transformer = new FunctionCallTransformer(starRocksFunctionCall, false);
transformer = new FunctionCallTransformer(starRocksFunctionCall,trinoFnArgNums);

Copy link
Contributor Author

@happut happut Jun 25, 2024

Choose a reason for hiding this comment

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

I made this change here because the constructor of FunctionCallTransformer handles false and 0 differently.

    public FunctionCallTransformer(FunctionCallExpr targetCall, int argNums) {
        this(targetCall, false, argNums);
    }

    public FunctionCallTransformer(FunctionCallExpr targetCall, boolean variableArgument) {
        this(targetCall, variableArgument, 0);
    }

    private FunctionCallTransformer(FunctionCallExpr targetCall, boolean variableArgument, int argNums) {
        this.targetCall = targetCall;
        this.argNums = argNums;
        this.variableArgument = variableArgument;
        if (variableArgument) {
            this.placeholderExprs = Lists.newArrayList();
        } else {
            this.placeholderExprs = Arrays.asList(new PlaceholderExpr[argNums]);
        }
        init();
    }

If we do not explicitly set variableArgument to false, the array will be out of bounds.

Copy link
Contributor

@Youngwb Youngwb Jun 26, 2024

Choose a reason for hiding this comment

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

This ctor already set variableArgument to false. why not just use this ? like FunctionCallTransformer(starRocksFunctionCall, 0);

public FunctionCallTransformer(FunctionCallExpr targetCall, int argNums) {
        this(targetCall, false, argNums);
 }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you are right. 😓
I should be confused ..... here
`if (variableArgument) {` `
I test this with my computer... wait a moment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already modified and pushed according to your opinions, the code test is normal, thank you!

@Youngwb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any problem with the Main branch? After I rebase, I was reported an error, I couldn't compile.
image

Copy link
Contributor Author

@happut happut Jun 26, 2024

Choose a reason for hiding this comment

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

This is the error.
image

I think it should be this ?

        this.generatedColumnExpr = column.generatedColumnExpr;

In addition, I feel that there are some problem in this pr.
The file change count looks abnormal....
image

In fact, the difference between my branch and the main branch is only the following files
image

Do I need to create a new pr?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry , there is compilation problem in main branch, after we fix it, you can rebase it again

Copy link
Contributor

Choose a reason for hiding this comment

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

#47522 this PR fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Youngwb
Mentor, because some index in this pr are wrong( such as file change count....) , I create a new pr-----

#47529, you can check on it.

happut and others added 12 commits June 26, 2024 11:34
Signed-off-by: DanRoscigno <[email protected]>
Signed-off-by: 絵空事スピリット <[email protected]>
Co-authored-by: 絵空事スピリット <[email protected]>
@happut happut requested review from a team as code owners June 26, 2024 05:09
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jun 26, 2024
@wanpengfei-git wanpengfei-git requested a review from a team June 26, 2024 05:09
Copy link

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

sonarcloud bot commented Jun 26, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@happut happut closed this Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.3 documentation Improvements or additions to documentation PROTO-REVIEW
Projects
None yet
Development

Successfully merging this pull request may close these issues.