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

Coral-Trino: Replace backquotes with equivalent double quotes #243

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KevinGe00
Copy link
Contributor

@KevinGe00 KevinGe00 commented Mar 10, 2022

Fixes issue #242.

Comment on lines 97 to 103
private static String standardizeSql(String sql) {
return sql.toUpperCase().replaceAll("`", "\"");
}

private static String trimParenthesis(String value) {
String str = value.trim();
if (str.startsWith("(") && str.endsWith(")")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's better to combine these 2 methods together in one method standardizeTrinoSql and add comment of the reason why we need to standardize it.

@ljfgem ljfgem changed the title Replacing backquotes with equivalent double quotes Coral-Trino: Replacing backquotes with equivalent double quotes Mar 10, 2022
}
return str;
return str.toUpperCase().replaceAll("`", "\"");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe putting replaceAll here should avoid unnecessary calls if we need to recurse, would appreciate confirmation on that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we add toUppercase(). Also back quotes can be part of the literals so might accidentally change a backquote that was not supposed to be changed.

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 toUpperCase() is brought over from this line.

@wmoustafa wmoustafa changed the title Coral-Trino: Replacing backquotes with equivalent double quotes Coral-Trino: Replace backquotes with equivalent double quotes Mar 10, 2022
@wmoustafa
Copy link
Contributor

wmoustafa commented Mar 10, 2022

I am not clear on the motivation. So obviously, current test cases do not have this issue. Did you run to them in production views (that they use backquotes)? If yes, how did the production views get created in the first place? You might want to add more details to the description to make the workflow of the issue clear.

@wmoustafa
Copy link
Contributor

By any chance are we using the wrong dialect to generate this SQL? Dialects allow customizing the quotes if that was the issue. See https://github.com/linkedin/coral/blob/master/coral-trino/src/main/java/com/linkedin/coral/trino/rel2trino/TrinoSqlDialect.java#L18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants