[ https://issues.apache.org/jira/browse/FLINK-7923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16342028#comment-16342028 ]
ASF GitHub Bot commented on FLINK-7923: --------------------------------------- Github user hequn8128 commented on a diff in the pull request: https://github.com/apache/flink/pull/5367#discussion_r164266897 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/calls/ScalarOperators.scala --- @@ -984,6 +987,63 @@ object ScalarOperators { } } + def generateDot(codeGenerator: CodeGenerator, + dot: RexCall, + record: GeneratedExpression, + subField: GeneratedExpression) + : GeneratedExpression = { + val nullTerm = newName("isNull") + val resultTerm = newName("result") + val resultType = FlinkTypeFactory.toTypeInfo(dot.getType) + val resultTypeTerm = boxedTypeTermForTypeInfo(resultType) + dot.operands.get(0).getType match { + case crdt: CompositeRelDataType => { + val fieldName = dot.operands.get(1).asInstanceOf[RexLiteral] + .getValue.asInstanceOf[NlsString].getValue + if (crdt.compositeType.isInstanceOf[TupleTypeInfo[_]]) { + return GeneratedExpression(resultTerm, nullTerm, + s""" + |${record.code} + |${subField.code} + |${resultTypeTerm} $resultTerm = + | (${resultTypeTerm}) ${record.resultTerm}.productElement( --- End diff -- NPE will be thrown if ${record.resultTerm} is null > SQL parser exception when accessing subfields of a Composite element in an > Object Array type column > --------------------------------------------------------------------------------------------------- > > Key: FLINK-7923 > URL: https://issues.apache.org/jira/browse/FLINK-7923 > Project: Flink > Issue Type: Bug > Components: Table API & SQL > Affects Versions: 1.4.0 > Reporter: Rong Rong > Assignee: Shuyi Chen > Priority: Major > > Access type such as: > {code:SQL} > SELECT > a[1].f0 > FROM > MyTable > {code} > will cause problem. > See following test sample for more details: > https://github.com/walterddr/flink/commit/03c93bcb0fb30bd2d327e35b5e244322d449b06a -- This message was sent by Atlassian JIRA (v7.6.3#76005)