flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "godfrey he (Jira)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-15381) INSERT INTO VALUES statement fails if a cast project is applied
Date Thu, 02 Jan 2020 02:56:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-15381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17006544#comment-17006544
] 

godfrey he commented on FLINK-15381:
------------------------------------

The collection trait is generated when creating {{LogicalProject }} in {{SqlToRelConverter}}.
code is 
{code:java LogicalProject.java}
  public static LogicalProject create(final RelNode input,
      final List<? extends RexNode> projects, RelDataType rowType) {
    final RelOptCluster cluster = input.getCluster();
    final RelMetadataQuery mq = cluster.getMetadataQuery();
    final RelTraitSet traitSet =
        cluster.traitSet().replace(Convention.NONE)
            .replaceIfs(RelCollationTraitDef.INSTANCE,
                () -> RelMdCollation.project(mq, input, projects));
    return new LogicalProject(cluster, traitSet, input, projects, rowType);
  }
{code}


> INSERT INTO VALUES statement fails if a cast project is applied
> ---------------------------------------------------------------
>
>                 Key: FLINK-15381
>                 URL: https://issues.apache.org/jira/browse/FLINK-15381
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Planner
>            Reporter: Jark Wu
>            Assignee: godfrey he
>            Priority: Blocker
>              Labels: pull-request-available
>             Fix For: 1.10.0
>
>         Attachments: image-2019-12-26-14-56-00-634.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The following query will fail:
> {code:scala}
>   @Test
>   def test(): Unit = {
>     val sinkDDL =
>       """
>         |create table t2(
>         |  a int,
>         |  b string
>         |) with (
>         |  'connector' = 'COLLECTION'
>         |)
>       """.stripMargin
>     val query =
>       """
>         |insert into t2 select cast(a as int), cast(b as varchar) from (values (3, 'c'))
T(a,b)
>       """.stripMargin
>     tableEnv.sqlUpdate(sinkDDL)
>     tableEnv.sqlUpdate(query)
>     execJob("testJob")
>   }
> {code}
> exception:
> {code}
> org.apache.flink.table.api.TableException: Cannot generate a valid execution plan for
the given query: 
> LogicalSink(name=[`default_catalog`.`default_database`.`t2`], fields=[a, b])
> +- LogicalProject(EXPR$0=[$0], EXPR$1=[CAST($1):VARCHAR(2147483647) CHARACTER SET "UTF-16LE"
NOT NULL])
>    +- LogicalValues(type=[RecordType(INTEGER a, CHAR(1) b)], tuples=[[{ 3, _UTF-16LE'c'
}]])
> This exception indicates that the query uses an unsupported SQL feature.
> Please check the documentation for the set of currently supported SQL features.
> {code}



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

Mime
View raw message