[
https://issues.apache.org/jira/browse/FLINK-35935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17870075#comment-17870075
]
xuyang commented on FLINK-35935:
--------------------------------
Hi, [~xccui]. Can you provide more details about this bug? I tried to reproduce
it in CalcTest with the following test, but it unexpectedly worked fine:
{code:java}
// add it in org.apache.flink.table.planner.plan.stream.sql#CalcTest
@Test
def test1(): Unit = {
util.tableEnv.executeSql(
"CREATE TABLE MySink WITH ('connector' = 'values') AS (SELECT * FROM
MyTable limit 5)")
}
// the optimizedRelNodes in PlannerBase#translate by debugging
StreamPhysicalSink(table=[default_catalog.default_database.MySink], fields=[a,
b, c])
StreamPhysicalLimit(offset=[0], fetch=[5])
StreamPhysicalExchange(distribution=[single])
StreamPhysicalLegacyTableSourceScan(table=[[default_catalog,
default_database, MyTable, source: [TestTableSource(a, b, c)]]], fields=[a, b,
c])
{code}
> CREATE TABLE AS doesn't work with LIMIT
> ---------------------------------------
>
> Key: FLINK-35935
> URL: https://issues.apache.org/jira/browse/FLINK-35935
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 1.18.1
> Reporter: Xingcan Cui
> Priority: Major
>
> {code:java}
> CREATE TABLE WITH (foo) AS (SELECT * FROM bar LIMIT 5){code}
> The above statement throws "Caused by: java.lang.AssertionError: not a query:
> " exception.
> A workaround is to wrap the query with CTE.
> {code:java}
> CREATE TABLE WITH (foo) AS (WITH R AS (SELECT * FROM bar LIMIT 5) SELECT *
> FROM R){code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)