https://hive.apache.org/docs/latest/language/languagemanual-commands/
set:
-- For hiveconf variables set my_var=; -- For hivevar variables set hivevar:my_var=;
spark-sql (default)> set a=1; a 1 Time taken: 0.009 seconds, Fetched 1 row(s) spark-sql (default)> ${hiveconf:a}; [PARSE_SYNTAX_ERROR] Syntax error at or near '1'. SQLSTATE: 42601 (line 1, pos 0) == SQL == 1 ^^^ spark-sql (default)> set; a 1 spark.app.id local-1768096841019 spark.app.name SparkSQL::172.26.76.164 spark.app.startTime 1768096840445 spark.app.submitTime 1768096839230 spark.driver.extraClassPath /home/frank/download/apache-hive-4.2.0/lib/postgresql-42.7.8.jar spark.driver.extraJavaOptions -Djava.net.preferIPv6Addresses=false -XX:+IgnoreUnrecognizedVMOptions --add-modules=jdk.incubator.vector --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.cs=ALL-UNNAMED --add-opens=java.base/sun.security.action=ALL-UNNAMED --add-opens=java.base/sun.util.calendar=ALL-UNNAMED --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED -Djdk.reflect.useDirectMethodHandle=false -Dio.netty.tryReflectionSetAccessible=true -Dio.netty.allocator.type=pooled -Dio.netty.handler.ssl.defaultEndpointVerificationAlgorithm=NONE --enable-native-access=ALL-UNNAMED spark.driver.host 172.26.76.164 spark.driver.port 33299 spark.executor.extraJavaOptions -Djava.net.preferIPv6Addresses=false -XX:+IgnoreUnrecognizedVMOptions --add-modules=jdk.incubator.vector --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.cs=ALL-UNNAMED --add-opens=java.base/sun.security.action=ALL-UNNAMED --add-opens=java.base/sun.util.calendar=ALL-UNNAMED --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED -Djdk.reflect.useDirectMethodHandle=false -Dio.netty.tryReflectionSetAccessible=true -Dio.netty.allocator.type=pooled -Dio.netty.handler.ssl.defaultEndpointVerificationAlgorithm=NONE --enable-native-access=ALL-UNNAMED spark.executor.id driver spark.hadoop.fs.s3a.vectored.read.max.merged.size 2M spark.hadoop.fs.s3a.vectored.read.min.seek.size 128K spark.jars spark.master local[*] spark.sql.artifact.isolation.enabled false spark.sql.binaryOutputStyle UTF-8 spark.sql.catalogImplementation hive spark.sql.datetime.java8API.enabled true spark.sql.hive.metastore.jars maven spark.sql.hive.metastore.jars.isolation true spark.sql.hive.metastore.sharedPrefixes org.postgresql spark.sql.hive.metastore.version 4.1.0 spark.sql.hive.version 2.3.10 spark.sql.warehouse.dir file:/home/frank/spark-warehouse spark.submit.deployMode client spark.submit.pyFiles Time taken: 0.009 seconds, Fetched 27 row(s) spark-sql (default)>
spark-sql (default)> set hivevar:b=2; hivevar:b 2 Time taken: 0.017 seconds, Fetched 1 row(s) spark-sql (default)> ${hivevar:b}; [PARSE_SYNTAX_ERROR] Syntax error at or near '2'. SQLSTATE: 42601 (line 1, pos 0) == SQL == 2 ^^^
spark-sql (default)> set zzz:aaa='A'; zzz:aaa 'A' Time taken: 0.011 seconds, Fetched 1 row(s) spark-sql (default)> ${zzz:aaa}; [PARSE_SYNTAX_ERROR] Syntax error at or near '$'. SQLSTATE: 42601 (line 1, pos 0) spark-sql (default)> ${hiveconf:zzz:aaa}; [PARSE_SYNTAX_ERROR] Syntax error at or near ''A''. SQLSTATE: 42601 (line 1, pos 0) == SQL == 'A' ^^^ spark-sql (default)> set zzz:aaa; zzz:aaa 'A' Time taken: 0.009 seconds, Fetched 1 row(s)
Hive variables (both hivevar and hiveconf) are session-scoped. They exist only for the duration of your current CLI, Beeline, or Hue session. To completely remove a variable:
-
Exit the current session (
exit;orquit;). -
Start a new session.
spark-sql (default)> !clear; Time taken: 0.006 seconds spark-sql (default)> !ls; airflow airflow-venv download tmp zproject zvenv Time taken: 0.005 seconds spark-sql (default)>

浙公网安备 33010602011771号