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

fix: include lower-case identifiers among those that need quotes #3723

Merged
merged 1 commit into from
Nov 4, 2019

Conversation

rodesai
Copy link
Contributor

@rodesai rodesai commented Nov 3, 2019

IdentifierUtils::needsQuotes is used by various code that formats SQL text to decide what identifiers to wrap in quotes. Before this change, this just included reserved identifiers. However, identifiers that include lower-case characters should also be quoted. Otherwise, when the parser parses them it will convert them to upper-case.

@rodesai rodesai requested a review from a team as a code owner November 3, 2019 02:44
@rodesai rodesai requested a review from agavra November 3, 2019 02:44
Copy link
Contributor

@big-andy-coates big-andy-coates left a comment

Choose a reason for hiding this comment

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

Thanks @rodesai, LGTM, though best to check with @agavra as well given he's working in this area.

Copy link
Contributor

@agavra agavra left a comment

Choose a reason for hiding this comment

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

LGTM - it'd be nice to have a description explaining the background of why we did this/how you discovered it (so that in the future if I git blame and go the PR I see the background)

IdentifierUtils::needsQuotes is used by various code that formats SQL text to
decide what identifiers to wrap in quotes. Before this change, this just included
reserved identifiers. However, identifiers that include lower-case characters should
also be quoted. Otherwise, when the parser parses them it will convert them to
upper-case. So this patch changes needsQuotes to check for lower-case characters.

For schema inference, we don't want to quote column names generated from lower-case
avro schema fields. To handle this, this patch adds IdentifierUtils.isValid, that
only returns true if the identifier is valid (parsable). Schema inference uses this
to only quote invalid identifiers.
@rodesai rodesai merged commit 62c47bf into confluentinc:master Nov 4, 2019
stevenpyzhang pushed a commit to stevenpyzhang/ksql that referenced this pull request Apr 22, 2020
…fluentinc#3723)

IdentifierUtils::needsQuotes is used by various code that formats SQL text to
decide what identifiers to wrap in quotes. Before this change, this just included
reserved identifiers. However, identifiers that include lower-case characters should
also be quoted. Otherwise, when the parser parses them it will convert them to
upper-case. So this patch changes needsQuotes to check for lower-case characters.

For schema inference, we don't want to quote column names generated from lower-case
avro schema fields. To handle this, this patch adds IdentifierUtils.isValid, that
only returns true if the identifier is valid (parsable). Schema inference uses this
to only quote invalid identifiers.
stevenpyzhang added a commit that referenced this pull request Apr 22, 2020
…) (#5139)

IdentifierUtils::needsQuotes is used by various code that formats SQL text to
decide what identifiers to wrap in quotes. Before this change, this just included
reserved identifiers. However, identifiers that include lower-case characters should
also be quoted. Otherwise, when the parser parses them it will convert them to
upper-case. So this patch changes needsQuotes to check for lower-case characters.

For schema inference, we don't want to quote column names generated from lower-case
avro schema fields. To handle this, this patch adds IdentifierUtils.isValid, that
only returns true if the identifier is valid (parsable). Schema inference uses this
to only quote invalid identifiers.

Co-authored-by: Rohan <desai.p.rohan@gmail.com>
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.

None yet

3 participants