Repository navigation
[SPARK-61179][CONNECT][PYTHON] Unset a DataFrameReader option of None, and take the description of Catalog.createExternalTable, in the Python client as PySpark does - #377
Open
HyukjinKwon wants to merge 1 commit into
Conversation
…, and take the description of Catalog.createExternalTable, in the Python client as PySpark does DataFrameReader.option(key, None), DataFrameReader.options(key=None) and DataFrameReader.load(..., key=None) unset the option in PySpark, while the format methods (csv(path, header=None) and the like) skip None and keep it. The client skipped None in all of them, so an earlier value stayed. The reader now unsets the option for the first three. Catalog.createExternalTable passes its keyword arguments to createTable, so description is createTable's description, which becomes the table comment. The client sent it as a table option instead, so there was no comment and a "description" property. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
SPARK-61179: PySpark's
DataFrameReader.option(key, None),DataFrameReader.options(key=None)andDataFrameReader.load(..., key=None)unset the option, andCatalog.createExternalTable(..., description=...)passes the description tocreateTable, which stores it as the table comment.DataFrameReader.option,optionsandloadunset an option givenNone, through a new coreDataFrameReader::unset_option. The format methods (csv(path, header=None)and the like) still skipNoneand keep the earlier value, as PySpark does, and so do theDataStreamReaderand writer option methods, which PySpark also keeps.Catalog.createExternalTabletakesdescriptionas a named argument and passes it tocreateTable, instead of sending it as a table option.Why are the changes needed?
A reader option set to
Nonekept its earlier value, so the reader read with the header that PySpark drops:createExternalTablewith a description did not set the table comment:Does this PR introduce any user-facing change?
Yes.
DataFrameReader.option,optionsandloadwith aNonevalue now unset the option, as in PySpark.Catalog.createExternalTable(description=...)sets the table comment, as in PySpark, and no longer adds a table option.One difference remains: PySpark's
DataFrameReader._optionslists an unset key with the valueNone, and the Rust-backed reader drops the key.How was this patch tested?
test_reader_none_unsets_an_option_and_external_description_is_the_commentinpython/tests/test_dropin_e2e.py. It checks the reader columns afteroption,optionsandloadwithNoneafter an earlierheadervalue, that thecsv(path, header=None)kwarg keeps the earlier value, and that a reused reader keeps its option, and it checksgetTable(...).description, theCommentrow ofDESCRIBE TABLE EXTENDED, and thatSHOW TBLPROPERTIESlists no description. It fails without this change, at the firstoptioncase (['a', 'b']for['_c0', '_c1']). The same test passes with official PySpark 4.3.0 oversc://.DESCRIBEresults were checked with official PySpark 4.3.0, this change and master by a probe script.option(key, None)keeps the earlier value in official PySpark 4.3.0 forDataFrameWriter,DataFrameWriterV2andDataStreamReader(probed through_writeand_options), and on the build forDataFrameWriter(by reading back the written header) andDataStreamReader(through_options). The build'sDataFrameWriterV2path is unchanged and was not probed.wasm-udf, the offline Python suites (2227 passed, 8 skipped), and the live drop-in and Arrow suites (211 passed) and live cases (10 passed) against a local Spark 4.3.0 server. Clippy reports no diagnostics in the changed lines.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.