Slice v1 scan batches for input_file_name() [databricks] #16794
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 640 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.387
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16794"
general
weight: 0.35
gerashegalov
Fixes #16743.
Short term fix for #13918.
Description
GpuInputFileNamebuilds its column withColumnVector.fromScalar(path, numRows), so a batch needsnumRows utf8PathBytesbytes of string data and cudf caps that at 2 GiB. A single scan batch with ~16M+ rows and a ~135-byte path fails withCudfColumnSizeOverflowException. Delta MERGE addsinput_file_name()itself, so users cannot avoid it, and reader batch size configs are soft limits that do not reliably prevent it. The only workaround today isspark.rapids.sql.expression.InputFileName=false.After these changes, when a v1 file scan (
GpuFileSourceScanExec) feeds a bareinput_file_name(), the scan slices any batch whoserows pathByteswould exceed the string limit into row slices of at mostmaxRowsrows (maxRows = max(1, (Int.MaxValue - 1MiB) / max(1, pathBytes))). Smaller batches pass through unchanged. The projection stays on the GPU. This covers the reported case: Delta MERGE and Spark's defaultuseV1SourceListboth use v1 scans.How it works:
InputFileBlockHolderonce per source batch. While slices are pending, the scan iterator does not touch the reader, so the path cannot change under us.slicecopies), so the source batch can be spilled or closed independently.InputFileNametrigger slicing, notinput_file_block_start/length.Not covered by this short term fix (to be tracked on #13918):
GpuBatchScanExec, e.g. Iceberg).concat(input_file_name(), 'x')orupper(input_file_name())(see the comment onHEADROOM_BYTES).input_file_name()._file, which the reader builds itself.Testing:
InputFileNameBatchSlicerSuite(unit) andInputFileNameLongPathSuite(end to end), plustest_parquet_input_file_name_sliced_large_batchandtest_delta_merge_input_file_name_sliced_large_batch. The suites cover:- slice boundaries, order and path capture across files of different path lengths;
- zero column batches;
- the source not being advanced while slices are pending;
- cleanup on abandon and on task completion;
- retry OOM;
- multi-byte paths;
- the Delta MERGE plan shape, with an inner
monotonically_increasing_id()project under an outerinput_file_name()project;- the PERFILE and MULTITHREADED Parquet readers (COALESCING falls back to MULTITHREADED when the query uses
input_file_name()).spark.rapids.sql.test.inputFileName.maxStringBytes) and assert batch counts, so they fail if slicing is disabled. An earlier, larger Delta MERGE run (not included in this PR because it needs gigabytes of GPU memory) reproduced the originalCudfColumnSizeOverflowExceptionwithout the fix.InputFileNameLongPathSuiteruns in theen_US.UTF-8premerge step because one test uses a multi-byte directory name. That test is skipped whensun.jnu.encodingis not UTF-8.sql-pluginalso compiles on Scala 2.13 with Spark 4.1.1. Databricks is not verified locally;[databricks]is in the title so the MERGE test runs there.Performance (Spark2a, 8 workers, NDS sf3k, GPU old jar vs new jar, 10 runs per jar, no slicing triggered): the median run time of each
input_file_name()query was within 1.5% between the two jars, and the differences were not statistically significant (p ≥ 0.2). A control query with no input file expression was also unchanged (5848 vs 5846 ms over 16 runs per jar, p = 0.75). With default 2 GB partitions, where slicing did fire on the new jar, the old jar fails three string queries withCudfColumnSizeOverflowExceptionand the new jar completes them (3.9, 2.9 and 4.2 s; one run, earlier build). The cost of slicing itself (each slice is a copy of its rows) was not separately measured, and Delta MERGE was not timed. The timings were taken before the trigger was narrowed toinput_file_name().Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance