LOAD Statements

LOAD statements are used to load a built-in or user-defined module.

Run a LOAD statement

Java

LOAD statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns ‘OK’ for a successful LOAD operation; otherwise, it will throw an exception.

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

Scala

LOAD statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns ‘OK’ for a successful LOAD operation; otherwise, it will throw an exception.

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

Python

LOAD statements can be executed with the executeSql() method of the TableEnvironment. The executeSql() method returns ‘OK’ for a successful LOAD operation; otherwise, it will throw an exception.

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

SQL CLI

LOAD statements can be executed in SQL CLI.

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

Java

  1. StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
  2. StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
  3. // load a hive module
  4. tEnv.executeSql("LOAD MODULE hive WITH ('hive-version' = '3.1.2')");
  5. tEnv.executeSql("SHOW MODULES").print();
  6. // +-------------+
  7. // | module name |
  8. // +-------------+
  9. // | core |
  10. // | hive |
  11. // +-------------+

Scala

  1. val env = StreamExecutionEnvironment.getExecutionEnvironment()
  2. val tEnv = StreamTableEnvironment.create(env)
  3. // load a hive module
  4. tEnv.executeSql("LOAD MODULE hive WITH ('hive-version' = '3.1.2')")
  5. tEnv.executeSql("SHOW MODULES").print()
  6. // +-------------+
  7. // | module name |
  8. // +-------------+
  9. // | core |
  10. // | hive |
  11. // +-------------+

Python

  1. table_env = StreamTableEnvironment.create(...)
  2. # load a hive module
  3. table_env.execute_sql("LOAD MODULE hive WITH ('hive-version' = '3.1.2')")
  4. table_env.execute_sql("SHOW MODULES").print()
  5. # +-------------+
  6. # | module name |
  7. # +-------------+
  8. # | core |
  9. # | hive |
  10. # +-------------+

SQL CLI

  1. Flink SQL> LOAD MODULE hive WITH ('hive-version' = '3.1.2');
  2. [INFO] Load module succeeded!
  3. Flink SQL> SHOW MODULES;
  4. +-------------+
  5. | module name |
  6. +-------------+
  7. | core |
  8. | hive |
  9. +-------------+

LOAD MODULE

The following grammar gives an overview of the available syntax:

  1. LOAD MODULE module_name [WITH ('key1' = 'val1', 'key2' = 'val2', ...)]

module_name is a simple identifier. It is case-sensitive and should be identical to the module type defined in the module factory because it is used to perform module discovery. Properties ('key1' = 'val1', 'key2' = 'val2', ...) is a map that contains a set of key-value pairs (except for the key 'type') and passed to the discovery service to instantiate the corresponding module.