[ 
https://issues.apache.org/jira/browse/FLINK-14030?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Leonard Xu updated FLINK-14030:
-------------------------------
    Description: 
*testAllApis()* unit tests will run fail because planner make a conversion
from [*ifThenElse(isNull(plus(f0, f1)), 'null', 'not null')*]
to [*CASE(OR(IS NULL($0), IS NULL($1)), _UTF-16LE'null', _UTF-16LE'not null')*]
 which is not a equivalence conversion. The result of expression 'f0 + 'f1 
should be null
 when the result overflows even if its two operands both are not null.

It's easy to reproduce as following:
testAllApis(
 'f0 + 'f1,
 "f1 + f1",
 "f1 + f1",
 "null")// the result should be null because overflow

override def testData: Row =

{ val testData = new Row(2) testData.setField(0, BigDecimal("1e10").bigDecimal) 
testData.setField(1, BigDecimal("0").bigDecimal) testData }

override def typeInfo: RowTypeInfo =

{ new RowTypeInfo( /* 0 */ fromLogicalTypeToTypeInfo(DECIMAL(38, 10)), /* 1 */ 
fromLogicalTypeToTypeInfo(DECIMAL(38, 28)) ) }

 

  was:
{code:java}
testAllApis() {code}
unit tests will run fail because planner make a conversion
 from ~[ifThenElse(isNull(plus(f0, f1)), 'null', 'not null')]~
 to ~[CASE(OR(IS NULL($0), IS NULL($1)), _UTF-16LE'null', _UTF-16LE'not null')]~
 which is not a equivalence conversion. The result of expression 'f0 + 'f1 
should be null
 when the result overflows even if its two operands both are not null.

It's easy to reproduce as following:
{code:java}
testAllApis(
 'f0 + 'f1,
 "f1 + f1",
 "f1 + f1",
 "null")// the result should be null because overflow
override def testData: Row =
{ val testData = new Row(2) testData.setField(0, BigDecimal("1e10").bigDecimal) 
testData.setField(1, BigDecimal("0").bigDecimal) testData }
override def typeInfo: RowTypeInfo =
{ new RowTypeInfo( /* 0 */ fromLogicalTypeToTypeInfo(DECIMAL(38, 10)), /* 1 */ 
fromLogicalTypeToTypeInfo(DECIMAL(38, 28)) ) }
{code}
 

 


> Nonequivalent conversion happens in Table planner 
> --------------------------------------------------
>
>                 Key: FLINK-14030
>                 URL: https://issues.apache.org/jira/browse/FLINK-14030
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>    Affects Versions: 1.9.0
>            Reporter: Leonard Xu
>            Priority: Major
>             Fix For: 2.0.0
>
>
> *testAllApis()* unit tests will run fail because planner make a conversion
> from [*ifThenElse(isNull(plus(f0, f1)), 'null', 'not null')*]
> to [*CASE(OR(IS NULL($0), IS NULL($1)), _UTF-16LE'null', _UTF-16LE'not 
> null')*]
>  which is not a equivalence conversion. The result of expression 'f0 + 'f1 
> should be null
>  when the result overflows even if its two operands both are not null.
> It's easy to reproduce as following:
> testAllApis(
>  'f0 + 'f1,
>  "f1 + f1",
>  "f1 + f1",
>  "null")// the result should be null because overflow
> override def testData: Row =
> { val testData = new Row(2) testData.setField(0, 
> BigDecimal("1e10").bigDecimal) testData.setField(1, 
> BigDecimal("0").bigDecimal) testData }
> override def typeInfo: RowTypeInfo =
> { new RowTypeInfo( /* 0 */ fromLogicalTypeToTypeInfo(DECIMAL(38, 10)), /* 1 
> */ fromLogicalTypeToTypeInfo(DECIMAL(38, 28)) ) }
>  



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to