docs/content/docs/sql/reference/utility/load.md
LOAD statements are used to load a built-in or user-defined module.
{{< tabs "load statement" >}} {{< tab "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.
{{< /tab >}} {{< tab "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.
{{< /tab >}}
{{< tab "Python" >}}
LOAD statements can be executed with the execute_sql() method of the TableEnvironment. The execute_sql() 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.
{{< /tab >}} {{< tab "SQL CLI" >}}
LOAD statements can be executed in [SQL CLI]({{< ref "docs/sql/interfaces/sql-client" >}}).
The following examples show how to run a LOAD statement in SQL CLI.
{{< /tab >}} {{< /tabs >}}
{{< tabs "load modules" >}} {{< tab "Java" >}}
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
// load a hive module
tEnv.executeSql("LOAD MODULE hive WITH ('hive-version' = '3.1.3')");
tEnv.executeSql("SHOW MODULES").print();
// +-------------+
// | module name |
// +-------------+
// | core |
// | hive |
// +-------------+
{{< /tab >}} {{< tab "Scala" >}}
val env = StreamExecutionEnvironment.getExecutionEnvironment()
val tEnv = StreamTableEnvironment.create(env)
// load a hive module
tEnv.executeSql("LOAD MODULE hive WITH ('hive-version' = '3.1.3')")
tEnv.executeSql("SHOW MODULES").print()
// +-------------+
// | module name |
// +-------------+
// | core |
// | hive |
// +-------------+
{{< /tab >}} {{< tab "Python" >}}
table_env = StreamTableEnvironment.create(...)
# load a hive module
table_env.execute_sql("LOAD MODULE hive WITH ('hive-version' = '3.1.3')")
table_env.execute_sql("SHOW MODULES").print()
# +-------------+
# | module name |
# +-------------+
# | core |
# | hive |
# +-------------+
{{< /tab >}} {{< tab "SQL CLI" >}}
Flink SQL> LOAD MODULE hive WITH ('hive-version' = '3.1.3');
[INFO] Load module succeeded!
Flink SQL> SHOW MODULES;
+-------------+
| module name |
+-------------+
| core |
| hive |
+-------------+
{{< /tab >}} {{< /tabs >}}
{{< top >}}
The following grammar gives an overview of the available syntax:
LOAD MODULE module_name [WITH ('key1' = 'val1', 'key2' = 'val2', ...)]
{{< hint warning >}}
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.
{{< /hint >}}