GitHub user vanzin opened a pull request:

    https://github.com/apache/spark/pull/14272

    [SPARK-16632][sql] Respect Hive schema when merging parquet schema.

    When Hive (or at least certain versions of Hive) creates parquet files
    containing tinyint or smallint columns, it stores them as int32, but
    doesn't annotate the parquet field as containing the corresponding
    int8 / int16 data. When Spark reads those files using the vectorized
    reader, it follows the parquet schema for these fields, but when
    actually reading the data it tries to use the type fetched from
    the metastore, and then fails because data has been loaded into the
    wrong fields in OnHeapColumnVector.
    
    So instead of blindly trusting the parquet schema, check whether the
    Catalyst-provided schema disagrees with it, and adjust the types so
    that the necessary metadata is present when loading the data into
    the ColumnVector instance.
    
    Tested with unit tests and with tests that create byte / short columns
    in Hive and try to read them from Spark.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/vanzin/spark SPARK-16632

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/14272.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #14272
    
----
commit d853ba0769189b0557d801b9e3e1ed1a9d65cea9
Author: Marcelo Vanzin <[email protected]>
Date:   2016-07-19T22:51:16Z

    [SPARK-16632][sql] Respect Hive schema when merging parquet schema.
    
    When Hive (or at least certain versions of Hive) creates parquet files
    containing tinyint or smallint columns, it stores them as int32, but
    doesn't annotate the parquet field as containing the corresponding
    int8 / int16 data. When Spark reads those files using the vectorized
    reader, it follows the parquet schema for these fields, but when
    actually reading the data it tries to use the type fetched from
    the metastore, and then fails because data has been loaded into the
    wrong fields in OnHeapColumnVector.
    
    So instead of blindly trusting the parquet schema, check whether the
    Catalyst-provided schema disagrees with it, and adjust the types so
    that the necessary metadata is present when loading the data into
    the ColumnVector instance.
    
    Tested with unit tests and with tests that create byte / short columns
    in Hive and try to read them from Spark.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to