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
DRILL-1065: Support for ALTER ... RESET statement #159
Conversation
}else{ | ||
throw new ValidationException("Sql options can only be literals."); | ||
} else { // RESET option | ||
if ("ALL".equals(name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.equalsIgnoreCase(...)
I worked around the fallback structure of option managers, which is wrong. I will update the pull request soon. |
@@ -35,6 +37,20 @@ | |||
} | |||
|
|||
@Override | |||
public void deleteOption(final String name, final OptionValue.OptionType type) { | |||
throw UserException.unsupportedError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why throw a UserException here ? is the error message relevant to the user ? do we even expect this method to be called ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this in my new implementation.
f785c3b
to
b0133af
Compare
} | ||
|
||
@Test | ||
public void setAndResetSystemOption() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a test where both SYSTEM and SESSION options are changed, and confirm the reset is working as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changeSessionAndNotSystem and changeSystemAndNotSession are testing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding those unit tests
I have added a note to the SessionOptionManager that the effects of deleting a short lived option are undefined because that requires slightly extensive changes, which is out of scope for this JIRA. @jacques-n please review the changes in CompoundIdentifierConverter class. |
@@ -107,7 +117,7 @@ public SqlNode visitChild( | |||
} | |||
SqlNode newOperand = operand.accept(CompoundIdentifierConverter.this); | |||
enableComplex = localEnableComplex; | |||
if (newOperand != operand) { | |||
if (! newOperand.equalsDeep(operand, false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to call equalsDeep()? If the expression has an identifier which is rewritten by CompoundIdentifierConverter, is it true that the new expression would be different in reference from then original one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by this change. Operands are expected to be immutable. As such, identity comparison should be sufficient. Are you trying to avoid excessive rewrites?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted this change. Will post a new patch soon.
As an aside, I'm really excited about this commit. Should make things much easier for end users. We should probably create a new jira to update the docs to remove escaping for all the options. |
We use "exec" as the first part of many option names (e.g. |
0f97e40
to
5c9dfef
Compare
Let's fix this as part of the patch. Since we don't actually support EXEC (as far as I can remember), let's make this work nicely by removing it as a reserved word. (I think there is an unreserved reserved word list in the parser). @julianhyde may be able to help point us in the write direction. |
(commenting here and not on the commit) There are various |
Hey @julianhyde, looks like the keyword list can be extended but non-reserved keywords cannot be. Should I open a JIRA? |
Yes, open a JIRA. We don't need NonReservedKeyWord() and CommonNonReservedKeyWord() to be separate anymore, so you can generate code into whichever one is most convenient. |
Here's the list of keywords that we need to add to the non-reserved list: ["EXEC", "JOIN", "WINDOW", "LARGE", "PARTITION", "OLD", "COLUMN"]. Given Calcite's note about such a list and the standard, I am against making this change. There are a lot of unit test failures (PARSE ERROR) in TestWindowFrame and TestWindowFunctions with this change. @julianhyde What are the implications of adding a keyword to the non-reserved list (say "JOIN")? Also the option "store.parquet.block-size" has a "-" in it which is not allowed. So do we are escape the word? Or change the name? |
Okay, let's skip this for now. |
@sudheeshkatkam can you please rebase, and create a separate JIRA for removing exec from reserved words. +1, LGTM except Thanks |
The CompoundIdentifierConverter.java changes look sound. There is no reason to do identifier expansion for the purpose of SetOptions. +1 |
5c9dfef
to
62625c3
Compare
Rebased, squashed, and edited the commit message. Also, see DRILL-3875. |
@@ -179,6 +181,7 @@ public void validate(final OptionValue v) { | |||
|
|||
public TypeValidator(final String name, final Kind kind, final OptionValue defValue) { | |||
super(name); | |||
checkArgument(defValue.type == OptionType.SYSTEM, "Default value must be SYSTEM type."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you modify all of these to return UserException? Maybe create a static method ideally reporting the specific option and value as additional UserException context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is when a TypeValidator (static instance) is created, so developers know not to create a validator with non SYSTEM level option type. Nothing to do with usage. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these? I may have just missed the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused.. what does "these" refer to? I do not see any other precondition checks.
That change was addressing Hakim's comment here. The issue was when ControlsOptionValidator was being registered with the SystemOptionManager, the default option was being stored within SystemOptionManager as a SESSION option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three other checkArguments in this changeset. However, I think they also refer to dev mistakes instead of user errors. Probably fine as is.
Looks good. One small change above. Otherwise +1. |
+ Support for "SET option = value" statement (assumes scope as SESSION) + Bump Calcite version to include CALCITE-823 (Parser support for "ALTER ... RESET" statement). This commit includes a breaking change: SqlSetOption#getName now returns a SqlIdentifier rather than a String => option names are multi-part identifiers, and do not require escaping + Add rule in CompoundIdentifierConverter (+ Override annotations) + Improve error messages in SetOptionHandler + Add documentation (CompoundIdentifierConverter, OptionValue, SessionOptionManager, SystemOptionManager) - Does not include support for deleting short lived options + Default ExecutionControls option value should be at SYSTEM level + Change asserts to preconditions in SystemOptionManager + Add a precondition to TypeValidator's ctor to ensure default values are set at SYSTEM level + Address Hakim's and Jinfeng's review comments
028c983
to
8802d83
Compare
@jacques-n @vkorukanti please review.