[
https://issues.apache.org/jira/browse/FLINK-7923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16342033#comment-16342033
]
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_r164266900
--- 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(
+ | ${fieldName.substring(1).toInt} - 1);
+ |boolean $nullTerm =${resultTerm} == null;
+ |""".stripMargin, resultType)
+ } else if (crdt.compositeType.isInstanceOf[CaseClassTypeInfo[_]]) {
+ return GeneratedExpression(resultTerm, nullTerm,
+ s"""
+ |${record.code}
+ |${resultTypeTerm} $resultTerm =
+ | (${resultTypeTerm}) ${record.resultTerm}.${fieldName}();
+ |boolean $nullTerm =${resultTerm} == null;
+ |""".stripMargin, resultType)
+ } else if (crdt.compositeType.isInstanceOf[PojoTypeInfo[_]]) {
+ return GeneratedExpression(resultTerm, nullTerm,
+ s"""
+ |${record.code}
+ |${resultTypeTerm} $resultTerm =
+ | (${resultTypeTerm}) ${record.resultTerm}.${fieldName};
--- End diff --
NPE will be thrown
> 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)