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 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 VIEWS
  • SHOW FUNCTIONS
  • SHOW MODULES

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. // create a view
  41. tEnv.executeSql("CREATE VIEW my_view AS ...");
  42. // show views
  43. tEnv.executeSql("SHOW VIEWS").print();
  44. // +-----------+
  45. // | view name |
  46. // +-----------+
  47. // | my_view |
  48. // +-----------+
  49. // show functions
  50. tEnv.executeSql("SHOW FUNCTIONS").print();
  51. // +---------------+
  52. // | function name |
  53. // +---------------+
  54. // | mod |
  55. // | sha256 |
  56. // | ... |
  57. // +---------------+
  58. // create a user defined function
  59. tEnv.executeSql("CREATE FUNCTION f1 AS ...");
  60. // show user defined functions
  61. tEnv.executeSql("SHOW USER FUNCTIONS").print();
  62. // +---------------+
  63. // | function name |
  64. // +---------------+
  65. // | f1 |
  66. // | ... |
  67. // +---------------+
  68. // show modules
  69. tEnv.executeSql("SHOW MODULES").print();
  70. // +-------------+
  71. // | module name |
  72. // +-------------+
  73. // | core |
  74. // +-------------+
  75. // show full modules
  76. tEnv.executeSql("SHOW FULL MODULES").print();
  77. // +-------------+-------+
  78. // | module name | used |
  79. // +-------------+-------+
  80. // | core | true |
  81. // | hive | false |
  82. // +-------------+-------+

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. // create a view
  27. tEnv.executeSql("CREATE VIEW my_view AS ...")
  28. // show views
  29. tEnv.executeSql("SHOW VIEWS").print()
  30. // +-----------+
  31. // | view name |
  32. // +-----------+
  33. // | my_view |
  34. // +-----------+
  35. // show functions
  36. tEnv.executeSql("SHOW FUNCTIONS").print()
  37. // +---------------+
  38. // | function name |
  39. // +---------------+
  40. // | mod |
  41. // | sha256 |
  42. // | ... |
  43. // +---------------+
  44. // create a user defined function
  45. tEnv.executeSql("CREATE FUNCTION f1 AS ...")
  46. // show user defined functions
  47. tEnv.executeSql("SHOW USER FUNCTIONS").print()
  48. // +---------------+
  49. // | function name |
  50. // +---------------+
  51. // | f1 |
  52. // | ... |
  53. // +---------------+
  54. // show modules
  55. tEnv.executeSql("SHOW MODULES").print()
  56. // +-------------+
  57. // | module name |
  58. // +-------------+
  59. // | core |
  60. // +-------------+
  61. // show full modules
  62. tEnv.executeSql("SHOW FULL MODULES").print()
  63. // +-------------+-------+
  64. // | module name | used |
  65. // +-------------+-------+
  66. // | core | true |
  67. // | hive | false |
  68. // +-------------+-------+

Python

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

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> CREATE VIEW my_view AS ...;
  10. [INFO] View has been created.
  11. Flink SQL> SHOW VIEWS;
  12. my_view
  13. Flink SQL> SHOW FUNCTIONS;
  14. mod
  15. sha256
  16. ...
  17. Flink SQL> CREATE FUNCTION f1 AS ...;
  18. [INFO] Function has been created.
  19. Flink SQL> SHOW USER FUNCTIONS;
  20. f1
  21. ...
  22. Flink SQL> SHOW MODULES;
  23. +-------------+
  24. | module name |
  25. +-------------+
  26. | core |
  27. +-------------+
  28. 1 row in set
  29. Flink SQL> SHOW FULL MODULES;
  30. +-------------+------+
  31. | module name | used |
  32. +-------------+------+
  33. | core | true |
  34. +-------------+------+
  35. 1 row in set

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 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.