Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEA] Support Count on Struct of [ Struct of [String, Map(String,String)], Array(String), Map(String,String) ] #5060

Closed
viadea opened this issue Mar 25, 2022 · 1 comment · Fixed by #5132
Assignees
Labels
feature request New feature or request

Comments

@viadea
Copy link
Collaborator

viadea commented Mar 25, 2022

I wish we can support Count on Struct of [ Struct of [String, Map(String,String)], Array(String), Map(String,String) ].

Example:

import org.apache.spark.sql.Row
import org.apache.spark.sql.types._

val data = Seq(
    Row("Adam",  Row( Row("address" , Map("state"->"CA")), List("Java","Scala","C++"),  Map("hair"->"black","eye"->"black") )       ),
    Row("Bob",   Row( Row("address" , Map("state"->"NY")), List("Java","Python","C++"), Map("hair"->"red","eye"->"black") )       ),
    Row("Cathy", Row( Row("address" , Map("state"->"CO")), List("Java","C++"),          Map("hair"->"yellow","eye"->"black") )       )
)

val mapType  = DataTypes.createMapType(StringType,StringType)

val schema = new StructType()
                .add("name",StringType)
                .add("prop", new StructType().add("prop2",new StructType()
                                                                .add("propname",StringType)
                                                                .add("propvalue",mapType) 
                                                 )
                                               .add("language", ArrayType(StringType))
                                               .add("bio", mapType)
                     )         

val nestedDF = spark.createDataFrame(spark.sparkContext.parallelize(data),schema)
nestedDF.write.format("parquet").mode("overwrite").save("/tmp/testparquet")
val df1 = spark.read.parquet("/tmp/testparquet")
df1.createOrReplaceTempView("df1")
df1.printSchema

spark.sql("SELECT count(prop) FROM df1").collect()

Not-Supported messages:

        !Expression <Count> count(prop#364) cannot run on GPU because input expression AttributeReference prop#364 (child StructType(StructField(propname,StringType,true), StructField(propvalue,MapType(StringType,StringType,true),true)) is not supported, child ArrayType(StringType,true) is not supported, child MapType(StringType,StringType,true) is not supported)
@viadea viadea added feature request New feature or request ? - Needs Triage Need team to review and classify labels Mar 25, 2022
@revans2
Copy link
Collaborator

revans2 commented Mar 25, 2022

We should be able to make this work for any data type. In the worst case we can rewrite it to the equivalent of SUM(isNull(prop))

@sameerz sameerz removed the ? - Needs Triage Need team to review and classify label Mar 29, 2022
@HaoYang670 HaoYang670 self-assigned this Mar 31, 2022
@sameerz sameerz added this to the Apr 4 - Apr 15 milestone Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants