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
FeatReq: insert "as" for column alias in Parser #1513
Comments
@yiga2 we have avoided writing a complete SQL parser, and even if we did I'm not sure putting 'as' in front of them is going to help you anyway ? |
Well, it does help as Postgres then detects that these reserved keywords are actually aliases here. Give it a try: |
@yiga2 fair enough, however this would require a full fledged SQL parser and impose a parsing penalty on everyone... |
@yiga2 , I'm not sure if you would like that, but there's http://calcite.apache.org You can setup Apache Calcite as a "proxy" on top of pgjdbc (so you submit your queries to Calcite, and it sends relevant queries back to PG behind the scenes). Relevant class in question: https://calcite.apache.org/apidocs/org/apache/calcite/sql/babel/Babel.html mailing list: dev@calcite.apache.org |
How about this ? To add " to aliases. It can execute. |
Why not. To Dave's point, it would require some bulletproof logic to quote or prefix with 'as'. Not sure the demand or traction is there so we just forked and customized to our needs. |
@changkejun and the poor soul that writes select MyType type, MyName name would be screaming at us. |
We have a 3rd party app that issues generic sql statements like so:
select 'mytype' type, 'myname' name from test_table
... which errors out because
name
andtype
are keywords to PG.Instead of hardcoding a replace in a forked repo to make such statements work, can the
Parser
module be enhanced to detect column (or table) aliases and insert theas
keyword if not passed already ?E.g.
select 'mytype' as type, 'myname' as name from test_table
is valid for Postgres.I wouldn't know how to exactly as there is currently no method to parse column names. Maybe some regexps...
The text was updated successfully, but these errors were encountered: