Skip to content

fix: raise ValueError for invalid ParquetWriterOptions settings - #1862

Open
andygrove wants to merge 3 commits into
apache:mainfrom
andygrove:df56-upgrade-followups
Open

andygrove wants to merge 3 commits into
apache:mainfrom
andygrove:df56-upgrade-followups

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

No issue. Follow-up to the review of #1826.

Rationale for this change

#1826 upgraded to DataFusion 56. Comparing it with the 55.0.0 release turned up a few gaps that users would hit.

  • An invalid compression, statistics_enabled or encoding in ParquetWriterOptions raised RuntimeError with a Rust Debug string, for example Configuration("Unknown or unsupported parquet compression: bogus. ..."). SessionConfig.set rejects the same values with a readable ValueError.
  • DataFusion 56 validates more settings than the upgrade guide said. The Parquet compression, statistics_enabled, encoding and coerce_int96_tz settings are now rejected when they are set, and an invalid statistics_enabled in ParquetWriterOptions is no longer silently replaced with "page".
  • With null_regex set, an empty field in a column that is not a string now fails to parse, and the missing fields of truncated rows are read the same way as empty fields. Neither the guide nor the CsvReadOptions docstring said so. The truncated_rows docstring still promised nulls.
  • CreateExternalCatalog and DropCatalog had no tests, because SessionContext.sql runs DDL right away and the DDL node never reaches to_variant().

What changes are included in this PR?

  • ParquetWriterOptions maps the parse errors for writer_version, compression, statistics_enabled and encoding with from_datafusion_error, so they raise ValueError. Column-specific options are still plain strings upstream and are checked when the file is written, so they are unchanged.
  • The upgrade guide gets a "Parquet writer settings are validated" section. The time zone section now mentions coerce_int96_tz, and the CSV null_regex section covers non-string columns and truncated rows. The null_regex and truncated_rows docstrings match.
  • Tests:
    • The existing ParquetWriterOptions error tests now expect ValueError, and test_write_parquet_with_options_invalid_statistics_enabled is new. These fail without the fix.
    • test_set_rejects_an_invalid_value pins the ValueError from SQL SET and SessionConfig.set that the guide describes.
    • test_drop_catalog, test_create_external_catalog and test_drop_catalog_schema plan the statement under EXPLAIN, which does not run it, and check the node's accessors. test_drop_catalog_schema replaces a test that was missing its test_ prefix and never ran.

python/tests/test_dataframe.py is skipped in CI at the moment, because pyarrow.cffi cannot be imported there, so the Parquet tests in this PR were run locally.

Are there any user-facing changes?

Yes. An invalid writer_version, compression, statistics_enabled or encoding in ParquetWriterOptions now raises ValueError from write_parquet_with_options. On 55.0.0, writer_version raised RuntimeError, compression and encoding raised Exception while writing, and an invalid statistics_enabled was ignored. Code that catches Exception is unaffected. The upgrade guide covers this, along with the other DataFusion 56 changes above.

andygrove and others added 3 commits December 5, 2026 16:24
DataFusion 56 made the global Parquet compression, statistics_enabled and
encoding options enums, and apache#1826 parsed them in the ParquetWriterOptions
constructor with py_datafusion_err. An invalid value therefore raised
RuntimeError with the Rust Debug string, for example
Configuration("Unknown or unsupported parquet compression: ..."), while
SessionConfig.set raised ValueError with a readable message for the same
setting.

Map all four parse errors, including writer_version, with
from_datafusion_error so they raise ValueError, as the comment on
SessionConfig.set asks for rejected values. Tighten the existing tests from
Exception to ValueError and cover statistics_enabled, which on 55 was
silently replaced with "page".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings that DataFusion 56 validates when they are set go beyond the time
zone. The Parquet compression, statistics_enabled and encoding options and
coerce_int96_tz are also rejected with ValueError by SQL SET and
SessionConfig.set, where 55 accepted them. Add that to the upgrade guide
along with the ParquetWriterOptions change, and pin the ValueError with a
test.

When null_regex is set, empty fields and the missing fields of truncated
rows are no longer null unless the pattern matches the empty string. In a
column that is not a string they now fail to parse. Say so in the upgrade
guide and in the CsvReadOptions docstring, which promised nulls for
truncated rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SessionContext.sql runs DDL right away, so its logical plan is an empty
relation and the DDL node never reaches to_variant(). EXPLAIN plans the
statement without running it, which makes CreateExternalCatalog and
DropCatalog testable after all. Use it for both, check their accessors, and
revive the drop_catalog_schema test, which lacked the test_ prefix and
never ran.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant