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] support user variable in analytic function #47728

Merged
merged 8 commits into from
Jul 3, 2024

Conversation

packy92
Copy link
Contributor

@packy92 packy92 commented Jul 2, 2024

Why I'm doing:

What I'm doing:

consider user varibale in constant expr check.

Fixes #47225

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

packy92 added 5 commits July 1, 2024 20:31
Signed-off-by: packy92 <wangchao@starrocks.com>
Signed-off-by: packy92 <wangchao@starrocks.com>
Signed-off-by: packy92 <wangchao@starrocks.com>
Signed-off-by: packy92 <wangchao@starrocks.com>
Signed-off-by: packy92 <wangchao@starrocks.com>
@packy92 packy92 requested review from a team as code owners July 2, 2024 04:33
@mergify mergify bot assigned packy92 Jul 2, 2024
}

return Optional.empty();
}
}
Copy link

Choose a reason for hiding this comment

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

The most risky bug in this code is:
Optional.get() without checking for presence

You can modify the code like this:

if (k.isPresent() && counterNum.isPresent() && k.get() > counterNum.get()) {
    throw new SemanticException(
        "The second parameter must be smaller than or equal to the third parameter" +
        functionCallExpr.toSql(), kExpr.getPos());
}

Seaven
Seaven previously approved these changes Jul 2, 2024
Signed-off-by: packy92 <wangchao@starrocks.com>
kangkaisen
kangkaisen previously approved these changes Jul 2, 2024
Signed-off-by: packy92 <wangchao@starrocks.com>
Signed-off-by: packy92 <wangchao@starrocks.com>
Copy link

sonarqubecloud bot commented Jul 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

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

Copy link

github-actions bot commented Jul 2, 2024

[FE Incremental Coverage Report]

pass : 37 / 37 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/analysis/Expr.java 2 2 100.00% []
🔵 com/starrocks/sql/analyzer/AnalyticAnalyzer.java 11 11 100.00% []
🔵 com/starrocks/sql/analyzer/FunctionAnalyzer.java 15 15 100.00% []
🔵 com/starrocks/sql/optimizer/transformer/SqlToScalarOperatorTranslator.java 1 1 100.00% []
🔵 com/starrocks/analysis/UserVariableExpr.java 8 8 100.00% []

Copy link

github-actions bot commented Jul 2, 2024

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@kangkaisen kangkaisen merged commit 09d8d3a into StarRocks:main Jul 3, 2024
47 of 48 checks passed
Copy link

github-actions bot commented Jul 3, 2024

@Mergifyio backport branch-3.3

@github-actions github-actions bot removed the 3.3 label Jul 3, 2024
Copy link

github-actions bot commented Jul 3, 2024

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Jul 3, 2024
Copy link
Contributor

mergify bot commented Jul 3, 2024

backport branch-3.3

✅ Backports have been created

Copy link
Contributor

mergify bot commented Jul 3, 2024

backport branch-3.2

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jul 3, 2024
Signed-off-by: packy92 <wangchao@starrocks.com>
(cherry picked from commit 09d8d3a)
mergify bot pushed a commit that referenced this pull request Jul 3, 2024
Signed-off-by: packy92 <wangchao@starrocks.com>
(cherry picked from commit 09d8d3a)

# Conflicts:
#	test/sql/test_hint/R/test_hint
#	test/sql/test_hint/T/test_hint
wanpengfei-git pushed a commit that referenced this pull request Jul 3, 2024
…7728) (#47789)

Co-authored-by: packy92 <110370499+packy92@users.noreply.github.com>
wanpengfei-git pushed a commit that referenced this pull request Aug 6, 2024
…7728) (#47790)

Signed-off-by: packy92 <wangchao@starrocks.com>
Co-authored-by: packy92 <110370499+packy92@users.noreply.github.com>
Co-authored-by: packy92 <wangchao@starrocks.com>
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.

Support user-defined variables in window expressions
3 participants