drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adeneche <...@git.apache.org>
Subject [GitHub] drill pull request: DRILL-1065: Support for ALTER ... RESET statem...
Date Mon, 21 Sep 2015 17:02:52 GMT
Github user adeneche commented on a diff in the pull request:

    https://github.com/apache/drill/pull/159#discussion_r39996054
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/SetOptionHandler.java
---
    @@ -49,45 +53,67 @@ public SetOptionHandler(QueryContext context) {
       }
     
       @Override
    -  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException,
IOException, ForemanSetupException {
    +  public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, ForemanSetupException
{
         final SqlSetOption option = unwrap(sqlNode, SqlSetOption.class);
    -    final String scope = option.getScope();
    -    final String name = option.getName();
         final SqlNode value = option.getValue();
    -    OptionValue.OptionType type;
    -    if (value instanceof SqlLiteral) {
    +    if (value != null && !(value instanceof SqlLiteral)) {
    +      throw UserException.validationError()
    +          .message("Drill does not support assigning non-literal values in SET statements.")
    +          .build(logger);
    +    }
    +
    +    final String scope = option.getScope();
    +    final OptionValue.OptionType type;
    +    if (scope == null) { // No scope mentioned assumed SESSION
    +      type = OptionType.SESSION;
    +    } else {
           switch (scope.toLowerCase()) {
    -        case "session":
    -          type = OptionValue.OptionType.SESSION;
    -          break;
    -        case "system":
    -          type = OptionValue.OptionType.SYSTEM;
    -          break;
    -//        case "query":
    -//          type = OptionValue.OptionType.QUERY;
    -//          break;
    -        default:
    -          throw new ValidationException("Invalid OPTION scope. Scope must be SESSION
or SYSTEM.");
    +      case "session":
    +        type = OptionType.SESSION;
    +        break;
    +      case "system":
    +        type = OptionType.SYSTEM;
    +        break;
    +      default:
    +        throw UserException.validationError()
    +            .message("Invalid OPTION scope %s. Scope must be SESSION or SYSTEM.", scope)
    +            .build(logger);
           }
    +    }
     
    -      if (type == OptionType.SYSTEM) {
    -        // If the user authentication is enabled, make sure the user who is trying to
change the system option has
    -        // administrative privileges.
    -        if (context.isUserAuthenticationEnabled() &&
    -            !ImpersonationUtil.hasAdminPrivileges(
    -                context.getQueryUserName(),
    -                context.getOptions().getOption(ExecConstants.ADMIN_USERS_KEY).string_val,
    -                context.getOptions().getOption(ExecConstants.ADMIN_USER_GROUPS_KEY).string_val))
{
    -          throw UserException.permissionError()
    -              .message("Not authorized to change SYSTEM options.")
    -              .build(logger);
    -        }
    +    if (type == OptionType.SYSTEM) {
    +      // If the user authentication is enabled, make sure the user who is trying to change
the system option has
    +      // administrative privileges.
    +      if (context.isUserAuthenticationEnabled() &&
    +          !ImpersonationUtil.hasAdminPrivileges(
    +            context.getQueryUserName(),
    +            context.getOptions().getOption(ExecConstants.ADMIN_USERS_KEY).string_val,
    --- End diff --
    
    you should reuse `context.getOptions()` as a local variable


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message