Hi,

thanks for writing on the mailling list. I could reproduce your error and opened an issue for it (https://issues.apache.org/jira/browse/FLINK-8107). UNNEST currently only supports unnesting and joining an array of the same relation. However joining of two relations will be supported soon (window joins in 1.4 and full joins in 1.5). I don't know your exact use case maybe you can explain a bit more what you want to do? Otherwise it might be worth looking into user-defined table functions because they can also be quite useful to unroll arrays.

https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/table/udfs.html#table-functions

I hope that helps.

Regards,
Timo


Am 11/19/17 um 6:59 PM schrieb Lothium:
Hey,
I need some help regarding the sql and table api. I'm using Apache Flink
1.3.2 with scala 2.11.11 (also tried 2.11.8) and I created a DataStream
(based on a scala case class) and I registered this as a table. The case
class includes some Lists, because the underlying JSON has some Arrays in
the schema. I had a look at the SQL API documentation and there is an
example with the CROSS JOIN and UNNEST function, so I tried the following
example SQL query:
"SELECT t.item.* FROM product, UNNEST(entity.items) AS t (item)".

When I run the stream I get the following error:
"Exception in thread "main" java.lang.AssertionError: Cycle detected during
type-checking
        at
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:93)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:931)
        at
org.apache.calcite.sql.validate.AbstractNamespace.getRowType(AbstractNamespace.java:115)
        at
org.apache.calcite.sql.validate.AbstractNamespace.getRowTypeSansSystemColumns(AbstractNamespace.java:122)
        at
org.apache.calcite.sql.validate.AliasNamespace.validateImpl(AliasNamespace.java:71)
        at
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:931)
        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:325)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateIdentifier(SqlValidatorImpl.java:2765)
        at
org.apache.calcite.sql.SqlIdentifier.validateExpr(SqlIdentifier.java:324)
        at org.apache.calcite.sql.SqlOperator.validateCall(SqlOperator.java:407)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateCall(SqlValidatorImpl.java:4603)
        at
org.apache.calcite.sql.validate.UnnestNamespace.validateImpl(UnnestNamespace.java:52)
        at
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:931)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:912)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2941)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2926)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateJoin(SqlValidatorImpl.java:2963)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2935)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3168)
        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:931)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:912)
        at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:220)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:887)
        at
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:597)
        at
org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:88)
        at
org.apache.flink.table.api.TableEnvironment.sql(TableEnvironment.scala:499)
...."

Do you have any idea about this? The stream works when I do a simple select
without doing the unnest etc.. Is there also a way to do the unnest via the
Table API? I haven't found an example or an operator for this.

Thanks in advance!



--
Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/


Reply via email to