Zoltán Borók-Nagy created IMPALA-15847:
------------------------------------------

             Summary: Parquet scanner doesn't validate PLAIN-encoded DATE values
                 Key: IMPALA-15847
                 URL: https://issues.apache.org/jira/browse/IMPALA-15847
             Project: IMPALA
          Issue Type: Bug
          Components: Backend
            Reporter: Zoltán Borók-Nagy
            Assignee: Zoltán Borók-Nagy


The Parquet scanner decodes batches of PLAIN-encoded DATE values with a plain 
memcpy (the generic ParquetPlainEncoder::DecodeNoBoundsCheck), which skips the 
range check of the DateValue constructor. Values outside 0001-01-01..9999-12-31 
are therefore not marked invalid: there is no "out of range date" warning, 
ABORT_ON_ERROR=1 doesn't fail the query, and the slot isn't set to NULL. The 
interpreted SlotRef re-checks the range and returns NULL, but codegen'd 
expressions use the raw value, so results depend on codegen.

Example on master bb5e81da51: a Spark-written Parquet file whose PLAIN-encoded 
DATE column dt holds 0000-12-31, +10000-01-01, 0001-01-01, 9999-12-31, 
2024-05-01 and NULL.
{noformat}
                                  codegen on   DISABLE_CODEGEN=true
SELECT dt                         NULL for the first two rows in both
count(*) WHERE dt IS NULL         1            3
count(*) WHERE dt IS NOT NULL     5            3
count(*) WHERE dt < '2000-01-01'  2            1
{noformat}
Dictionary-encoded files, like testdata/data/out_of_range_date.parquet, are not 
affected, because dictionary values are decoded with the range check.

Fix: validate DATE values in the batched PLAIN decoder, for example with a 
DecodeNoBoundsCheck specialization that constructs the DateValue. INT64 
timestamps with isAdjustedToUTC=true have the same symptom when the 
UTC-to-local conversion moves them out of range, which is IMPALA-7862.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to