clintropolis commented on a change in pull request #10370:
URL: https://github.com/apache/druid/pull/10370#discussion_r486634787



##########
File path: core/src/main/java/org/apache/druid/math/expr/ApplyFunction.java
##########
@@ -848,4 +882,32 @@ public CartesianFoldLambdaBinding accumulateWithIndex(int 
index, Object acc)
       return this;
     }
   }
+
+  class LambdaInputBindingTypes implements Expr.InputBindingTypes
+  {
+    private final Object2IntMap<String> lambdaIdentifiers;
+    private final Expr.InputBindingTypes inputTypes;
+    private final List<Expr> args;
+
+    public LambdaInputBindingTypes(Expr.InputBindingTypes inputTypes, 
LambdaExpr expr, List<Expr> args)
+    {
+      this.inputTypes = inputTypes;
+      this.args = args;
+      List<String> identifiers = expr.getIdentifiers();
+      this.lambdaIdentifiers = new Object2IntOpenHashMap<>(args.size());
+      for (int i = 0; i < args.size(); i++) {
+        lambdaIdentifiers.put(identifiers.get(i), i);
+      }
+    }
+
+    @Nullable
+    @Override
+    public ExprType getType(String name)
+    {
+      if (lambdaIdentifiers.containsKey(name)) {
+        return 
ExprType.elementType(args.get(lambdaIdentifiers.getInt(name)).getOutputType(inputTypes));

Review comment:
       It shouldn't be called in any sort of hot loop. The eventual usage of 
this information is so that this happens during a sort of planning phase that 
is checking to see if it we can make a strongly typed and optimized expression 
evaluator to use instead of the default.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to