fhueske commented on a change in pull request #6606: [FLINK-10163] [sql-client] Support views in SQL Client URL: https://github.com/apache/flink/pull/6606#discussion_r212609696
########## File path: docs/dev/table/sqlClient.md ########## @@ -459,6 +466,50 @@ Web interface: http://localhost:8081 {% top %} +SQL Views +--------- + +Views allow to define virtual tables from SQL queries. The view definition is parsed and validated immediately. However, the actual execution happens when the view is accessed during the submission of a general `INSERT INTO` or `SELECT` statement. + +Views can either be defined in [environment files](sqlClient.html#environment-files) or within the CLI session. + +The following example shows how to define multiple views in a file: + +{% highlight yaml %} +views: + - name: MyRestrictedView + query: "SELECT MyField2 FROM MyTableSource" + - name: MyComplexView + query: > + SELECT MyField2 + 42, CAST(MyField1 AS VARCHAR) + FROM MyTableSource + WHERE MyField2 > 200 +{% endhighlight %} + +Similar to table sources and sinks, views defined in a session environment file have highest precendence. + +Views can also be created within a CLI session using the `CREATE VIEW` statement: + +{% highlight text %} +CREATE VIEW MyNewView AS SELECT MyField2 FROM MyTableSource +{% endhighlight %} + +The `SHOW VIEW` statement allows for printing a previously created view again: + +{% highlight text %} +SHOW VIEW MyNewView +{% endhighlight %} + +Views created within a CLI session can also be removed again using the `DROP VIEW` statement: + +{% highlight text %} +DROP VIEW MyNewView +{% endhighlight %} + +<span class="label label-danger">Attention</span> The definition of views is limited to the mentioned semantics above. Defining a schema for views or escape whitespaces in table names will be supported in future versions. Review comment: semantics -> syntax ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
