Hi Vincent, Jim is correct, we to be able to handle invocations with those types: The 1st arg can be any type. The 2nd and 3rd types must be compatible. During function resolution the FE will pick the most appropriate signature and add casts to the 2nd or 3rd arg as necessary. You do not need to create signatures like "nvl2(string, int, timestamp)".
I have considered the following options for addressing this difficulty: 1. Accept an AnyType for the 1st argument and create 9 function signatures. The FE current does not have such a concept. Adding it would involve changing many tricky places. 2. Rewrite NVL2() as an IF in the FE using the ExprRewriteRule framework. You will need to make changes to FunctionCallExpr to accept NVL2(). 3. Stamp out all 9*9 function signatures. Should be easy since you are in Python code there. Option 3 seems easiest/preferable to me at this point. Alex On Mon, May 15, 2017 at 1:05 PM, Jim Apple <[email protected]> wrote: > It seems to me like there should be version with type X, [P,X,X] for > all pair P and X. There might be a smart way to do this without the > quadratic number of cases; someone else probably knows better than I > do about that. > > On Sun, May 14, 2017 at 1:00 AM, Vincent Tran <[email protected]> wrote: > > Hey folks, > > > > I want to start contributing to learn the code base. I added this > function > > to my personal build: > > > > [['nvl2'], 'TINYINT', ['TINYINT', 'TINYINT', 'TINYINT'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'SMALLINT', ['SMALLINT', 'SMALLINT', 'SMALLINT'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'INT', ['INT', 'INT', 'INT'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'BIGINT', ['BIGINT', 'BIGINT', 'BIGINT'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'FLOAT', ['FLOAT', 'FLOAT', 'FLOAT'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'DOUBLE', ['DOUBLE', 'DOUBLE', 'DOUBLE'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'DECIMAL', ['DECIMAL', 'DECIMAL', 'DECIMAL'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'STRING', ['STRING', 'STRING', 'STRING'], > > 'impala::ConditionalFunctions::NVL2'], > > [['nvl2'], 'TIMESTAMP', ['TIMESTAMP', 'TIMESTAMP', 'TIMESTAMP'], > > 'impala::ConditionalFunctions::NVL2'], > > > > > > Do you think this is a sound approach? Should we allow mix types for this > > function? > > > > i.e. nvl2(string, int, timestamp) > > > > > > https://issues.cloudera.org/browse/IMPALA-5030 > > > > > > -- > > Vincent T. Tran > > Customer Operations Engineer > > Cloudera, Inc. >
