如何在 Notebook 中檢查 Spark 屬性是否可修改How to check if a spark property is modifiable in a notebook

問題Problem

您可以藉由設定各種設定來調整應用程式。You can tune applications by setting various configurations. 某些設定必須在叢集層級設定,而某些設定則是在筆記本或應用程式內設定。Some configurations must be set at the cluster level, whereas some are set inside notebooks or applications.

解決方法Solution

若要檢查是否可以在筆記本中設定特定的 Spark 設定,請在筆記本資料格中執行下列命令:To check if a particular Spark configuration can be set in a notebook, run the following command in a notebook cell:

spark.conf.isModifiable("spark.databricks.preemption.enabled")

如果 true 傳回,則可以在筆記本中設定屬性。If true is returned, then the property can be set in the notebook. 否則,必須在叢集層級設定。Otherwise, it must be set at the cluster level.