------------------ ???????? ------------------
??????: "????????????"<453673...@qq.com>;
????????: 2018??4??3??(??????) ????11:23
??????: "user"<user@flink.apache.org>;
????: "skycrab68"<skycra...@163.com>; 
????: subuquery about flink sql 



Deal All
      I have a question about subquery of flink sql.
      My sql like this:
      select 
        user,
        count(product),
        TUMBLE_START(t, INTERVAL '60' SECOND) as wStart,
        TUMBLE_END(t, INTERVAL '60' SECOND) as wEnd
    from (
        select 
            distinct(user),
            product,
            amount,
            actionTime
        from myFlinkTable
    ) GROUP BY user,TUMBLE(t, INTERVAL '60' SECOND) 


    The typeinfo of field like this:
    TypeInformation<Row> typeInfo = Types.ROW(
                new String[] {"user","product","amount","actionTime"},
                new TypeInformation<?>[] {
                        BasicTypeInfo.STRING_TYPE_INFO,
                        BasicTypeInfo.INT_TYPE_INFO,
                        BasicTypeInfo.INT_TYPE_INFO,
                        BasicTypeInfo.LONG_TYPE_INFO,
                }
        );


    My datasource implements DefinedRowtimeAttribute,as follows??
    @Override
    public String getRowtimeAttribute() {
        return "t";
    }


    I run the test code,and get the following error.
    Exception in thread "main" org.apache.flink.table.api.ValidationException: 
SQL validation failed. At line 13, column 24: Column 't' not found in any table
        at 
org.apache.flink.table.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:92)
        at 
org.apache.flink.table.api.TableEnvironment.sql(TableEnvironment.scala:499)
        at com.didi.flink.sql.Main.main(Main.java:103)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.apache.calcite.runtime.CalciteContextException: At line 13, 
column 24: Column 't' not found in any table
        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:804)
        at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:789)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4363)
        at 
org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:258)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:5018)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:5000)
        at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:344)
        at 
org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.visitChild(SqlShuttle.java:134)
        at 
org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.visitChild(SqlShuttle.java:101)
        at org.apache.calcite.sql.SqlOperator.acceptCall(SqlOperator.java:859)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visitScoped(SqlValidatorImpl.java:5053)
        at 
org.apache.calcite.sql.validate.SqlScopedShuttle.visit(SqlScopedShuttle.java:50)
        at 
org.apache.calcite.sql.validate.SqlScopedShuttle.visit(SqlScopedShuttle.java:33)
        at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expand(SqlValidatorImpl.java:4624)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateGroupClause(SqlValidatorImpl.java:3529)
        at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3172)
        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)
        ... 7 more
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Column 't' 
not found in any table
        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)
        ... 32 more
==========================================
How to solve this problem??



Best wishes

Thanks

Reply via email to