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

DRILL-1065: Support for ALTER ... RESET statement #159

Closed
wants to merge 2 commits into from

Conversation

sudheeshkatkam
Copy link
Contributor

  • Support for "SET option = value" statement (assumes scope as SESSION)
  • Better error messages in SetOptionHandler
  • Changes in CompoundIdentifierConverter
    • update when rewritten operand is not deeply equal to the original operand
    • Added Override annotations
  • Default ExecutionControls option value should be at SYSTEM level

@jacques-n @vkorukanti please review.

}else{
throw new ValidationException("Sql options can only be literals.");
} else { // RESET option
if ("ALL".equals(name)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

.equalsIgnoreCase(...)

@sudheeshkatkam
Copy link
Contributor Author

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()
Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

}

@Test
public void setAndResetSystemOption() throws Exception {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

@sudheeshkatkam
Copy link
Contributor Author

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)) {
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@jacques-n
Copy link
Contributor

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.

@sudheeshkatkam
Copy link
Contributor Author

We use "exec" as the first part of many option names (e.g. exec.min_hash_table_size), and unfortunately, "exec" is a keyword, and the parser throws an error (... PARSE ERROR: Encountered "SET exec" ...). We still have to escape keywords.

@jacques-n
Copy link
Contributor

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.

@sudheeshkatkam
Copy link
Contributor Author

(commenting here and not on the commit)

There are various getOption(...) convenient methods in the OptionManager interface with typed validators as parameters (like StringValidator) which return the value with that type (like String).

@sudheeshkatkam
Copy link
Contributor Author

Hey @julianhyde, looks like the keyword list can be extended but non-reserved keywords cannot be. Should I open a JIRA?

@julianhyde
Copy link
Contributor

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.

@sudheeshkatkam
Copy link
Contributor Author

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?

@jacques-n
Copy link
Contributor

Okay, let's skip this for now.

@adeneche
Copy link
Contributor

@sudheeshkatkam can you please rebase, and create a separate JIRA for removing exec from reserved words.

+1, LGTM except CompoundIdentifierConverter.java I don't have enough knowledge to review this class. @jacques-n can you please review the change in this file ?

Thanks

@jacques-n
Copy link
Contributor

The CompoundIdentifierConverter.java changes look sound. There is no reason to do identifier expansion for the purpose of SetOptions. +1

@sudheeshkatkam
Copy link
Contributor Author

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.");
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@jacques-n
Copy link
Contributor

Looks good. One small change above. Otherwise +1.

Sudheesh Katkam added 2 commits October 1, 2015 15:28
+ 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
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

5 participants