Skip to content

Preserve quotedness for Identifier when formatting Query #80

Merged
martint merged 1 commit into
trinodb:masterfrom
Praveen2112:maintain_quotedness
Feb 4, 2019
Merged

Preserve quotedness for Identifier when formatting Query #80
martint merged 1 commit into
trinodb:masterfrom
Praveen2112:maintain_quotedness

Conversation

@Praveen2112

Copy link
Copy Markdown
Member

Presto doesn't maintain the quotedness of an identifier when using SqlQueryFormatter so it results in throwing parsing error when we run prepare query of the syntax [https://github.com/prestodb/presto/issues/10739]. This PR solves that above issue

@cla-bot cla-bot Bot added the cla-signed label Jan 26, 2019
@martint martint self-assigned this Jan 28, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It shouldn't be necessary to call toLowerCase(). The DereferenceExpression already deals with Identifiers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In fact, I don't think the tryParseParts method needs to exist anymore in its current form.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a little hard to read. I'd pull it out into a makeQualifiedName. Also, I'd structure it as:

List<Identifier> parts = Arrays.stream(fullName.split("\\."))
        .map(Identifier::new)
        .collect(Collectors.toList());

return QualifiedName.of(parts);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be changed to Arrays.stream(fullName.split("\\.")).xxx like the calls in TestSqlParser and formatted across multiple lines to make it more readable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Call this TestSqlFormatter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems unnecessary. It looks like you could just do: new CreateView(node.getName(), ...) instead of trying to recreate the QualifiedName from the QualifiedObjectName that was derived from node.getName().

If you do that, you should also be able to remove MetadataUtil.getDelimitedList(), which I'm not fond of.

@martint martint assigned Praveen2112 and unassigned martint Jan 30, 2019

@martint martint left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Can you rebase and fix the merge conflicts? I'll merge it once that's taken care of.

@Praveen2112

Copy link
Copy Markdown
Member Author

@martint I have updated the code and resolved the conflicts.

@martint

martint commented Feb 3, 2019

Copy link
Copy Markdown
Member

@Praveen2112, there are some build failures. Can you take a look?

We maintain Identifier in QualifiedName for preserving its quotedness.
@martint martint merged commit d5dfc99 into trinodb:master Feb 4, 2019
@martint martint mentioned this pull request Feb 4, 2019
6 tasks
v-jizhang added a commit to v-jizhang/presto that referenced this pull request Feb 22, 2022
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
when we run prepare query of the syntax
[prestodb#10739].
This PR solves that above issue.

Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
zhenxiao pushed a commit to prestodb/presto that referenced this pull request Feb 24, 2022
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
when we run prepare query of the syntax
[#10739].
This PR solves that above issue.

Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
imjalpreet added a commit to imjalpreet/presto that referenced this pull request Jun 8, 2023
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
agrawalreetika pushed a commit to agrawalreetika/prestodb that referenced this pull request Mar 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
agrawalreetika pushed a commit to agrawalreetika/prestodb that referenced this pull request Mar 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
agrawalreetika pushed a commit to agrawalreetika/prestodb that referenced this pull request Apr 22, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
agrawalreetika pushed a commit to agrawalreetika/prestodb that referenced this pull request Apr 23, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 14, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 25, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 26, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 27, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 27, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 29, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to agrawalreetika/prestodb that referenced this pull request Jul 29, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
agrawalreetika added a commit to prestodb/presto that referenced this pull request Jul 30, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
YiChengLee03 pushed a commit to YiChengLee03/presto that referenced this pull request Jul 30, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 2, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
lga-zurich pushed a commit to lga-zurich/presto-exchange that referenced this pull request Sep 8, 2025
Cherry-pick of trinodb/trino#80

Presto doesn't maintain the quotedness of an identifier when
using SqlQueryFormatter so it results in throwing parsing error
if quoted table name is a reserved word
Co-authored-by: praveenkrishna <praveenkrishna@tutanota.com>

Co-authored-by: imjalpreet <jalpreetnanda@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants