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

[Feature] Support Mysql Field function #55331

Merged
merged 3 commits into from
Feb 8, 2025

Conversation

Wenjun7J
Copy link
Contributor

@Wenjun7J Wenjun7J commented Jan 22, 2025

Why I'm doing:

For custom sorting.

What I'm doing:

Implement field function. Fixes #55585

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.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@Wenjun7J Wenjun7J requested review from a team as code owners January 22, 2025 07:41
@CLAassistant
Copy link

CLAassistant commented Jan 22, 2025

CLA assistant check
All committers have signed the CLA.

@Wenjun7J Wenjun7J changed the title [Enhancement] Support Mysql Field function [Feature] Support Mysql Field function Jan 22, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 22, 2025
@Wenjun7J Wenjun7J force-pushed the support_field_function branch from 90206a8 to 9ed76ac Compare January 22, 2025 07:53
@@ -806,6 +807,45 @@ private static Function getAdjustedAnalyzedFunction(ConnectContext session,
break;
}
}
} else if (FunctionSet.FIELD.equalsIgnoreCase(fnName)) {
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 don't need this change, could be ref greatest function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The goal here is to make the FIELD function compatible with MySQL’s parameter type inference behavior. The default choice of function signature would otherwise lead to inconsistent behavior.

gensrc/script/functions.py Outdated Show resolved Hide resolved
@Wenjun7J Wenjun7J force-pushed the support_field_function branch from 9ed76ac to 4656202 Compare January 26, 2025 06:50
(targetType.isStringType() && argumentTypes[i].isStringType())) {
targetType = Type.getAssignmentCompatibleType(targetType, argumentTypes[i], false);
if (targetType.isInvalid()) {
throw new SemanticException("Parameter's type is not invalid");
Copy link
Contributor

Choose a reason for hiding this comment

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

is not invalid or is invalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Revised as is invalid

result.append(0);
return result.build(true);
} else if (state != nullptr) {
LOG(WARNING) << "state:" << state->all_const << " " << state->list_all_const << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Seaven
Seaven previously approved these changes Feb 5, 2025
trueeyu
trueeyu previously approved these changes Feb 6, 2025
Seaven
Seaven previously approved these changes Feb 6, 2025
HangyuanLiu
HangyuanLiu previously approved these changes Feb 6, 2025
wangsimo0
wangsimo0 previously approved these changes Feb 6, 2025
@Wenjun7J Wenjun7J force-pushed the support_field_function branch 4 times, most recently from 3416d97 to 98d2fc0 Compare February 6, 2025 08:14
@Wenjun7J Wenjun7J force-pushed the support_field_function branch from 98d2fc0 to 0c54136 Compare February 6, 2025 09:20
Signed-off-by: SevenJ <[email protected]>
@Wenjun7J Wenjun7J force-pushed the support_field_function branch 3 times, most recently from 508aab5 to 0648036 Compare February 7, 2025 02:40
Signed-off-by: SevenJ <[email protected]>
@Wenjun7J Wenjun7J force-pushed the support_field_function branch from 0648036 to fae4205 Compare February 7, 2025 03:01
Copy link

sonarqubecloud bot commented Feb 7, 2025

Copy link

github-actions bot commented Feb 7, 2025

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

github-actions bot commented Feb 7, 2025

[FE Incremental Coverage Report]

pass : 34 / 35 (97.14%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/analyzer/FunctionAnalyzer.java 28 29 96.55% [823]
🔵 com/starrocks/sql/analyzer/ExpressionAnalyzer.java 2 2 100.00% []
🔵 com/starrocks/catalog/FunctionSet.java 1 1 100.00% []
🔵 com/starrocks/analysis/Expr.java 3 3 100.00% []

Copy link

github-actions bot commented Feb 7, 2025

[BE Incremental Coverage Report]

fail : 0 / 63 (00.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exprs/string_functions.h 0 63 00.00% [55, 699, 700, 704, 705, 706, 707, 708, 709, 710, 714, 715, 716, 718, 719, 720, 723, 724, 733, 734, 738, 739, 745, 746, 747, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 761, 763, 764, 765, 766, 767, 768, 769, 770, 772, 775, 776, 779, 780, 781, 782, 785, 786, 787, 788, 789, 790, 791, 793, 796, 799, 800]

@Seaven Seaven enabled auto-merge (squash) February 7, 2025 12:45
@andyziye andyziye disabled auto-merge February 8, 2025 02:25
@andyziye andyziye merged commit 976847f into StarRocks:main Feb 8, 2025
57 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation version:3.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support field funciton for custom sorting.
7 participants