Skip to content

fix(azure-source): make Parquet input work and stop truncating blobs - #656

Open
szinczen wants to merge 4 commits into
Aiven-Open:mainfrom
szinczen:fix/azure-source-parquet
Open

szinczen wants to merge 4 commits into
Aiven-Open:mainfrom
szinczen:fix/azure-source-parquet

Conversation

@szinczen

Copy link
Copy Markdown

Fixes #653 and fixes silent truncation of blobs in the Azure source connector.

Problems

  1. Parquet cannot be read from the distribution (Azure/S3 source: input.format=parquet fails with NoClassDefFoundError – hadoop-mapreduce-client-core missing from runtime distribution #653). hadoop-mapreduce-client-core was only a test dependency, so the reader fails with NoClassDefFoundError: org/apache/hadoop/mapreduce/lib/input/FileInputFormat. Because only RuntimeException is logged in the polling thread, the connector log shows just polling thread has died.
  2. Blobs are truncated (all input formats). AzureBlobSourceRecordIterator wraps only downloadStream().blockFirst(). Adding the missing jar alone is therefore not enough: in my test, ~100 MB Parquet files then produced 0 records and the read carried on without failing.
  3. getAzureBlobStream(offset) passes a blob name as the second argument of listBlobs, which is a service continuation token.

Changes (one commit each)

  • Ship hadoop-mapreduce-client-core as a non-transitive runtimeOnly dependency of commons. This adds the jar to the distributions of all source and sink connectors that depend on commons.
  • Log Errors thrown in the source polling thread, then rethrow them.
  • Download the whole blob to a temporary file (downloadToFile), deleted when the stream is closed, so the blob is not held in memory.
  • Apply "start after this blob" by filtering on the blob name instead of passing it as a continuation token. This lists the whole prefix and filters on the client side.

Parquet input now needs temporary disk space of roughly twice the file size per task, because ParquetTransformer makes its own temporary copy.

Testing

  • ./gradlew build -x integrationTest (Windows, JDK 21): everything passes except S3SinkConfigTest.wrongPartSize(), which also fails for me on unmodified main (c7289ad).
  • Integration tests were not run.
  • Added unit tests for the offset filtering and for openBlob (complete content, temporary file removed after close and after a failed download).
  • End-to-end check, done on fb275fe before rebasing (the commits in between do not touch the changed files): the real AzureBlobSourceRecordIterator with the jars from the built distribution (plus Kafka Connect 3.3.1 API/runtime) against Azurite. No Kafka Connect worker, converter or producer, and no real Azure account.
    • 3 Parquet files of 105-133 MB, 2,750,000 rows. Before (with only the missing jar added): 0 records. After: 2,750,000 records, no missing or duplicate ids, content verified per row, with -Xmx512m and with -Xmx256m.
    • input.format=bytes: before, larger blobs were cut to about 1.2 KB; after, the reassembled chunks match the SHA-256 of each original.
    • Smaller files with snappy, zstd, gzip and no compression also read completely.
  • The listing change (3) could not be reproduced with Azurite, which accepted the blob name as a marker. It is based on the SDK method signature and the meaning of continuation tokens.

Not addressed

Read failures that are caught inside Transformer / ParquetTransformer are logged and do not fail the task. For example, a damaged Parquet file produced 0 records in my test without failing. From reading the code, a failure in the middle of a file may also leave it marked as processed. Changing this affects all source connectors, so I left it out of this PR.

🤖 Generated with Claude Code

szinczen and others added 4 commits November 27, 2026 11:34
parquet-java loads org.apache.hadoop.mapreduce.lib.input.FileInputFormat when a reader is built. The jar was only a test dependency, so input.format=parquet failed with NoClassDefFoundError in the released distribution. Fixes Aiven-Open#653.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Only RuntimeException was logged, so an Error such as NoClassDefFoundError surfaced only as 'polling thread has died'. The Error is logged and rethrown.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The input stream wrapped only downloadStream().blockFirst(), silently truncating blobs. The blob is now downloaded to a temporary file that is deleted when the stream is closed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The second argument of listBlobs is an opaque continuation token returned by the service. Listing from an offset now filters by blob name.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@szinczen
szinczen requested a review from a team as a code owner November 27, 2026 10:36
@aindriu-aiven

Copy link
Copy Markdown
Contributor

@szinczen thank you for this, I will review hopefully later today

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.

Azure/S3 source: input.format=parquet fails with NoClassDefFoundError – hadoop-mapreduce-client-core missing from runtime distribution

2 participants