[
https://issues.apache.org/jira/browse/FLINK-19443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17204541#comment-17204541
]
Nicholas Jiang commented on FLINK-19443:
----------------------------------------
[~libenchao] [~mytang0], could you please provide the SQL case that could cause
the NPE problem? You could check the testSplitIndex() in ScalarFunctionsTest.
IMO, the case cause the NPE problem is that the parameter 'str' is null, but
there is no this case in current behaviour.
> runtime function 'splitIndex'
> -----------------------------
>
> Key: FLINK-19443
> URL: https://issues.apache.org/jira/browse/FLINK-19443
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Runtime
> Reporter: mytang0
> Priority: Minor
>
> runtime function 'splitIndex' has NPE problem (located in the
> SqlFunctionUtils class)
>
> *NPE version:*
> public static String splitIndex(String str, String separator, int index) {
> if (index < 0) {
> return null;
> }
> String[] values = StringUtils.splitByWholeSeparatorPreserveAllTokens(str,
> separator);
> if (index >= values.length) {
> return null;
> } else {
> return values[index];
> }
> }
> public static String splitIndex(String str, int character, int index) {
> if (character > 255 || character < 1 || index < 0) {
> return null;
> }
> String[] values = StringUtils.splitPreserveAllTokens(str, (char)
> character);
> if (index >= values.length) {
> return null;
> } else {
> return values[index];
> }
> }
>
> *Fix version:*
> public static String splitIndex(String str, String separator, int index) {
> if (index < 0) {
> return null;
> }
> String[] values = StringUtils.splitByWholeSeparatorPreserveAllTokens(str,
> separator);
> if ({color:#FF0000}values == null ||{color} index >= values.length) {
> return null;
> } else {
> return values[index];
> }
> }
> public static String splitIndex(String str, int character, int index) {
> if (character > 255 || character < 1 || index < 0) {
> return null;
> }
> String[] values = StringUtils.splitPreserveAllTokens(str, (char)
> character);
> if ({color:#FF0000}values == null ||{color} index >= values.length) {
> return null;
> } else {
> return values[index];
> }
> }
--
This message was sent by Atlassian Jira
(v8.3.4#803005)