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

Quote column name in Phoenix CREATE TABLE statement #3601

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

ebyhr
Copy link
Member

@ebyhr ebyhr commented May 3, 2020

Related to #3466

@cla-bot cla-bot bot added the cla-signed label May 3, 2020
@ebyhr ebyhr requested review from findepi and vincentpoon May 3, 2020 10:27
throw new SkipException("TODO");
if (columnName.equals("a\"quote")) {
assertThatThrownBy(() -> super.testColumnName(columnName))
.hasMessageContaining("Illegal data. Unsupported sql type: QUOTE");
Copy link
Member

Choose a reason for hiding this comment

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

That's incorrect error message. We didn't ask to create a column of type quote.

This is because getEscapedArgument doesn't support escaping " within the name.
If Phoenix does not support this, we need to filter this out on our side.

Then, the correct way to exclude this test case would be like here
https://github.com/prestosql/presto/blob/329a48592ecb6c628712ef3648f2e8da7eb33d38/presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlDistributedQueries.java#L123-L127

Copy link
Member Author

Choose a reason for hiding this comment

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

@findepi Replaced with isColumnNameRejected. As far as I confirmed, we cannot use double-quotation for column name.

Copy link
Member

Choose a reason for hiding this comment

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

@ebyhr thanks!

please make sure the column name is cleanly rejected at some point, so that user knows this is illegal column name, not something else.

eg io.prestosql.plugin.mysql.TestMySqlDistributedQueries#isColumnNameRejected verifies the actual exception message contains "Incorrect column name"

{
// TODO (https://github.com/prestosql/presto/issues/3466) Phoenix generally lacks quoting in underlying queries
throw new SkipException("TODO");
return columnName.equals("a\"quote");
Copy link
Member

Choose a reason for hiding this comment

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

Leave some TODO comment still.
Currently the " in column name leads to SQL injection.
Use of a"quote column should produce a reasonable exception message like "Invalid column name" or "Column name cannot contain a quotation sign". Then, here you should verify the actual exception message.

Additionally, enable testColumnName test in Phoenix.
@ebyhr ebyhr merged commit 300d830 into trinodb:master Oct 7, 2020
@ebyhr ebyhr deleted the phoenix-column branch October 7, 2020 09:59
@ebyhr ebyhr mentioned this pull request Oct 7, 2020
10 tasks
@martint martint added this to the 344 milestone Oct 10, 2020
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.

4 participants