Skip to content

Commit 5ba467c

Browse files
yaooqinnHyukjinKwon
authored andcommitted
[SPARK-31550][SQL][DOCS] Set nondeterministic configurations with general meanings in sql configuration doc
### What changes were proposed in this pull request? ```scala spark.sql.session.timeZone spark.sql.warehouse.dir ``` these 2 configs are nondeterministic and vary with environments Besides, reflect code in `gen-sql-config-docs.py` via apache#28274 (comment) and `configuration.md` via apache#28274 (comment) ### Why are the changes needed? doc fix ### Does this PR introduce any user-facing change? no ### How was this patch tested? verify locally ![image](https://user-images.githubusercontent.com/8326978/80179099-5e7da200-8632-11ea-803f-d47a93151869.png) Closes apache#28322 from yaooqinn/SPARK-31550. Authored-by: Kent Yao <[email protected]> Signed-off-by: HyukjinKwon <[email protected]>
1 parent b6509aa commit 5ba467c

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

docs/configuration.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -2624,30 +2624,31 @@ Spark subsystems.
26242624

26252625
### Spark SQL
26262626

2627+
{% for static_file in site.static_files %}
2628+
{% if static_file.name == 'generated-runtime-sql-config-table.html' %}
2629+
26272630
#### Runtime SQL Configuration
26282631

26292632
Runtime SQL configurations are per-session, mutable Spark SQL configurations. They can be set with initial values by the config file
26302633
and command-line options with `--conf/-c` prefixed, or by setting `SparkConf` that are used to create `SparkSession`.
26312634
Also, they can be set and queried by SET commands and rest to their initial values by RESET command,
26322635
or by `SparkSession.conf`'s setter and getter methods in runtime.
26332636

2634-
{% for static_file in site.static_files %}
2635-
{% if static_file.name == 'generated-runtime-sql-config-table.html' %}
2636-
{% include_relative generated-runtime-sql-config-table.html %}
2637+
{% include_relative generated-runtime-sql-config-table.html %}
26372638
{% break %}
26382639
{% endif %}
26392640
{% endfor %}
26402641

2642+
{% for static_file in site.static_files %}
2643+
{% if static_file.name == 'generated-static-sql-config-table.html' %}
26412644

26422645
#### Static SQL Configuration
26432646

26442647
Static SQL configurations are cross-session, immutable Spark SQL configurations. They can be set with final values by the config file
26452648
and command-line options with `--conf/-c` prefixed, or by setting `SparkConf` that are used to create `SparkSession`.
26462649
External users can query the static sql config values via `SparkSession.conf` or via set command, e.g. `SET spark.sql.extensions;`, but cannot set/unset them.
26472650

2648-
{% for static_file in site.static_files %}
2649-
{% if static_file.name == 'generated-static-sql-config-table.html' %}
2650-
{% include_relative generated-static-sql-config-table.html %}
2651+
{% include_relative generated-static-sql-config-table.html %}
26512652
{% break %}
26522653
{% endif %}
26532654
{% endfor %}

sql/core/src/main/scala/org/apache/spark/sql/api/python/PythonSQLUtils.scala

+9-6
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ private[sql] object PythonSQLUtils {
4040
FunctionRegistry.functionSet.flatMap(f => FunctionRegistry.builtin.lookupFunction(f)).toArray
4141
}
4242

43-
def listSQLConfigs(): Array[(String, String, String, String)] = {
43+
private def listAllSQLConfigs(): Seq[(String, String, String, String)] = {
4444
val conf = new SQLConf()
45+
// Force to build static SQL configurations
46+
StaticSQLConf
47+
conf.getAllDefinedConfs
48+
}
49+
50+
def listRuntimeSQLConfigs(): Array[(String, String, String, String)] = {
4551
// Py4J doesn't seem to translate Seq well, so we convert to an Array.
46-
conf.getAllDefinedConfs.filterNot(p => SQLConf.staticConfKeys.contains(p._1)).toArray
52+
listAllSQLConfigs().filterNot(p => SQLConf.staticConfKeys.contains(p._1)).toArray
4753
}
4854

4955
def listStaticSQLConfigs(): Array[(String, String, String, String)] = {
50-
val conf = new SQLConf()
51-
// Force to build static SQL configurations
52-
StaticSQLConf
53-
conf.getAllDefinedConfs.filter(p => SQLConf.staticConfKeys.contains(p._1)).toArray
56+
listAllSQLConfigs().filter(p => SQLConf.staticConfKeys.contains(p._1)).toArray
5457
}
5558

5659
/**

sql/core/src/test/scala/org/apache/spark/sql/api/python/PythonSQLUtilsSuite.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.apache.spark.sql.internal.{SQLConf, StaticSQLConf}
2323
class PythonSQLUtilsSuite extends SparkFunSuite {
2424

2525
test("listing sql configurations contains runtime ones only") {
26-
val configs = PythonSQLUtils.listSQLConfigs()
26+
val configs = PythonSQLUtils.listRuntimeSQLConfigs()
2727

2828
// static sql configurations
2929
assert(!configs.exists(entry => entry._1 == StaticSQLConf.SPARK_SESSION_EXTENSIONS.key),

sql/create-docs.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@ mkdir docs
4545
echo "Generating SQL API Markdown files."
4646
"$SPARK_HOME/bin/spark-submit" gen-sql-api-docs.py
4747

48-
echo "Generating runtime SQL runtime configuration table HTML file."
49-
"$SPARK_HOME/bin/spark-submit" gen-sql-config-docs.py runtime
50-
51-
echo "Generating static SQL configuration table HTML file."
52-
"$SPARK_HOME/bin/spark-submit" gen-sql-config-docs.py static
48+
echo "Generating SQL configuration table HTML file."
49+
"$SPARK_HOME/bin/spark-submit" gen-sql-config-docs.py
5350

5451
echo "Generating HTML files for SQL function table and examples."
5552
"$SPARK_HOME/bin/spark-submit" gen-sql-functions-docs.py

sql/gen-sql-config-docs.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import os
1919
import re
20-
import sys
20+
2121
from collections import namedtuple
2222
from textwrap import dedent
2323

@@ -31,11 +31,11 @@
3131
"SQLConfEntry", ["name", "default", "description", "version"])
3232

3333

34-
def get_public_sql_configs(jvm, group):
34+
def get_sql_configs(jvm, group):
3535
if group == "static":
3636
config_set = jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listStaticSQLConfigs()
3737
else:
38-
config_set = jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listSQLConfigs()
38+
config_set = jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listRuntimeSQLConfigs()
3939
sql_configs = [
4040
SQLConfEntry(
4141
name=_sql_config._1(),
@@ -81,7 +81,11 @@ def generate_sql_configs_table_html(sql_configs, path):
8181
"""
8282
))
8383
for config in sorted(sql_configs, key=lambda x: x.name):
84-
if config.default == "<undefined>":
84+
if config.name == "spark.sql.session.timeZone":
85+
default = "(value of local timezone)"
86+
elif config.name == "spark.sql.warehouse.dir":
87+
default = "(value of <code>$PWD/spark-warehouse</code>)"
88+
elif config.default == "<undefined>":
8589
default = "(none)"
8690
elif config.default.startswith("<value of "):
8791
referenced_config_name = value_reference_pattern.match(config.default).group(1)
@@ -119,17 +123,13 @@ def generate_sql_configs_table_html(sql_configs, path):
119123

120124

121125
if __name__ == "__main__":
122-
if len(sys.argv) != 2:
123-
print("Usage: ./bin/spark-submit sql/gen-sql-config-docs.py <static|runtime>")
124-
sys.exit(-1)
125-
else:
126-
group = sys.argv[1]
127-
128126
jvm = launch_gateway().jvm
129-
sql_configs = get_public_sql_configs(jvm, group)
127+
docs_root_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "docs")
130128

131-
spark_root_dir = os.path.dirname(os.path.dirname(__file__))
132-
sql_configs_table_path = os.path\
133-
.join(spark_root_dir, "docs", "generated-" + group + "-sql-config-table.html")
129+
sql_configs = get_sql_configs(jvm, "runtime")
130+
sql_configs_table_path = os.path.join(docs_root_dir, "generated-runtime-sql-config-table.html")
131+
generate_sql_configs_table_html(sql_configs, path=sql_configs_table_path)
134132

133+
sql_configs = get_sql_configs(jvm, "static")
134+
sql_configs_table_path = os.path.join(docs_root_dir, "generated-static-sql-config-table.html")
135135
generate_sql_configs_table_html(sql_configs, path=sql_configs_table_path)

0 commit comments

Comments
 (0)