0

I was reading the Flink SQL docs and in the section on Create, I could not find anything that resembles CREATE VIEW AS SELECT nor CTAS.

I looked a bit further and found the following:

  • Flink SQL allows you to Select
  • Flink SQL allows you to Create
  • Flink SQL allows you to Insert

As such, it seems like Flink SQL would allow you to imitate the capabilities of Create as Select, but without the convenience of automatically grabbing the schema of the source table.

In addition, I found that:

  • Flink (outside SQL) allows you to assign the output of an SQL Select statement to a new table (and presumably a view)

For example:

Table result = tableEnv.sqlQuery("SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'");

Now my question:

(How) Does Flink allow you to Create as Select without leaving the SQL context

And based on the examples that I have seen this can likely be rephrased as:

Can you create as select inside an executeSql statement.

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122

1 Answers1

2

In Flink SQL, there exist the known CREATE VIEW AS SELECT since 1.11. In older versions, you'd need to resort to the table API as pointed out by you.

Arvid Heise
  • 3,524
  • 5
  • 11
  • Great! I started looking for tables and added view as an afterthought, but in fact for streaming that is probably what I should want to use anyway most of the time. – Dennis Jaheruddin Sep 01 '20 at 08:22