Skip to content

Honor suffix in ParquetExampleIO legacy read - #5998

Open
Dev-next-gen wants to merge 1 commit into
spotify:mainfrom
Dev-next-gen:parquet-example-legacy-suffix
Open

Dev-next-gen wants to merge 1 commit into
spotify:mainfrom
Dev-next-gen:parquet-example-legacy-suffix

Conversation

@Dev-next-gen

Copy link
Copy Markdown

I noticed that ParquetExampleIO.readLegacy hands the raw path to GcsConnectorUtil.setInputPaths, while the SDF read in the same file, and the legacy reads in ParquetAvroIO and ParquetTypeIO, all go through ScioUtil.filePattern(path, params.suffix) first. So with scio.parquet.read.useSplittableDoFn -> false (or on Dataflow with Runner V2 disabled, where this path is picked by default), parquetExampleFile(dir, suffix = ".parquet") ignores the suffix, and Hadoop opens every non-hidden file in the directory as Parquet.

To check it, I wrote 10 Examples with saveAsParquetExampleFile, dropped a README.txt next to the part files, and read the directory back with suffix = ".parquet" in both modes. I ran this against the published 0.15.9 artifacts (the file is unchanged between v0.15.9 and main), compiling ParquetExampleIO.scala from main on top of them, then the patched version:

before
RESULT useSplittableDoFn=true -> count=10
RESULT useSplittableDoFn=false -> FAILED RuntimeException: file:/tmp/scio-example-.../out/README.txt is not a Parquet file. Expected magic number at tail, but found [105, 108, 101, 10]
after
RESULT useSplittableDoFn=true -> count=10
RESULT useSplittableDoFn=false -> count=10

The read-side DefaultSuffix is null, so filePattern returns the path unchanged when no suffix is given, and existing calls that pass a glob behave as before. I added a test to ParquetExampleIOTest covering the legacy read with an unrelated file in the directory. I didn't have sbt on hand, so the proof above comes from that standalone harness and I haven't run the sbt suite itself; CI should cover that.

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.

The HadoopFormatIO-based read passed the raw path to setInputPaths, so
the suffix was ignored and every non-hidden file in the directory was
opened as Parquet. Build the file pattern the same way the SDF read and
the Avro and typed legacy reads already do.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant