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

support for SELECT special functions #24888

Merged
merged 4 commits into from
Apr 7, 2023
Merged

support for SELECT special functions #24888

merged 4 commits into from
Apr 7, 2023

Conversation

kanha-gupta
Copy link
Contributor

@kanha-gupta kanha-gupta commented Mar 29, 2023

Ref #24200 .

Changes proposed in this pull request:


Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.

@kanha-gupta
Copy link
Contributor Author

kanha-gupta commented Mar 29, 2023

@strongduanmu Hello, I request you to review it please.
task 1
Right now, Checks require approval which makes the coding process slightly slow therefore may you please help/suggest regarding automatic checks in pull request ?
Thank you.

@strongduanmu
Copy link
Member

Hi @kanha-gupta, can you refer issue #24200 for this pr?

@kanha-gupta
Copy link
Contributor Author

kanha-gupta commented Mar 30, 2023

@strongduanmu Hello
The code is getting build error Failures:
[ERROR] InternalMySQLParserIT>InternalSQLParserIT.assertSupportedSQL:60
SQL Case ID : select_char
SQL : SELECT CHAR(77,121,83,81,'76')
ProjectionsSegment's stop index assertion error:

Expected: is <44>
but: was <29>

XML code already have expected value at stop index
Can you please suggest error resolution ?
Thank you
(select_char test is being passed successfully in SQLNodeConverterEngineIT.java)
PS- I made a PR previously for the same for demonstration & build was successful at that time that's why I have problems in figuring out the error #24459

@kanha-gupta
Copy link
Contributor Author

@strongduanmu Hello,
Can you please suggest How to parse Identifiers & symbols in MySQLStatementSQLVisitor.java & related XML files from their Antlr grammar files ?
I tried finding a solution but I cant come up to solution looking at existing codebase.
Thank you

@kanha-gupta kanha-gupta changed the title support for Char function support for SELECT special functions Apr 2, 2023
@strongduanmu
Copy link
Member

Hi @kanha-gupta, can you merge master branch?

@kanha-gupta
Copy link
Contributor Author

kanha-gupta commented Apr 3, 2023

@strongduanmu Done, please check.
Also I have Posted a Query, Please check #24970

@@ -966,7 +971,9 @@ public final ASTNode visitTrimFunction(final TrimFunctionContext ctx) {
@Override
public final ASTNode visitWeightStringFunction(final WeightStringFunctionContext ctx) {
calculateParameterCount(Collections.singleton(ctx.expr()));
return new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.WEIGHT_STRING().getText(), getOriginalText(ctx));
FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.WEIGHT_STRING().getText(), getOriginalText(ctx));
result.getParameters().add((LiteralExpressionSegment) visit(ctx.expr()));
Copy link
Member

Choose a reason for hiding this comment

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

Do you think use (ExpressionSegment) visit(ctx.expr()) is better? (LiteralExpressionSegment) visit(ctx.expr()) will cause class cast exception.

FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.CHAR().getText(), getOriginalText(ctx));
for (ExprContext each : ctx.expr()) {
ASTNode expr = visit(each);
result.getParameters().add((LiteralExpressionSegment) expr);
Copy link
Member

Choose a reason for hiding this comment

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

Do you think use (ExpressionSegment) visit(ctx.expr()) is better? (LiteralExpressionSegment) visit(ctx.expr()) will cause class cast exception.

Copy link
Member

@strongduanmu strongduanmu left a comment

Choose a reason for hiding this comment

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

Good job, merged.

@strongduanmu strongduanmu merged commit e3527b3 into apache:master Apr 7, 2023
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.

2 participants