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

Use proper SQL identifier semantics for CALL arguments #11163

Conversation

findepi
Copy link
Member

@findepi findepi commented Feb 23, 2022

No description provided.

@findepi
Copy link
Member Author

findepi commented Feb 23, 2022

cc @losipiuk @kasiafi

Comment on lines 7898 to 7899
assertUpdate(optimizeEnabledSession, "ALTER TABLE " + tableName + " EXECUTE \"OPTIMIZE\" (\"file_size_threshold\" => '10B')");
assertUpdate(optimizeEnabledSession, "ALTER TABLE " + tableName + " EXECUTE \"OPTIMIZE\" (\"FILE_SIZE_THRESHOLD\" => '10B')");
Copy link
Member Author

Choose a reason for hiding this comment

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

This feels wrong. Only one of them should pass.

Copy link
Member Author

Choose a reason for hiding this comment

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

It works like this:

So

  • if we want ALTER TABLE EXECUTE (...) properties to be case sensitive, both these places need to be changed/diverged
  • do we want all properties to be case-sensitive? especially the table properties?

cc @martint @kasiafi @dain @losipiuk

Copy link
Member

Choose a reason for hiding this comment

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

I would say that we only allow case-insensitive arguments for procedures. I don't see a benefit to allowing case-sensitive.

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't see a direct benefit here as well, and that's why @losipiuk and I decided to go accept case-insensitivity for ALTER TABLE EXECUTE's parameters.
However, there is a concern about coherence and conformance, which i'd leave up to @martint @kasiafi to debate.

Copy link
Member

Choose a reason for hiding this comment

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

I think that we should respect the proper identifier semantics.
Although it might not seem very beneficial to allow using case-sensitive arguments for procedures, it's about consistency with the spec, and consistency of behavior across Trino. When adding new features, we generally try to be consistent with the spec wrt identifiers. In the long term, we're going to apply per-spec identifiers everywhere.

Copy link
Member

Choose a reason for hiding this comment

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

It's not just about case sensitivity, but also about allowing characters that are invalid unless it's a delimited (quoted) identifier. Once we support quoted identifiers, we should be consistent with the specification -- if an identifier is quoted, it needs to be treated as is (case conversions for non-english characters can be problematic, too, as they depend on locale)

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #11326 to prevent scope creep in this PR.

@findepi findepi force-pushed the findepi/use-proper-sql-identifier-semantics-for-named-call-arguments-dc447d branch from 9b3f81c to e7a215e Compare February 26, 2022 16:09
@cla-bot cla-bot bot added the cla-signed label Feb 26, 2022
@findepi findepi force-pushed the findepi/use-proper-sql-identifier-semantics-for-named-call-arguments-dc447d branch from e7a215e to cff195b Compare February 26, 2022 16:32
@findepi findepi changed the title Use proper SQL identifier semantics for named call arguments Use proper SQL identifier semantics for CALL arguments Feb 28, 2022
@findepi findepi marked this pull request as ready for review February 28, 2022 11:27
@findepi
Copy link
Member Author

findepi commented Feb 28, 2022

Ready to review, even if we decide not to address #11163 (comment) within this PR.

@@ -7891,6 +7891,13 @@ public void testOptimize()
assertUpdate(optimizeEnabledSession, "ALTER TABLE " + tableName + " EXECUTE optimize(file_size_threshold => '10B')");
assertThat(getTableFiles(tableName)).hasSameElementsAs(compactedFiles);

// optimize with delimited procedure name
Copy link
Member

Choose a reason for hiding this comment

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

Could you please separate tests for procedure name from tests for arguments (put them in different methods)? It seems that they are distinct issues. Also, could you add tests with unquoted names in different case?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a smoke test coverage. I put the together because it's not a detailed test for ALTER TABLE EXECUTE itself. (such test doesn't exist, and I don't want to add it)

Comment on lines 7898 to 7899
assertUpdate(optimizeEnabledSession, "ALTER TABLE " + tableName + " EXECUTE \"OPTIMIZE\" (\"file_size_threshold\" => '10B')");
assertUpdate(optimizeEnabledSession, "ALTER TABLE " + tableName + " EXECUTE \"OPTIMIZE\" (\"FILE_SIZE_THRESHOLD\" => '10B')");
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should respect the proper identifier semantics.
Although it might not seem very beneficial to allow using case-sensitive arguments for procedures, it's about consistency with the spec, and consistency of behavior across Trino. When adding new features, we generally try to be consistent with the spec wrt identifiers. In the long term, we're going to apply per-spec identifiers everywhere.

@findepi findepi force-pushed the findepi/use-proper-sql-identifier-semantics-for-named-call-arguments-dc447d branch from f41d71b to c4a1cce Compare March 4, 2022 12:33
@findepi
Copy link
Member Author

findepi commented Mar 4, 2022

Please re-review.

@findepi findepi force-pushed the findepi/use-proper-sql-identifier-semantics-for-named-call-arguments-dc447d branch from c4a1cce to 4e578ce Compare March 4, 2022 23:26
@findepi
Copy link
Member Author

findepi commented Mar 4, 2022

(rebased)

@findepi findepi merged commit 15e7374 into trinodb:master Mar 5, 2022
@findepi findepi deleted the findepi/use-proper-sql-identifier-semantics-for-named-call-arguments-dc447d branch March 5, 2022 21:50
@github-actions github-actions bot added this to the 373 milestone Mar 5, 2022
@findepi findepi mentioned this pull request Mar 5, 2022
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.

5 participants