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 collect_set on struct in reduction context #5095

Closed
viadea opened this issue Mar 30, 2022 · 2 comments
Closed

[FEA] Support collect_set on struct in reduction context #5095

viadea opened this issue Mar 30, 2022 · 2 comments
Labels
feature request New feature or request

Comments

@viadea
Copy link
Collaborator

viadea commented Mar 30, 2022

I wish we can support collect_set on struct in reduction context.

For example:

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

val data = Seq(
    Row("Adam",Map("hair"->"black","eye"->"black"), Row("address" , Map("state"->"CA"),Map("city"->"santa clara"))),
    Row("Bob",Map("hair"->"red","eye"->"red"),Row("address", Map("state"->"GA"),Map("city"->"abc"))),
    Row("Cathy",Map("hair"->"blue","eye"->"blue"),Row("address",Map("state"->"NC"),Map("city"->"xyz")))
)

val mapType  = DataTypes.createMapType(StringType,StringType)

val schema = new StructType().add("name",StringType).add("properties", mapType).add("prop2", new StructType().add("propname",StringType).add("address", mapType).add("address2", mapType))

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

spark.sql("SELECT collect_set(struct(name,name)) FROM df1").collect()

Not-supported-messages:

    !Exec <ObjectHashAggregateExec> cannot run on GPU because not all expressions can be replaced. The data type of following expressions will be converted in GPU runtime: buf#199: Converted BinaryType to ArrayType(StructType(StructField(name,StringType,true), StructField(name,StringType,true)),false)
      @Expression <AggregateExpression> partial_collect_set(struct(name, name#182, name, name#182), 0, 0) AS buf#199 could run on GPU
        !Expression <CollectSet> collect_set(struct(name, name#182, name, name#182), 0, 0) cannot run on GPU because input expression CreateNamedStruct struct(name, name#182, name, name#182) (StructType(StructField(name,StringType,true), StructField(name,StringType,true)) is not supported); expression CollectSet collect_set(struct(name, name#182, name, name#182), 0, 0) produces an unsupported type ArrayType(StructType(StructField(name,StringType,true), StructField(name,StringType,true)),false)
@viadea viadea added feature request New feature or request ? - Needs Triage Need team to review and classify labels Mar 30, 2022
@mattahrens mattahrens removed the ? - Needs Triage Need team to review and classify label Apr 5, 2022
@sperlingxx
Copy link
Collaborator

I think it is supported now as #4992 merged.

@viadea
Copy link
Collaborator Author

viadea commented Apr 13, 2022

confirmed it is working now using latest 2206 jars

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

No branches or pull requests

3 participants