You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/28 18:36:03 UTC

[GitHub] [pinot] walterddr opened a new issue, #8610: [Feature] Support dynamic return type in function such as CAST

walterddr opened a new issue, #8610:
URL: https://github.com/apache/pinot/issues/8610

   Background
   ===
   Following #8597 to support argument-type-based function lookup, it is possible that argument types themselves is not sufficient to determine the result type, for example `CAST(intCol AS 'long')` and `CAST(intCol AS 'int')` will have the same argument types `int, string` but different return type `long` vs. `int`.
   
   
   Proposal
   ===
   Propose to allow annotation of `@ScalarFunction` to annotate classes which have various function/method name, signature, class will look like this 
   ```
   @ScalarFunction(name = 'cast')
   public class CastFunction implements FunctionDefinition {
   
     @Override
     public Method getMethod(Collection<DataType> argumentType, Collection<Literal> literalArguments) {
       // ... 
     }
   
     // actual function methods:
     public int castToInt(Object o, String literalCastType) { // ... }
     public long castToLong(Object o , String literalCastType) { // ... }
   }
   ```
   Similar architecture is adopted in many sql-like systems to support UDF/UDAF/UDTF etc. thus I think the design should be sufficient. 
   
   
   Note
   ====
   * type inference is not discussed in this document
   * whether to use codegen or hand-written method is up for discussion.
   
   


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

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org