Fix count() in avro failed when reader_types is coalescing #6225
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
spark.read.format("avro").load(data_path).count()
reports error:QueryExecutionException: Expected 0 columns but read 8 from ArrayBuffer
, if reader_types isCOALESCING
. It is because Avro reader always specifies the schema from a file when coalescing reading, causing it to always read all columns of data.This PR use readDataSchema instead the schema from a file to quick fix this bug.
Further, we should build an evolved schema from readschema and dataSchema to do type checking and filtering, just like orc reader and parquet reader do. We also use readschema when reading files from cudf now, so it will be a bit complicated to make this change. Filed a followed issue #6226 to track it.
Fixes #6131
Signed-off-by: thirtiseven ntlihy@gmail.com