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

ASF subversion and git services commented on IMPALA-14904:
----------------------------------------------------------

Commit 89084c3bf893c1441ee5566085a68549ba55cd60 in impala's branch 
refs/heads/master from Steve Carlin
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=89084c3bf ]

IMPALA-15256: Calcite planner returning wrong results for floor, ceil

The floor and ceil functions were returning a wrong result for
negative values, e.g. floor(-5.2) was returning -5.

This was caused by a regression from IMPALA-14904, which cast the
operand for floor to match the return type. floor(-5.2) was being
treated as floor(cast(-5.2 as decimal(2,0)) which truncated the
decimal part.

This commit ensures that this will not happen for these functions.

The "ceil" keyword had to be treated as a ReservedFunctionName word in
Parser.jj

Also, the Parser.jj file changed to ensure that we do not use the default
Calcite operators to determine the precision.

The new ImpalaAdjustPrecisionFunction operator matches the logic
for floor and ceil that exists in FunctionCallExpr. Note that this
adds one to the precision of the return type. I'm not sure this is
necessary since a decimal like -9.9 already has a precision of 2 as
it gets changed to -10, but the logic now matches the original
planner.

The functions for ImpalaAdjustScaleFunction also ensure that the
param is not changed to be the same as the return type. I did a scan
through all the math functions and these are the only functions
where the return type for decimal does not need to match the param
type. The default logic is kept the same.

Tests: Added floor and ceil tests to both original and calcite planner.

Change-Id: I794cb181ebca59dae880eb96ae0f0570b5b9f8ed
Reviewed-on: http://gerrit.cloudera.org:8080/24690
Reviewed-by: Joe McDonnell <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>


> Calcite planner: Enable width_bucket function
> ---------------------------------------------
>
>                 Key: IMPALA-14904
>                 URL: https://issues.apache.org/jira/browse/IMPALA-14904
>             Project: IMPALA
>          Issue Type: Sub-task
>            Reporter: Steve Carlin
>            Assignee: Steve Carlin
>            Priority: Major
>             Fix For: Impala 5.0.0
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to