Skip to content

Commit 18121a6

Browse files
2010YOUY01alamb
andauthored
minor: validate config soft_max_rows_per_output_file when setting it (#23597)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Part of #17498 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> This is logically the same change as #23592, but for another configuration. 0 is a invalid setting here, and such value might cause very large output file count. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> Co-authored-by: Andrew Lamb <[email protected]>
1 parent a8f5480 commit 18121a6

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎datafusion/common/src/config.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ config_namespace! {
873873
/// This is a soft max, so it can be exceeded slightly. There also
874874
/// will be one file smaller than the limit if the total
875875
/// number of rows written is not roughly divisible by the soft max
876-
pub soft_max_rows_per_output_file: usize, default = 50000000
876+
pub soft_max_rows_per_output_file: ConfigNonZeroUsize, default = non_zero_usize_default(50000000)
877877

878878
/// This is the maximum number of RecordBatches buffered
879879
/// for each output file being worked. Higher values can potentially

‎datafusion/datasource/src/write/demux.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async fn row_count_demuxer(
153153
) -> Result<()> {
154154
let exec_options = &context.session_config().options().execution;
155155

156-
let max_rows_per_file = exec_options.soft_max_rows_per_output_file;
156+
let max_rows_per_file = exec_options.soft_max_rows_per_output_file.get();
157157
let max_buffered_batches = exec_options.max_buffered_batches_per_output_file;
158158
let minimum_parallel_files = exec_options.minimum_parallel_output_files;
159159
let mut part_idx = 0;

‎datafusion/sqllogictest/test_files/set_variable.slt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ SET datafusion.runtime.list_files_cache_ttl = '1m18446744073709551556s'
724724
statement error DataFusion error: Invalid or Unsupported Configuration: value must be greater than 0
725725
SET datafusion.execution.batch_size = 0
726726

727+
statement error DataFusion error: Invalid or Unsupported Configuration: value must be greater than 0
728+
SET datafusion.execution.soft_max_rows_per_output_file = 0
729+
727730
statement error DataFusion error: Invalid or Unsupported Configuration: value must be greater than 0
728731
SET datafusion.execution.max_spill_file_size_bytes = 0
729732

0 commit comments

Comments
 (0)