drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hsuanyi <...@git.apache.org>
Subject [GitHub] drill pull request: Drill 4372 review
Date Thu, 17 Mar 2016 04:18:27 GMT
Github user hsuanyi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/397#discussion_r56453886
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillOperatorTable.java
---
    @@ -62,11 +123,70 @@ public void lookupOperatorOverloads(SqlIdentifier opName, SqlFunctionCategory
ca
     
       @Override
       public List<SqlOperator> getOperatorList() {
    -    return operators;
    +    final List<SqlOperator> sqlOperators = Lists.newArrayList();
    +    sqlOperators.addAll(operatorsCalcite);
    +    if(isEnableInference()) {
    +      sqlOperators.addAll(operatorsInferernce);
    +    } else {
    +      sqlOperators.addAll(operatorsDefault);
    +    }
    +
    +    return sqlOperators;
       }
     
       // Get the list of SqlOperator's with the given name.
       public List<SqlOperator> getSqlOperator(String name) {
    -    return opMap.get(name.toLowerCase());
    +    if(isEnableInference()) {
    +      return opMapInferernce.get(name.toLowerCase());
    +    } else {
    +      return opMapDefault.get(name.toLowerCase());
    +    }
    +  }
    +
    +  private void populateWrappedCalciteOperators() {
    +    for(SqlOperator calciteOperator : inner.getOperatorList()) {
    +      final SqlOperator wrapper;
    +      if(calciteOperator instanceof SqlAggFunction) {
    +        wrapper = new DrillCalciteSqlAggFunctionWrapper((SqlAggFunction) calciteOperator,
    +            getFunctionListWithInference(calciteOperator.getName()));
    +      } else if(calciteOperator instanceof SqlFunction) {
    +        wrapper = new DrillCalciteSqlFunctionWrapper((SqlFunction) calciteOperator,
    +            getFunctionListWithInference(calciteOperator.getName()));
    +      } else {
    +        final String drillOpName = FunctionCallFactory.replaceOpWithFuncName(calciteOperator.getName());
    +        final List<DrillFuncHolder> drillFuncHolders = getFunctionListWithInference(drillOpName);
    +        if(drillFuncHolders.isEmpty() || calciteOperator == SqlStdOperatorTable.UNARY_MINUS
|| calciteOperator == SqlStdOperatorTable.UNARY_PLUS) {
    +          continue;
    +        }
    +
    +        wrapper = new DrillCalciteSqlOperatorWrapper(calciteOperator, drillOpName, drillFuncHolders);
    +      }
    +      calciteToWrapper.put(calciteOperator, wrapper);
    +    }
    +  }
    +
    +  private List<DrillFuncHolder> getFunctionListWithInference(String name) {
    +    final List<DrillFuncHolder> functions = Lists.newArrayList();
    +    for(SqlOperator sqlOperator : opMapInferernce.get(name.toLowerCase())) {
    +      if(sqlOperator instanceof DrillSqlOperator) {
    +        final List<DrillFuncHolder> list = ((DrillSqlOperator) sqlOperator).getFunctions();
    +        if(list != null) {
    +          functions.addAll(list);
    +        }
    +      }
    +
    +      if(sqlOperator instanceof DrillSqlAggOperator) {
    +        final List<DrillFuncHolder> list = ((DrillSqlAggOperator) sqlOperator).getFunctions();
    +        if(list != null) {
    +          functions.addAll(list);
    +        }
    +      }
    +    }
    +    return functions;
    +  }
    +
    +  private boolean isEnableInference() {
    --- End diff --
    
    addressed


---
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