-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-30510][SQL][DOCS] Publicly document Spark SQL configuration options #27459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f2bb001
include sql configs from html file
nchammas f0137f6
generate html table of sql configs
nchammas a6045f7
example of follow-up that is needed to clean docstrings
nchammas 7742fc1
back to a plain list
nchammas a3b6d19
style
nchammas 886d01e
python style
nchammas b80e6f2
catch missed special default values
nchammas 914630f
fix reference
nchammas a8ad179
tweak create-docs info message
nchammas e09f890
use markdown via mkdocs
nchammas 851d557
explain why .toArray
nchammas 36fd916
use markdown from within mkdocs
nchammas 6ca51cd
fix config reference + undo ConfigEntry removal
nchammas 43e47bd
explain why weird import
nchammas 1c9aa71
show example html output
nchammas 65c5bb0
unnecessary comment
nchammas 79022e7
docstring -> description
nchammas aa63cbe
split up sql docs script: API + Config
nchammas ba8ae9f
move sql-configs.html to root of docs/
nchammas 5310f08
fix documentation around create-docs.sh
nchammas 61b4ac5
unnecessary whitespace
nchammas 679bdac
group imports at beginning
nchammas 8401b6a
check for private configs
nchammas e48eb34
tweak default formatting
nchammas 3292108
remove check for private configs
nchammas 617a69d
tweak info message from create-docs.sh
nchammas 452bf98
remove dup default
nchammas 4c32cf2
stringify certain defaults so they display right
nchammas b08bac4
300 -> 5 * 60
nchammas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| sql-configs.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| import os | ||
| import re | ||
| from collections import namedtuple | ||
| from textwrap import dedent | ||
|
|
||
| # To avoid adding a new direct dependency, we import markdown from within mkdocs. | ||
| from mkdocs.structure.pages import markdown | ||
| from pyspark.java_gateway import launch_gateway | ||
|
|
||
| SQLConfEntry = namedtuple( | ||
| "SQLConfEntry", ["name", "default", "description"]) | ||
|
|
||
|
|
||
| def get_public_sql_configs(jvm): | ||
| sql_configs = [ | ||
| SQLConfEntry( | ||
| name=_sql_config._1(), | ||
| default=_sql_config._2(), | ||
| description=_sql_config._3(), | ||
| ) | ||
| for _sql_config in jvm.org.apache.spark.sql.api.python.PythonSQLUtils.listSQLConfigs() | ||
| ] | ||
| return sql_configs | ||
|
|
||
|
|
||
| def generate_sql_configs_table(sql_configs, path): | ||
| """ | ||
| Generates an HTML table at `path` that lists all public SQL | ||
| configuration options. | ||
|
|
||
| The table will look something like this: | ||
|
|
||
| ```html | ||
| <table class="table"> | ||
| <tr><th>Property Name</th><th>Default</th><th>Meaning</th></tr> | ||
|
|
||
| <tr> | ||
| <td><code>spark.sql.adaptive.enabled</code></td> | ||
| <td>false</td> | ||
| <td><p>When true, enable adaptive query execution.</p></td> | ||
| </tr> | ||
|
|
||
| ... | ||
|
|
||
| </table> | ||
| ``` | ||
| """ | ||
| value_reference_pattern = re.compile(r"^<value of (\S*)>$") | ||
|
|
||
| with open(path, 'w') as f: | ||
| f.write(dedent( | ||
| """ | ||
| <table class="table"> | ||
| <tr><th>Property Name</th><th>Default</th><th>Meaning</th></tr> | ||
| """ | ||
| )) | ||
| for config in sorted(sql_configs, key=lambda x: x.name): | ||
| if config.default == "<undefined>": | ||
| default = "(none)" | ||
| elif config.default.startswith("<value of "): | ||
| referenced_config_name = value_reference_pattern.match(config.default).group(1) | ||
| default = "(value of <code>{}</code>)".format(referenced_config_name) | ||
| else: | ||
| default = config.default | ||
|
|
||
| if default.startswith("<"): | ||
| raise Exception( | ||
| "Unhandled reference in SQL config docs. Config '{name}' " | ||
| "has default '{default}' that looks like an HTML tag." | ||
| .format( | ||
| name=config.name, | ||
| default=config.default, | ||
| ) | ||
| ) | ||
|
|
||
| f.write(dedent( | ||
| """ | ||
| <tr> | ||
| <td><code>{name}</code></td> | ||
| <td>{default}</td> | ||
| <td>{description}</td> | ||
| </tr> | ||
| """ | ||
| .format( | ||
| name=config.name, | ||
| default=default, | ||
| description=markdown.markdown(config.description), | ||
| ) | ||
| )) | ||
| f.write("</table>\n") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| jvm = launch_gateway().jvm | ||
| sql_configs = get_public_sql_configs(jvm) | ||
|
|
||
| spark_root_dir = os.path.dirname(os.path.dirname(__file__)) | ||
| sql_configs_table_path = os.path.join(spark_root_dir, "docs/sql-configs.html") | ||
|
|
||
| generate_sql_configs_table(sql_configs, path=sql_configs_table_path) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.