Registry Mirror
Skip to content

tpch conversion generates parquet files that cannot be queried on simple predicates #863

Closed

Description

@andygrove

Describe the bug

I converted tpch csv files to parquet and found that I cannot query with simple predicate on a string column.

> create external table customer stored as parquet location '/mnt/bigdata/tpch-sf1000-parquet/customer';
0 rows in set. Query took 0.000 seconds.

> SELECT c_mktsegment, COUNT(*) FROM customer GROUP BY c_mktsegment;
+--------------+-----------------+
| c_mktsegment | COUNT(UInt8(1)) |
+--------------+-----------------+
| HOUSEHOLD    | 30003565        |
| BUILDING     | 29998146        |
| FURNITURE    | 29999758        |
| MACHINERY    | 30003128        |
| AUTOMOBILE   | 29995355        |
+--------------+-----------------+
5 rows in set. Query took 0.758 seconds.

> SELECT concat('[', c_mktsegment, ']') from customer limit 5;
+------------------------------------------+
| concat(Utf8("["),c_mktsegment,Utf8("]")) |
+------------------------------------------+
| [MACHINERY]                              |
| [HOUSEHOLD]                              |
| [BUILDING]                               |
| [AUTOMOBILE]                             |
| [HOUSEHOLD]                              |
+------------------------------------------+
5 rows in set. Query took 0.028 seconds.

> SELECT COUNT(*) FROM customer WHERE c_mktsegment = 'BUILDING';
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 0               |
+-----------------+
1 row in set. Query took 0.398 seconds.

> SELECT COUNT(*) FROM customer WHERE c_mktsegment = 'HOUSEHOLD';
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 0               |
+-----------------+
1 row in set. Query took 0.386 seconds.

> SELECT COUNT(*) FROM customer WHERE c_mktsegment LIKE 'HOUSEHOLD';
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 30003565        |
+-----------------+
1 row in set. Query took 0.663 seconds.

The odd thing is that I see the behavior when querying from Spark, so I guess something is wrong with the parquet file.

scala> spark.sql("SELECT c_mktsegment, COUNT(*) FROM customer GROUP BY c_mktsegment").show
+------------+--------+                                                         
|c_mktsegment|count(1)|
+------------+--------+
|   MACHINERY|30003128|
|  AUTOMOBILE|29995355|
|    BUILDING|29998146|
|   HOUSEHOLD|30003565|
|   FURNITURE|29999758|
+------------+--------+


scala> spark.sql("SELECT COUNT(*) FROM customer WHERE c_mktsegment = 'BUILDING'").show
+--------+
|count(1)|
+--------+
|       0|
+--------+

To Reproduce
Run the above queries in datafusion-cli

Expected behavior
Simple predicates should work.

Additional context
The parquet files were generated by the conversion utility in the tpch benchmarks.

Activity

  1. added
    bug
    on Aug 11, 2021
  2. changed the title [-]Simple predicates against Parquet relations are not working[/-] [+]tpch conversion generates parquet files that cannot be queried on simple predicates[/+] on Aug 11, 2021
  3. andygrove commented on Aug 12, 2021

    @andygrove
    MemberAuthor

    If I comment out the code in our parquet reader that filters out row groups based on predicates then I see the expected results.

    > SELECT COUNT(*) FROM customer WHERE c_mktsegment = 'BUILDING';
    +-----------------+
    | COUNT(UInt8(1)) |
    +-----------------+
    | 29998146        |
    +-----------------+
    1 row in set. Query took 0.874 seconds.
    

    My conclusion is that we have a bug in our DataFusion/Parquet writer where we are writing incorrect statistics somehow.

  4. houqp commented on Aug 12, 2021

    @houqp
    Member

    Might be related to apache/arrow-rs#643. Have you tried running it with arrow master?

  5. andygrove commented on Aug 12, 2021

    @andygrove
    MemberAuthor

    Thanks @houqp yes that is it. I tested with Arrow master and it works. Perhaps we can put out a patch release on DataFusion/Ballista at some point soon with this fix.

  6. houqp commented on Aug 12, 2021

    @houqp
    Member

    Yep, once arrow 5.2 release is out, i will start a patch release for datafusion.

  7. alamb commented on Aug 12, 2021

    @alamb
    Contributor

    I plan to make an arrow-rs 5.2.0 RC this afternoon. The cool thing about using sem-ver versioning is that cargo update should be sufficient to get the fix for arrow without any changes to datafusion

    If we want to ensure anyone running datafuson is also using at least arrow 5.2.0 (and thus has the fix for apache/arrow-rs#643) we would need a new datafusion release

  8. houqp commented on Aug 13, 2021

    @houqp
    Member

    That's a very good point @alamb :D This certainly makes me less stressed about the patch release.

    UPDATE: actually, i take it back, looks like datafusion currently has arrow pinned to 5.1 :(

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions