Monday, September 9, 2019

Snowflake: snowsql !options

Related links:

Show snowsqlcommand line options.

snowsql -q '!options'

+----------------------------+------------------------+--------------------------------------------------------------------------------------+
| Name                       | Value                  | Help                                                                                 |
|----------------------------+------------------------+--------------------------------------------------------------------------------------|
| auto_completion            | True                   | Displays auto-completion suggestions for commands and Snowflake objects              |
| client_session_keep_alive  | False                  | Keeps the session active indefinitely, even if there is no activity from the user.   |
| echo                       | False                  | Outputs the SQL command to the terminal when it is executed                          |
| editor                     | vim                    | Changes the editor to use for the !edit command                                      |
| empty_for_null_in_tsv      | False                  | Outputs an empty string for NULL values in TSV format                                |
| environment_variables      | []                     | Specifies the environment variables to be set in the SnowSQL variables.              |
|                            |                        | The variable names should be comma separated.                                        |
| execution_only             | False                  | Executes queries only. No data will be fetched                                       |
| exit_on_error              | False                  | Quits when SnowSQL encounters an error                                               |
| force_put_overwrite        | False                  | Force OVERWRITE=true for PUT. This is to mitigate S3's eventually consistent issue.  |
| friendly                   | False                  | Shows the splash text and goodbye messages                                           |
| header                     | True                   | Outputs the header in query results                                                  |
| insecure_mode              | False                  | Turns off OSCP certificate checks                                                    |
| key_bindings               | emacs                  | Changes keybindings for navigating the prompt to emacs or vi                         |
| log_bootstrap_file         | ~/.snowsql/log_boots.. | SnowSQL bootstrap log file location                                                  |
| log_file                   | ~/.snowsql/log         | SnowSQL main log file location                                                       |
| log_level                  | CRITICAL               | Changes the log level (critical, debug, info, error, warning)                        |
| login_timeout              | 120                    | Login timeout in seconds.                                                            |
| noup                       | False                  | Turns off auto upgrading Snowsql                                                     |
| ocsp_fail_open             | True                   | Sets the fail open mode for OCSP Failures. For help please refer the documentation.  |
| output_file                | None                   | Writes output to the specified file in addition to the terminal                      |
| output_format              | psql                   | Sets the output format for query results.                                            |
| paging                     | False                  | Enables paging to pause output per screen height.                                    |
| progress_bar               | True                   | Shows progress bar while transferring data.                                          |
| prompt_format              | [user]#[warehouse]@[.. | Sets the prompt format. For help, see the documentation                              |
| quiet                      | False                  | Hides all output                                                                     |
| remove_comments            | False                  | Removes comments before sending query to Snowflake                                   |
| remove_trailing_semicolons | False                  | Removes trailing semicolons from SQL text before sending queries to Snowflake        |
| results                    | True                   | If set to off, queries will be sent asynchronously, but no results will be fetched.  |
|                            |                        | Use !queries to check the status.                                                    |
| rowset_size                | 1000                   | Sets the size of rowsets to fetch from the server.                                   |
|                            |                        | Set the option low for smooth output, high for fast output.                          |
| sfqid                      | True                   | Turns on/off Snowflake query id in the summary.                                      |
| sfqid_in_error             | False                  | Turns on/off Snowflake query id in the error message                                 |
| stop_on_error              | False                  | Stops all queries yet to run when SnowSQL encounters an error                        |
| syntax_style               | default                | Sets the colors for the text of SnowSQL.                                             |
| timing                     | True                   | Turns on/off timing for each query                                                   |
| timing_in_output_file      | False                  | Includes timing in the output file.                                                  |
| variable_substitution      | False                  | Substitutes variables (starting with '&') with values                                |
| version                    | 1.1.84                 | SnowSQL version                                                                      |
| wrap                       | True                   | Truncates lines at the width of the terminal screen                                  |
+----------------------------+------------------------+--------------------------------------------------------------------------------------+


Usage example for snowsql command line !options:


ubuntu@server:~$ snowsql -o friendly=false -o sfqid=on -o echo=True -o progress_bar=false  -q 'SELECT CURRENT_TIMESTAMP'
SELECT CURRENT_TIMESTAMP
+-------------------------------+
| CURRENT_TIMESTAMP             |
|-------------------------------|
| 2019-09-09 16:05:10.176 -0700 |
+-------------------------------+
1 Row(s) produced. Time Elapsed: 0.130s, Query ID: 018ec7e9-9999-9999-9999-83f10025e61a


Set options when at snowsql session:


--- Success ---
USR#WH@DBNAME.PUBLIC>   !set echo=false   --- Case-insensetive
USR#WH@DBNAME.PUBLIC>   !set echo=False
USR#WH@DBNAME.PUBLIC>   !set echo=TRUE
USR#WH@DBNAME.PUBLIC>   !set echo =TRUE

--- These will FAIL ---

USR#WH@DBNAME.PUBLIC>   !set echo=1;      --- ERROR: not acceptable value
1 is not an acceptable value for echo     

1 is not an acceptable value for echo
USR#WH@DBNAME.PUBLIC>   !set echo= TRUE   --- ERROR: white space is part of a value after '=' sign
 TRUE is not an acceptable value for echo

.

1 comment: