SHOW Statements

    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

    Java

    SHOW statements can be executed with the 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.

    SQL CLI

    SHOW statements can be executed in SQL CLI.

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

    Java

    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. // +---------------+
    57. // | f1 |
    58. // | ... |
    59. // +---------------+
    60. // show modules
    61. tEnv.executeSql("SHOW MODULES").print()
    62. // | module name |
    63. // +-------------+
    64. // | core |
    65. // +-------------+
    66. // show full modules
    67. tEnv.executeSql("SHOW FULL MODULES").print()
    68. // +-------------+-------+
    69. // | module name | used |
    70. // +-------------+-------+
    71. // | core | true |
    72. // | hive | false |
    73. // +-------------+-------+

    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. # | f1 |
    57. # | ... |
    58. # +---------------+
    59. # show modules
    60. # +-------------+
    61. # | module name |
    62. # +-------------+
    63. # | core |
    64. # +-------------+
    65. # show full modules
    66. table_env.execute_sql("SHOW FULL MODULES").print()
    67. # +-------------+-------+
    68. # | module name | used |
    69. # +-------------+-------+
    70. # | core | true |
    71. # | hive | false |
    72. # +-------------+-------+

    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

    Show all catalogs.

    SHOW CURRENT CATALOG

    1. SHOW CURRENT CATALOG

    Show current catalog.

    1. SHOW DATABASES

    SHOW CURRENT DATABASE

    1. SHOW CURRENT DATABASE

    Show current database.

    SHOW TABLES

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

    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

      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 all enabled module names with resolution order.

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

      SHOW JARS

      1. SHOW JARS

      Attention Currently SHOW JARS only works in the SQL CLI.