Hello,
I have been able to use queries with cte in this syntax –
INSERT INTO t1
      WITH cte1 AS (SELECT
                   ....),
                                 cte2 AS (SELECT
                   ....)
                               (SELECT
                  *
              FROM
                  cte1 AS a, cte2 as b .....
              );

Hope this helps you.

Regards,
Aniket Sule

From: elakiya udhayanan <laks....@gmail.com>
Sent: Thursday, October 19, 2023 3:04 AM
To: user@flink.apache.org
Subject: Flink SQL exception on using cte

CAUTION:External email. Do not click or open attachments unless you know and 
trust the sender.

Hi Team,

I have a Flink job which uses the upsert-kafka connector to consume the events 
from two different Kafka topics (confluent avro serialized) and write them to 
two different tables (in Flink's memory using the Flink's SQL DDL statements).

I want to correlate them using the SQL join statements and for this I am trying 
to use the cte expressions like below (sample): But getting  exception as below

 org.apache.flink.table.api.SqlParserException: SQL parse failed. Incorrect 
syntax near the keyword 'INSERT'


WITH p1 AS ( SELECT empId FROM employee )

 FROM p1

INSERT INTO correlate

SELECT pod;
Please let me know if queries with cte are supported in Apache Flink.

Thanks,
Elakiya
Caution: External email. Do not click or open attachments unless you know and 
trust the sender.

Reply via email to