Skip to content

[SQL] Row-based Parquet reader silently accepts incompatible primitive type conversions #58495

Description

@Jiayi-Wang-db

Problem

Spark's row-based Parquet reader and vectorized Parquet reader handle some incompatible requested
schemas differently. The vectorized reader raises SchemaColumnConvertNotSupportedException, while
the row-based reader silently interprets the physical value as the requested Catalyst type.

Two examples are:

Parquet file type Requested Spark type Row-based reader Vectorized reader
FIXED_LEN_BYTE_ARRAY(4) STRING Returns the raw bytes as UTF-8 Rejects the conversion
INT32 (DATE) DECIMAL(10, 0) Returns the day count as a decimal Rejects the conversion

The row reader's ParquetRowConverter currently accepts every binary-like primitive as a string
and treats any INT32 or INT64 without decimal metadata as an unannotated integer-backed
decimal. The latter ignores semantic logical annotations such as DATE.

This is a correctness problem because changing spark.sql.parquet.enableVectorizedReader can
change a query from failing cleanly to returning incorrectly interpreted data.

Expected behavior

Both readers should reject these unsupported conversions with
FAILED_READ_FILE.PARQUET_COLUMN_DATA_TYPE_MISMATCH.

Supported conversions should remain unchanged, including Parquet BINARY to Spark STRING and
unannotated or signed-integer INT32/INT64 to a sufficiently compatible Spark decimal type.

Related discussions

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions