如何在 Spark 中获取默认 属性 值
How to get default property values in Spark
我正在使用这个版本的 Spark:spark-1.4.0-bin-hadoop2.6
。我想检查一些默认属性。所以我在 spark-shell
中给出了以下声明
scala> sqlContext.getConf("spark.sql.hive.metastore.version")
我期待调用方法 getConf
到 return 0.13.1
的值,如本 link 中所述。但是我得到了以下异常
java.util.NoSuchElementException: spark.sql.hive.metastore.version
at org.apache.spark.sql.SQLConf$$anonfun$getConf.apply(SQLConf.scala:283)
at org.apache.spark.sql.SQLConf$$anonfun$getConf.apply(SQLConf.scala:283)
我是否以正确的方式检索属性?
您可以使用
sc.getConf.toDebugString
或
sqlContext.getAllConfs
这将 return 所有已设置的值,但是代码中有一些默认值。在您的具体示例中,it is indeed in the code:
getConf(HIVE_METASTORE_VERSION, hiveExecutionVersion)
val hiveExecutionVersion: String = "0.13.1"
因此,getConf
将尝试从配置中提取 Metastore 版本,回退到默认值,但这并未在 conf 本身中列出。
在 Spark 中 2.x.x 如果我想知道 Spark Conf 的默认值,我会这样做:
下面的命令将 return spark-shell 中的 Scala Map。
spark.sqlContext.getAllConfs
找到我们的 conf 值 属性:
例如- 找到spark使用的默认仓库目录设置为conf -
spark.sql.warehouse.dir:
spark.sqlContext.getAllConfs.get("spark.sql.warehouse.dir")
我正在使用这个版本的 Spark:spark-1.4.0-bin-hadoop2.6
。我想检查一些默认属性。所以我在 spark-shell
scala> sqlContext.getConf("spark.sql.hive.metastore.version")
我期待调用方法 getConf
到 return 0.13.1
的值,如本 link 中所述。但是我得到了以下异常
java.util.NoSuchElementException: spark.sql.hive.metastore.version
at org.apache.spark.sql.SQLConf$$anonfun$getConf.apply(SQLConf.scala:283)
at org.apache.spark.sql.SQLConf$$anonfun$getConf.apply(SQLConf.scala:283)
我是否以正确的方式检索属性?
您可以使用
sc.getConf.toDebugString
或
sqlContext.getAllConfs
这将 return 所有已设置的值,但是代码中有一些默认值。在您的具体示例中,it is indeed in the code:
getConf(HIVE_METASTORE_VERSION, hiveExecutionVersion)
val hiveExecutionVersion: String = "0.13.1"
因此,getConf
将尝试从配置中提取 Metastore 版本,回退到默认值,但这并未在 conf 本身中列出。
在 Spark 中 2.x.x 如果我想知道 Spark Conf 的默认值,我会这样做:
下面的命令将 return spark-shell 中的 Scala Map。
spark.sqlContext.getAllConfs
找到我们的 conf 值 属性:
例如- 找到spark使用的默认仓库目录设置为conf - spark.sql.warehouse.dir:
spark.sqlContext.getAllConfs.get("spark.sql.warehouse.dir")