flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-8323) Fix Mod scala function bug
Date Wed, 03 Jan 2018 12:25:01 GMT

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

ASF GitHub Bot commented on FLINK-8323:
---------------------------------------

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

    https://github.com/apache/flink/pull/5212#discussion_r159413615
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/ScalarOperators.scala
---
    @@ -47,9 +47,22 @@ object ScalarOperators {
           nullCheck: Boolean,
           resultType: TypeInformation[_],
           left: GeneratedExpression,
    -      right: GeneratedExpression)
    -    : GeneratedExpression = {
    -    val leftCasting = numericCasting(left.resultType, resultType)
    +      right: GeneratedExpression): GeneratedExpression = {
    +
    +    val leftCasting = operator match {
    +      case "%" =>
    +        if (left.resultType == right.resultType) {
    +          numericCasting(left.resultType, resultType)
    +        } else {
    +          val castedType = if (isDecimal(left.resultType)) {
    +            Types.LONG
    --- End diff --
    
    `BigDecimal. remainder` accept a `BigDecimal` ` divisor` and return a `BigDecimal` result.
when `right operand` is INTEGER and `left operand` is DECIMAL´╝î`%` should return INTEGER.
So may be using `BigDecimal. remainder` is not suitable. what do you think?



> Fix Mod scala function bug
> --------------------------
>
>                 Key: FLINK-8323
>                 URL: https://issues.apache.org/jira/browse/FLINK-8323
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API & SQL
>    Affects Versions: 1.5.0
>            Reporter: sunjincheng
>            Assignee: sunjincheng
>
> As we know mod(1514356320000,60000)=0, but currently  we get `-15488` when call `MOD(1514356320000,60000)`.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message