SHOW Statements

SHOW statements are used to list all catalogs, or list all databases in the current catalog, or list all tables/views in the current catalog and the current database, or show current catalog and database, or show create statement for specified table, or list all functions including system functions and user-defined functions in the current catalog and current database, or list only user-defined functions in the current catalog and current database, or list enabled module names, or list all loaded modules with enabled status in the current session.

Flink SQL supports the following SHOW statements for now:

  • SHOW CATALOGS
  • SHOW CURRENT CATALOG
  • SHOW DATABASES
  • SHOW CURRENT DATABASE
  • SHOW TABLES
  • SHOW CREATE TABLE
  • SHOW VIEWS
  • SHOW FUNCTIONS
  • SHOW MODULES
  • SHOW JARS

Run a SHOW statement

Java

SHOW statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns objects for a successful SHOW operation, otherwise will throw an exception.

The following examples show how to run a SHOW statement in TableEnvironment.

Scala

SHOW statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns objects for a successful SHOW operation, otherwise will throw an exception.

The following examples show how to run a SHOW statement in TableEnvironment.

Python

SHOW statements can be executed with the execute_sql() method of the TableEnvironment. The execute_sql() method returns objects for a successful SHOW operation, otherwise will throw an exception.

The following examples show how to run a SHOW statement in TableEnvironment.

SQL CLI

SHOW statements can be executed in SQL CLI.

The following examples show how to run a SHOW statement in SQL CLI.

Java

  1. StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  2. StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
  3. // show catalogs
  4. tEnv.executeSql("SHOW CATALOGS").print();
  5. // +-----------------+
  6. // | catalog name |
  7. // +-----------------+
  8. // | default_catalog |
  9. // +-----------------+
  10. // show current catalog
  11. tEnv.executeSql("SHOW CURRENT CATALOG").print();
  12. // +----------------------+
  13. // | current catalog name |
  14. // +----------------------+
  15. // | default_catalog |
  16. // +----------------------+
  17. // show databases
  18. tEnv.executeSql("SHOW DATABASES").print();
  19. // +------------------+
  20. // | database name |
  21. // +------------------+
  22. // | default_database |
  23. // +------------------+
  24. // show current database
  25. tEnv.executeSql("SHOW CURRENT DATABASE").print();
  26. // +-----------------------+
  27. // | current database name |
  28. // +-----------------------+
  29. // | default_database |
  30. // +-----------------------+
  31. // create a table
  32. tEnv.executeSql("CREATE TABLE my_table (...) WITH (...)");
  33. // show tables
  34. tEnv.executeSql("SHOW TABLES").print();
  35. // +------------+
  36. // | table name |
  37. // +------------+
  38. // | my_table |
  39. // +------------+
  40. // show create table
  41. tEnv.executeSql("SHOW CREATE TABLE my_table").print();
  42. // CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  43. // ...
  44. // ) WITH (
  45. // ...
  46. // )
  47. // create a view
  48. tEnv.executeSql("CREATE VIEW my_view AS ...");
  49. // show views
  50. tEnv.executeSql("SHOW VIEWS").print();
  51. // +-----------+
  52. // | view name |
  53. // +-----------+
  54. // | my_view |
  55. // +-----------+
  56. // show functions
  57. tEnv.executeSql("SHOW FUNCTIONS").print();
  58. // +---------------+
  59. // | function name |
  60. // +---------------+
  61. // | mod |
  62. // | sha256 |
  63. // | ... |
  64. // +---------------+
  65. // create a user defined function
  66. tEnv.executeSql("CREATE FUNCTION f1 AS ...");
  67. // show user defined functions
  68. tEnv.executeSql("SHOW USER FUNCTIONS").print();
  69. // +---------------+
  70. // | function name |
  71. // +---------------+
  72. // | f1 |
  73. // | ... |
  74. // +---------------+
  75. // show modules
  76. tEnv.executeSql("SHOW MODULES").print();
  77. // +-------------+
  78. // | module name |
  79. // +-------------+
  80. // | core |
  81. // +-------------+
  82. // show full modules
  83. tEnv.executeSql("SHOW FULL MODULES").print();
  84. // +-------------+-------+
  85. // | module name | used |
  86. // +-------------+-------+
  87. // | core | true |
  88. // | hive | false |
  89. // +-------------+-------+

Scala

  1. val env = StreamExecutionEnvironment.getExecutionEnvironment()
  2. val tEnv = StreamTableEnvironment.create(env)
  3. // show catalogs
  4. tEnv.executeSql("SHOW CATALOGS").print()
  5. // +-----------------+
  6. // | catalog name |
  7. // +-----------------+
  8. // | default_catalog |
  9. // +-----------------+
  10. // show databases
  11. tEnv.executeSql("SHOW DATABASES").print()
  12. // +------------------+
  13. // | database name |
  14. // +------------------+
  15. // | default_database |
  16. // +------------------+
  17. // create a table
  18. tEnv.executeSql("CREATE TABLE my_table (...) WITH (...)")
  19. // show tables
  20. tEnv.executeSql("SHOW TABLES").print()
  21. // +------------+
  22. // | table name |
  23. // +------------+
  24. // | my_table |
  25. // +------------+
  26. // show create table
  27. tEnv.executeSql("SHOW CREATE TABLE my_table").print()
  28. // CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  29. // ...
  30. // ) WITH (
  31. // ...
  32. // )
  33. // create a view
  34. tEnv.executeSql("CREATE VIEW my_view AS ...")
  35. // show views
  36. tEnv.executeSql("SHOW VIEWS").print()
  37. // +-----------+
  38. // | view name |
  39. // +-----------+
  40. // | my_view |
  41. // +-----------+
  42. // show functions
  43. tEnv.executeSql("SHOW FUNCTIONS").print()
  44. // +---------------+
  45. // | function name |
  46. // +---------------+
  47. // | mod |
  48. // | sha256 |
  49. // | ... |
  50. // +---------------+
  51. // create a user defined function
  52. tEnv.executeSql("CREATE FUNCTION f1 AS ...")
  53. // show user defined functions
  54. tEnv.executeSql("SHOW USER FUNCTIONS").print()
  55. // +---------------+
  56. // | function name |
  57. // +---------------+
  58. // | f1 |
  59. // | ... |
  60. // +---------------+
  61. // show modules
  62. tEnv.executeSql("SHOW MODULES").print()
  63. // +-------------+
  64. // | module name |
  65. // +-------------+
  66. // | core |
  67. // +-------------+
  68. // show full modules
  69. tEnv.executeSql("SHOW FULL MODULES").print()
  70. // +-------------+-------+
  71. // | module name | used |
  72. // +-------------+-------+
  73. // | core | true |
  74. // | hive | false |
  75. // +-------------+-------+

Python

  1. table_env = StreamTableEnvironment.create(...)
  2. # show catalogs
  3. table_env.execute_sql("SHOW CATALOGS").print()
  4. # +-----------------+
  5. # | catalog name |
  6. # +-----------------+
  7. # | default_catalog |
  8. # +-----------------+
  9. # show databases
  10. table_env.execute_sql("SHOW DATABASES").print()
  11. # +------------------+
  12. # | database name |
  13. # +------------------+
  14. # | default_database |
  15. # +------------------+
  16. # create a table
  17. table_env.execute_sql("CREATE TABLE my_table (...) WITH (...)")
  18. # show tables
  19. table_env.execute_sql("SHOW TABLES").print()
  20. # +------------+
  21. # | table name |
  22. # +------------+
  23. # | my_table |
  24. # +------------+
  25. # show create table
  26. table_env.executeSql("SHOW CREATE TABLE my_table").print()
  27. # CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  28. # ...
  29. # ) WITH (
  30. # ...
  31. # )
  32. # create a view
  33. table_env.execute_sql("CREATE VIEW my_view AS ...")
  34. # show views
  35. table_env.execute_sql("SHOW VIEWS").print()
  36. # +-----------+
  37. # | view name |
  38. # +-----------+
  39. # | my_view |
  40. # +-----------+
  41. # show functions
  42. table_env.execute_sql("SHOW FUNCTIONS").print()
  43. # +---------------+
  44. # | function name |
  45. # +---------------+
  46. # | mod |
  47. # | sha256 |
  48. # | ... |
  49. # +---------------+
  50. # create a user defined function
  51. table_env.execute_sql("CREATE FUNCTION f1 AS ...")
  52. # show user defined functions
  53. table_env.execute_sql("SHOW USER FUNCTIONS").print()
  54. # +---------------+
  55. # | function name |
  56. # +---------------+
  57. # | f1 |
  58. # | ... |
  59. # +---------------+
  60. # show modules
  61. table_env.execute_sql("SHOW MODULES").print()
  62. # +-------------+
  63. # | module name |
  64. # +-------------+
  65. # | core |
  66. # +-------------+
  67. # show full modules
  68. table_env.execute_sql("SHOW FULL MODULES").print()
  69. # +-------------+-------+
  70. # | module name | used |
  71. # +-------------+-------+
  72. # | core | true |
  73. # | hive | false |
  74. # +-------------+-------+

SQL CLI

  1. Flink SQL> SHOW CATALOGS;
  2. default_catalog
  3. Flink SQL> SHOW DATABASES;
  4. default_database
  5. Flink SQL> CREATE TABLE my_table (...) WITH (...);
  6. [INFO] Table has been created.
  7. Flink SQL> SHOW TABLES;
  8. my_table
  9. Flink SQL> SHOW CREATE TABLE my_table;
  10. CREATE TABLE `default_catalog`.`default_db`.`my_table` (
  11. ...
  12. ) WITH (
  13. ...
  14. )
  15. Flink SQL> CREATE VIEW my_view AS ...;
  16. [INFO] View has been created.
  17. Flink SQL> SHOW VIEWS;
  18. my_view
  19. Flink SQL> SHOW FUNCTIONS;
  20. mod
  21. sha256
  22. ...
  23. Flink SQL> CREATE FUNCTION f1 AS ...;
  24. [INFO] Function has been created.
  25. Flink SQL> SHOW USER FUNCTIONS;
  26. f1
  27. ...
  28. Flink SQL> SHOW MODULES;
  29. +-------------+
  30. | module name |
  31. +-------------+
  32. | core |
  33. +-------------+
  34. 1 row in set
  35. Flink SQL> SHOW FULL MODULES;
  36. +-------------+------+
  37. | module name | used |
  38. +-------------+------+
  39. | core | true |
  40. +-------------+------+
  41. 1 row in set
  42. Flink SQL> SHOW JARS;
  43. /path/to/addedJar.jar

SHOW CATALOGS

  1. SHOW CATALOGS

Show all catalogs.

SHOW CURRENT CATALOG

  1. SHOW CURRENT CATALOG

Show current catalog.

SHOW DATABASES

  1. SHOW DATABASES

Show all databases in the current catalog.

SHOW CURRENT DATABASE

  1. SHOW CURRENT DATABASE

Show current database.

SHOW TABLES

  1. SHOW TABLES

Show all tables in the current catalog and the current database.

SHOW CREATE TABLE

  1. SHOW CREATE TABLE

Show create table statement for specified table.

Attention Currently SHOW CREATE TABLE only supports table that is created by Flink SQL DDL.

SHOW VIEWS

  1. SHOW VIEWS

Show all views in the current catalog and the current database.

SHOW FUNCTIONS

  1. SHOW [USER] FUNCTIONS

Show all functions including system functions and user-defined functions in the current catalog and current database.

USER Show only user-defined functions in the current catalog and current database.

SHOW MODULES

  1. SHOW [FULL] MODULES

Show all enabled module names with resolution order.

FULL Show all loaded modules and enabled status with resolution order.

SHOW JARS

  1. SHOW JARS

Show all added jars in the session classloader which are added by ADD JAR statements.

Attention Currently SHOW JARS only works in the SQL CLI.