You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "colin fang (JIRA)" <ji...@apache.org> on 2019/03/20 13:47:00 UTC

[jira] [Created] (SPARK-27217) Nested schema pruning doesn't work for aggregation e.g. `sum`.

colin fang created SPARK-27217:
----------------------------------

             Summary: Nested schema pruning doesn't work for aggregation e.g. `sum`.
                 Key: SPARK-27217
                 URL: https://issues.apache.org/jira/browse/SPARK-27217
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 2.4.0
            Reporter: colin fang


Since SPARK-4502 is fixed,  I would expect queries such as `select sum(b.x)` doesn't have to read other nested fields.

{code:python}   
 rdd = spark.range(1000).rdd.map(lambda x: [x.id+3, [x.id+1, x.id-1]])
    df = spark.createDataFrame(, schema='a:int,b:struct<x:int,y:int>')
    df.repartition(1).write.mode('overwrite').parquet('test.parquet')
    df = spark.read.parquet('test.parquet')

    spark.conf.set('spark.sql.optimizer.nestedSchemaPruning.enabled', 'true')
    df.select('b.x').explain()
    # ReadSchema: struct<b:struct<x:int>>

    spark.conf.set('spark.sql.optimizer.nestedSchemaPruning.enabled', 'false')
    df.select('b.x').explain()
    # ReadSchema: struct<b:struct<x:int,y:int>>

    spark.conf.set('spark.sql.optimizer.nestedSchemaPruning.enabled', 'true')
    df.selectExpr('sum(b.x)').explain()
    #  ReadSchema: struct<b:struct<x:int,y:int>>
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org