You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Dawid Wysakowicz (JIRA)" <ji...@apache.org> on 2016/03/08 14:12:40 UTC

[jira] [Comment Edited] (FLINK-3574) Implement math functions for Table API

    [ https://issues.apache.org/jira/browse/FLINK-3574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15184889#comment-15184889 ] 

Dawid Wysakowicz edited comment on FLINK-3574 at 3/8/16 1:11 PM:
-----------------------------------------------------------------

I thought about a logic as described by you in {{getCallGenerator}}, but right know we can't specify signature with NUMERIC type cause {{NumericTypeInfo}} is an abstract class thus it cannot be instantiated. To give an example I would like to write sth like, which unfortunately is impossible:

{code}
  addSqlFunctionMethod(
    LOG10,
    Seq(NUMERIC_TYPE_INFO),
    DOUBLE_TYPE_INFO,
    BuiltInMethod.Log10.method)
{code}

Regarding the two ways of processing I meant sth different. Have a look at those two code snippets:  

RexNodeTranslator:
{code}
      case UnaryMinus(child) =>
        val c = toRexNode(child, relBuilder)
        relBuilder.call(SqlStdOperatorTable.UNARY_MINUS, c)

      // Scalar functions
      case Call(name, args@_*) =>
        val rexArgs = args.map(toRexNode(_, relBuilder))
        val sqlOperator = toSqlOperator(name)
        relBuilder.call(sqlOperator, rexArgs)
{code}

CodeGenerator:
{code}
      case OR =>
        operands.reduceLeft { (left: GeneratedExpression, right: GeneratedExpression) =>
          requireBoolean(left)
          requireBoolean(right)
          generateOr(nullCheck, left, right)
        }

      case call: SqlOperator =>
        val callGen = ScalarFunctions.getCallGenerator(call, operands.map(_.resultType))
        callGen
          .getOrElse(throw new CodeGenException(s"Unsupported call: $call"))
          .generate(this, operands)
{code}

In both snippets UnaryMinus and OR could be expressed in the case call block using appropriate CallGenerator. My question is should we replace whole match block with the invocation to {{getCallGenerator}}


was (Author: dawidwys):
I thought about a logic as described by you in {{getCallGenerator}}, but right know we can't specify signature with NUMERIC type cause {{NumericTypeInfo}} is an abstract class thus it cannot be instantiated.

Regarding the two ways of processing I meant sth different. Have a look at those two code snippets:  

RexNodeTranslator:
{code}
      case UnaryMinus(child) =>
        val c = toRexNode(child, relBuilder)
        relBuilder.call(SqlStdOperatorTable.UNARY_MINUS, c)

      // Scalar functions
      case Call(name, args@_*) =>
        val rexArgs = args.map(toRexNode(_, relBuilder))
        val sqlOperator = toSqlOperator(name)
        relBuilder.call(sqlOperator, rexArgs)
{code}

CodeGenerator:
{code}
      case OR =>
        operands.reduceLeft { (left: GeneratedExpression, right: GeneratedExpression) =>
          requireBoolean(left)
          requireBoolean(right)
          generateOr(nullCheck, left, right)
        }

      case call: SqlOperator =>
        val callGen = ScalarFunctions.getCallGenerator(call, operands.map(_.resultType))
        callGen
          .getOrElse(throw new CodeGenException(s"Unsupported call: $call"))
          .generate(this, operands)
{code}

In both snippets UnaryMinus and OR could be expressed in the case call block using appropriate CallGenerator. My question is should we replace whole match block with the invocation to {{getCallGenerator}}

> Implement math functions for Table API
> --------------------------------------
>
>                 Key: FLINK-3574
>                 URL: https://issues.apache.org/jira/browse/FLINK-3574
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API
>            Reporter: Timo Walther
>            Assignee: Dawid Wysakowicz
>
> {code}
> MOD
> EXP
> POWER
> LN
> LOG10
> ABS
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)