wuchong commented on a change in pull request #16245: URL: https://github.com/apache/flink/pull/16245#discussion_r658452346
########## File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/config/SqlClientOptions.java ########## @@ -53,4 +55,16 @@ private SqlClientOptions() {} .defaultValue(false) .withDescription( "Determine whether to output the verbose output to the console. If set the option true, it will print the exception stack. Otherwise, it only output the cause."); + + // Display options + + @Documentation.TableOption(execMode = Documentation.ExecMode.BATCH_STREAMING) + public static final ConfigOption<Integer> DISPLAY_MAX_COLUMN_WIDTH = + ConfigOptions.key("sql-client.display.max_column_width") Review comment: Would be better to use `sql-client.display.max-column-width`, Flink configuration doesn't use `_` as separator. ########## File path: flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/gateway/ResultDescriptor.java ########## @@ -29,21 +35,17 @@ private final boolean isMaterialized; - private final boolean isTableauMode; - - private final boolean isStreamingMode; + public final ReadableConfig config; Review comment: We can add a `public int getMaxColumnWidth()` method just like `isStreamingMode`, so that we don't need to expose the whole `config`. And users don't need to remember the config name when using, e.g. `resultDescriptor.config.get(DISPLAY_MAX_COLUMN_WIDTH)`. ########## File path: docs/content/docs/dev/table/sqlClient.md ########## @@ -60,106 +59,72 @@ or explicitly use `embedded` mode: ./bin/sql-client.sh embedded ``` +See [SQL Client startup options](#sql-client-startup-options) below for more details. + ### Running SQL Queries -Once the CLI has been started, you can use the `HELP` command to list all available SQL statements. -For validating your setup and cluster connection, you can enter your first SQL query and press the `Enter` key to execute it: +For validating your setup and cluster connection, you can enter the simple query below and press `Enter` to execute it. ```sql -SELECT 'Hello World'; +SELECT + name, + COUNT(*) AS cnt +FROM + (VALUES ('Bob'), ('Alice'), ('Greg'), ('Bob')) AS NameTable(name) +GROUP BY name; ``` -This query requires no table source and produces a single row result. The CLI will retrieve results -from the cluster and visualize them. You can close the result view by pressing the `Q` key. - -The CLI supports **three modes** for maintaining and visualizing results. - -The **table mode** materializes results in memory and visualizes them in a regular, paginated table representation. -It can be enabled by executing the following command in the CLI: +The SQL client will retrieve the results from the cluster and visualize them (you can close the result view by pressing the `Q` key): ```text -SET 'sql-client.execution.result-mode' = 'table'; + name cnt + Alice 1 + Greg 1 + Bob 2 ``` -The **changelog mode** does not materialize results and visualizes the result stream that is produced -by a [continuous query]({{< ref "docs/dev/table/concepts/dynamic_tables" >}}#continuous-queries) consisting of insertions (`+`) and retractions (`-`). +The `SET` command allows you to tune the job execution and the sql client behaviour. See [SQL Client Configuration](#sql-client-configuration) below for more details. -```text -SET 'sql-client.execution.result-mode' = 'changelog'; -``` +After a query is defined, it can be submitted to the cluster as a long-running, detached Flink job. +The [configuration section](#configuration) explains how to declare table sources for reading data, how to declare table sinks for writing data, and how to configure other table program properties. -The **tableau mode** is more like a traditional way which will display the results in the screen directly with a tableau format. -The displaying content will be influenced by the query execution type(`execution.type`). -```text -SET 'sql-client.execution.result-mode' = 'tableau'; -``` - -Note that when you use this mode with streaming query, the result will be continuously printed on the console. If the input data of -this query is bounded, the job will terminate after Flink processed all input data, and the printing will also be stopped automatically. -Otherwise, if you want to terminate a running query, just type `CTRL-C` in this case, the job and the printing will be stopped. +### Getting help -You can use the following query to see all the result modes in action: - -```sql -SELECT name, COUNT(*) AS cnt FROM (VALUES ('Bob'), ('Alice'), ('Greg'), ('Bob')) AS NameTable(name) GROUP BY name; -``` - -This query performs a bounded word count example. - -In *changelog mode*, the visualized changelog should be similar to: +The documentation of the SQL client commands can be accessed as follows: Review comment: Actually, it's not easy to maintain the HELP list (it's not complete too), would be better to just add a link to SQL page `dev/table/sql/overview/` where shows all supported statements. ########## File path: docs/content/docs/dev/table/sqlClient.md ########## @@ -60,106 +59,72 @@ or explicitly use `embedded` mode: ./bin/sql-client.sh embedded ``` +See [SQL Client startup options](#sql-client-startup-options) below for more details. + ### Running SQL Queries -Once the CLI has been started, you can use the `HELP` command to list all available SQL statements. -For validating your setup and cluster connection, you can enter your first SQL query and press the `Enter` key to execute it: +For validating your setup and cluster connection, you can enter the simple query below and press `Enter` to execute it. ```sql -SELECT 'Hello World'; +SELECT + name, + COUNT(*) AS cnt +FROM + (VALUES ('Bob'), ('Alice'), ('Greg'), ('Bob')) AS NameTable(name) +GROUP BY name; ``` -This query requires no table source and produces a single row result. The CLI will retrieve results -from the cluster and visualize them. You can close the result view by pressing the `Q` key. - -The CLI supports **three modes** for maintaining and visualizing results. - -The **table mode** materializes results in memory and visualizes them in a regular, paginated table representation. -It can be enabled by executing the following command in the CLI: +The SQL client will retrieve the results from the cluster and visualize them (you can close the result view by pressing the `Q` key): ```text -SET 'sql-client.execution.result-mode' = 'table'; + name cnt + Alice 1 + Greg 1 + Bob 2 Review comment: Could you show this display example using `tableau` mode which I think the community is tend to make it as default mode in the future. The `tableau` mode is also more readable than `table` mode. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org