Github user hsuanyi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/377#discussion_r53809552
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFunctionRegistry.java
 ---
    @@ -92,38 +94,46 @@ public DrillFunctionRegistry(ScanResult classpathScan) {
       }
     
       public int size(){
    -    return methods.size();
    +    return registeredFunctions.size();
       }
     
       /** Returns functions with given name. Function name is case 
insensitive. */
       public List<DrillFuncHolder> getMethods(String name) {
    -    return this.methods.get(name.toLowerCase());
    +    return this.registeredFunctions.get(name.toLowerCase());
    +  }
    +
    +  public Collection<DrillFuncHolder> getAllMethods() {
    +    return 
Collections.unmodifiableCollection(registeredFunctions.values());
       }
     
       public void register(DrillOperatorTable operatorTable) {
    -    SqlOperator op;
    -    for (Entry<String, Collection<DrillFuncHolder>> function : 
methods.asMap().entrySet()) {
    -      Set<Integer> argCounts = Sets.newHashSet();
    -      String name = function.getKey().toUpperCase();
    +    for (Entry<String, Collection<DrillFuncHolder>> function : 
registeredFunctions.asMap().entrySet()) {
    +      final ArrayListMultimap<Integer, DrillFuncHolder> functions = 
ArrayListMultimap.create();
    +      final ArrayListMultimap<Integer, DrillFuncHolder> aggregateFunctions 
= ArrayListMultimap.create();
    +      final String name = function.getKey().toUpperCase();
    +      boolean isDeterministic = false;
           for (DrillFuncHolder func : function.getValue()) {
    -        if (argCounts.add(func.getParamCount())) {
    -          if (func.isAggregating()) {
    -            op = new DrillSqlAggOperator(name, func.getParamCount());
    -          } else {
    -            boolean isDeterministic;
    -            // prevent Drill from folding constant functions with types 
that cannot be materialized
    -            // into literals
    -            if 
(DrillConstExecutor.NON_REDUCIBLE_TYPES.contains(func.getReturnType().getMinorType()))
 {
    -              isDeterministic = false;
    -            } else {
    -              isDeterministic = func.isDeterministic();
    -            }
    -            op = new DrillSqlOperator(name, func.getParamCount(), 
func.getReturnType(), isDeterministic);
    -          }
    -          operatorTable.add(function.getKey(), op);
    +        final int paramCount = func.getFunctionArgumentNumber() == 
FunctionArgumentNumber.VARIABLE ? -1 : func.getParamCount();
    +        if(func.isAggregating()) {
    +          aggregateFunctions.put(paramCount, func);
    +        } else {
    +          functions.put(paramCount, func);
    +        }
    +        // prevent Drill from folding constant functions with types that 
cannot be materialized
    +        // into literals
    +        if 
(DrillConstExecutor.NON_REDUCIBLE_TYPES.contains(func.getReturnType().getMinorType()))
 {
    +          isDeterministic = false;
    --- End diff --
    
    Addressed in the new patch. Moreover, I will add the following comment into 
the code.
    
    In order to prevent Drill from folding constant functions with types that 
cannot be materialized
    into literals, the deterministic property of the DrillSqlOperator which has 
functions with the NON_REDUCIBLE_TYPES will be set to false.
    
    However,  partition-pruning will be initiated "only" for the deterministic 
DrillSqlOperator. Thus, an additional logic is added to PruneScanRule to help 
decide if partition-pruning can be taken.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to