[ https://issues.apache.org/jira/browse/FLINK-19101?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
fa zheng updated FLINK-19101: ----------------------------- Description: For a SQL : {code:sql} select t1.a, t2.b from t1 join t2 on t1.b=t2.b and t1.b<'2' {code} It will throw java.lang.NullPointerException because SelectivityEstimator convert character value interval to string without considering null situation. {code:scala} def convertValueInterval( interval: ValueInterval, typeFamily: RelDataTypeFamily): ValueInterval = { require(interval != null && typeFamily != null) interval match { case ValueInterval.empty | ValueInterval.infinite => interval case _ => val (lower, includeLower) = interval match { case li: WithLower => (li.lower, li.includeLower) case _ => (null, false) } val (upper, includeUpper) = interval match { case ui: WithUpper => (ui.upper, ui.includeUpper) case _ => (null, false) } typeFamily match { case SqlTypeFamily.NUMERIC | SqlTypeFamily.BOOLEAN | SqlTypeFamily.DATE | SqlTypeFamily.TIME | SqlTypeFamily.TIMESTAMP => ValueInterval( comparableToDouble(lower), comparableToDouble(upper), includeLower, includeUpper) case SqlTypeFamily.CHARACTER => ValueInterval( lower.toString, //It can't call toString directly upper.toString //It can't call toString directly includeLower, includeUpper) case _ => throw new UnsupportedOperationException(s"Unsupported typeFamily: $typeFamily") } } } {code} was: For a SQL : {code:sql} select t1.a, t2.b from t1 join t2 on t1.b=t2.b and t1.b<'2' {code} It will throw java.lang.NullPointerException because SelectivityEstimator convert character value interval to string without considering null situation. {code:scala} def convertValueInterval( interval: ValueInterval, typeFamily: RelDataTypeFamily): ValueInterval = { require(interval != null && typeFamily != null) interval match { case ValueInterval.empty | ValueInterval.infinite => interval case _ => val (lower, includeLower) = interval match { case li: WithLower => (li.lower, li.includeLower) case _ => (null, false) } val (upper, includeUpper) = interval match { case ui: WithUpper => (ui.upper, ui.includeUpper) case _ => (null, false) } typeFamily match { case SqlTypeFamily.NUMERIC | SqlTypeFamily.BOOLEAN | SqlTypeFamily.DATE | SqlTypeFamily.TIME | SqlTypeFamily.TIMESTAMP => ValueInterval( comparableToDouble(lower), comparableToDouble(upper), includeLower, includeUpper) case SqlTypeFamily.CHARACTER => ValueInterval( {color:red} lower.toString, upper.toString,{color} includeLower, includeUpper) case _ => throw new UnsupportedOperationException(s"Unsupported typeFamily: $typeFamily") } } } {code} > The SelectivityEstimator throw an NullPointerException when > convertValueInterval with string type > ------------------------------------------------------------------------------------------------- > > Key: FLINK-19101 > URL: https://issues.apache.org/jira/browse/FLINK-19101 > Project: Flink > Issue Type: Bug > Components: Table SQL / Planner > Affects Versions: 1.10.2, 1.11.1 > Reporter: fa zheng > Priority: Critical > Fix For: 1.12.0 > > > For a SQL : > {code:sql} > select t1.a, t2.b from t1 join t2 on t1.b=t2.b and t1.b<'2' > {code} > It will throw java.lang.NullPointerException because SelectivityEstimator > convert character value interval to string without considering null > situation. > {code:scala} > def convertValueInterval( > interval: ValueInterval, > typeFamily: RelDataTypeFamily): ValueInterval = { > require(interval != null && typeFamily != null) > interval match { > case ValueInterval.empty | ValueInterval.infinite => interval > case _ => > val (lower, includeLower) = interval match { > case li: WithLower => (li.lower, li.includeLower) > case _ => (null, false) > } > val (upper, includeUpper) = interval match { > case ui: WithUpper => (ui.upper, ui.includeUpper) > case _ => (null, false) > } > typeFamily match { > case SqlTypeFamily.NUMERIC | SqlTypeFamily.BOOLEAN | > SqlTypeFamily.DATE | > SqlTypeFamily.TIME | SqlTypeFamily.TIMESTAMP => > ValueInterval( > comparableToDouble(lower), > comparableToDouble(upper), > includeLower, > includeUpper) > case SqlTypeFamily.CHARACTER => > ValueInterval( > lower.toString, //It can't call toString directly > upper.toString //It can't call toString directly > includeLower, > includeUpper) > case _ => throw new UnsupportedOperationException(s"Unsupported > typeFamily: $typeFamily") > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)