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 parse select expr as alias_name #4841

Merged

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented Apr 13, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

After this pr, this SQL will return err.

SELECT TRUE as `_`  FROM `t1` WHERE 1 <> 1 LIMIT 0;

ERROR 1105 (HY000): Code: 1005, displayText = sql parser error: Expected an identifier after AS, found: `_`.

The err occurs in sqlparser, the err has already been fixed there.

Changelog

  • New Feature

Related Issues

Fixes #4840

@vercel
Copy link

vercel bot commented Apr 13, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/databend/databend/DvnZBNNsgP5Q1QhSJTE2VJXqkpAo
✅ Preview: Ignored

[Deployment for 92dc8aa canceled]

@mergify
Copy link
Contributor

mergify bot commented Apr 13, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Apr 13, 2022
Expr::Cast { expr, data_type } => Ok(Expr::Cast {
Expr::Cast {
expr, data_type, ..
} => Ok(Expr::Cast {
Copy link
Collaborator Author

@TCeason TCeason Apr 13, 2022

Choose a reason for hiding this comment

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

@b41sh Hi the pg_style can be set false at there?

Copy link
Member

Choose a reason for hiding this comment

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

We don't used pg_style, i think it's OK here.

Copy link
Member

Choose a reason for hiding this comment

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

we can set pg_style as false, it is used to distinguish the field names of two different casts.

select cast(a as int8) from test;
select a::int8 from test;

I am working on this modification, you can set it as false first.

@BohuTANG
Copy link
Member

This need a stateless test, it is easy to find the bug when the new sqlparser is introduced someday.

@TCeason TCeason force-pushed the ISSUE-4840/support_parse_alias_back_quoted branch from a5968a4 to 92dc8aa Compare April 13, 2022 09:27
@TCeason
Copy link
Collaborator Author

TCeason commented Apr 13, 2022

This need a stateless test, it is easy to find the bug when the new sqlparser is introduced someday.

Yep, you are right. Added.

Expr::Cast {
expr,
data_type,
pg_style: _pg_style,
Copy link
Member

Choose a reason for hiding this comment

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

Does the new version of sqlparser introduced pg_style params?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

O, @b41sh should know it better :D

@b41sh
Copy link
Member

b41sh commented Apr 13, 2022

/LGTM

@BohuTANG BohuTANG merged commit ba84e6b into databendlabs:main Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Support select expr as alias name
4 participants