[jira] [Created] (FLINK-18437) Table API has no Functions like sparkSQL explode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (FLINK-18437) Table API has no Functions like sparkSQL explode

Shang Yuanchun (Jira)
mzz created FLINK-18437:
---------------------------

             Summary: Table API has no Functions like  sparkSQL explode
                 Key: FLINK-18437
                 URL: https://issues.apache.org/jira/browse/FLINK-18437
             Project: Flink
          Issue Type: Bug
          Components: API / DataStream
    Affects Versions: 1.9.3
            Reporter: mzz


 .withSchema(new Schema()
        .field("ip", Types.STRING())
        .field("ts", Types.STRING())
        .field("environment", Types.ROW(Array("access", "brand"), Array[TypeInformation[_]](Types.STRING(), Types.STRING)))
        .field("advs", ObjectArrayTypeInfo.getInfoFor(new Array[Row](0).getClass, Types.ROW(Array("count", "eventid"), Array[TypeInformation[_]](Types.STRING(), Types.STRING))))
      )
      .inAppendMode()
      .registerTableSource("aggs_test")



The code above is dataSchema,i tried this way  [https://ci.apache.org/projects/flink/flink-docs-release-1.10/dev/table/sql/queries.html|http://example.com],but  when i execute this sql:
val sql1 =
      """
        |SELECT
        |ip,
        |ts,
        |environment,
        |adv
        |FROM aggs_test
        |CROSS JOIN UNNEST(advs) AS t (adv)
        |""".stripMargin

It report an error:
Exception in thread "main" org.apache.flink.table.api.ValidationException: SQL validation failed. From line 8, column 31 to line 8, column 33: List of column aliases must have same degree as table; table has 2 columns ('access', 'brand'), whereas alias list has 1 columns
        at org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:128)
        at org.apache.flink.table.sqlexec.SqlToOperationConverter.convert(SqlToOperationConverter.java:83)
        at org.apache.flink.table.planner.StreamPlanner.parse(StreamPlanner.scala:115)
        at org.apache.flink.table.api.internal.TableEnvironmentImpl.sqlQuery(TableEnvironmentImpl.java:298)
        at QM.COM.Flink.KafakaHelper.FlinkTableConnKafka$.main(FlinkTableConnKafka.scala:88)
        at QM.COM.Flink.KafakaHelper.FlinkTableConnKafka.main(FlinkTableConnKafka.scala)
Caused by: org.apache.calcite.runtime.CalciteContextException: From line 8, column 31 to line 8, column 33: List of column aliases must have same degree as table; table has 2 columns ('access', 'brand'), whereas alias list has 1 columns
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
        at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
        at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4807)
        at org.apache.calcite.sql.validate.AliasNamespace.validateImpl(AliasNamespace.java:86)
        at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:997)
        at org.apache.calcite.sql.validate.AbstractNamespace.getRowType(AbstractNamespace.java:115)
        at org.apache.calcite.sql.validate.AliasNamespace.getRowType(AliasNamespace.java:41)
        at org.apache.calcite.sql.validate.DelegatingScope.resolveInNamespace(DelegatingScope.java:101)
        at org.apache.calcite.sql.validate.ListScope.resolve(ListScope.java:191)
        at org.apache.calcite.sql.validate.ListScope.findQualifyingTableNames(ListScope.java:156)
        at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:238)
        at org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:5699)
        at org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:5684)
        at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:317)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.expand(SqlValidatorImpl.java:5291)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateUnnest(SqlValidatorImpl.java:3126)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3108)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3093)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateJoin(SqlValidatorImpl.java:3158)
        at org.apache.flink.table.calcite.FlinkCalciteSqlValidator.validateJoin(FlinkCalciteSqlValidator.scala:67)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3102)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3365)
        at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
        at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:997)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:957)
        at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:932)
        at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:639)
        at org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:124)
        ... 5 more
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: List of column aliases must have same degree as table; table has 2 columns ('access', 'brand'), whereas alias list has 1 columns
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
        at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:572)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)