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] SortArray supports nested types #3715

Open
wbo4958 opened this issue Sep 30, 2021 · 2 comments
Open

[FEA] SortArray supports nested types #3715

wbo4958 opened this issue Sep 30, 2021 · 2 comments
Labels
cudf_dependency An issue or PR with this label depends on a new feature in cudf feature request New feature or request

Comments

@wbo4958
Copy link
Collaborator

wbo4958 commented Sep 30, 2021

Could we have the feature for supporting SortArray on nested types

repro

      val data = Seq(
        Row(Row("Adam ", "", "Green"), 1, "M", 10),
        Row(Row("Bob ", "Middle", "Green"), 2, "M", 20),
        Row(Row("Cathy ", "", "Green"), 3, "F", 30)
      )

      val schema = (new StructType()
        .add("name", new StructType()
          .add("firstname", StringType)
          .add("middlename", StringType)
          .add("lastname", StringType))
        .add("low", IntegerType)
        .add("gender", StringType)
        .add("high", IntegerType))

      val df = spark.createDataFrame(spark.sparkContext.parallelize(data), schema)
      df.write.format("parquet").mode("overwrite").save("/tmp/testparquet")

      val df2 = spark.read.parquet("/tmp/testparquet")
      df2.createOrReplaceTempView("df2")
      val df3 = spark.sql("SELECT sort_array(collect_set(struct(low,high))) FROM df2 group by gender")
      df3.explain(true)

explain log

!Exec <ObjectHashAggregateExec> cannot run on GPU because not all expressions can be replaced
  @Expression <AttributeReference> gender#18 could run on GPU
  @Expression <AttributeReference> gender#18 could run on GPU
  @Expression <AggregateExpression> collect_set(struct(low, low#17, high, high#19), 0, 0) could run on GPU
    @Expression <CollectSet> collect_set(struct(low, low#17, high, high#19), 0, 0) could run on GPU
      @Expression <CreateNamedStruct> struct(low, low#17, high, high#19) could run on GPU
        @Expression <Literal> low could run on GPU
        @Expression <AttributeReference> low#17 could run on GPU
        @Expression <Literal> high could run on GPU
        @Expression <AttributeReference> high#19 could run on GPU
  @Expression <AttributeReference> collect_set(struct(low, low#17, high, high#19), 0, 0)#24 could run on GPU
  @Expression <Alias> sort_array(collect_set(struct(low, low#17, high, high#19), 0, 0)#24, true) AS sort_array(collect_set(struct(low, high)), true)#25 could run on GPU
    !Expression <SortArray> sort_array(collect_set(struct(low, low#17, high, high#19), 0, 0)#24, true) cannot run on GPU because array expression AttributeReference collect_set(struct(low, low#17, high, high#19), 0, 0)#24 (child StructType(StructField(low,IntegerType,true), StructField(high,IntegerType,true)) is not supported); expression SortArray sort_array(collect_set(struct(low, low#17, high, high#19), 0, 0)#24, true) produces an unsupported type ArrayType(StructType(StructField(low,IntegerType,true), StructField(high,IntegerType,true)),false)
      @Expression <AttributeReference> collect_set(struct(low, low#17, high, high#19), 0, 0)#24 could run on GPU
      @Expression <Literal> true could run on GPU
  *Exec <ShuffleExchangeExec> will run on GPU
    *Partitioning <HashPartitioning> will run on GPU
    *Exec <ObjectHashAggregateExec> will run on GPU. The data type of following expressions will be converted in GPU runtime: buf#28: Converted BinaryType to ArrayType(StructType(StructField(low,IntegerType,true), StructField(high,IntegerType,true)),false)
      *Expression <AggregateExpression> partial_collect_set(struct(low, low#17, high, high#19), 0, 0) will run on GPU
        *Expression <CollectSet> collect_set(struct(low, low#17, high, high#19), 0, 0) will run on GPU
          *Expression <CreateNamedStruct> struct(low, low#17, high, high#19) will run on GPU
      *Exec <FileSourceScanExec> will run on GPU
@wbo4958 wbo4958 added feature request New feature or request ? - Needs Triage Need team to review and classify labels Sep 30, 2021
@sameerz sameerz added cudf_dependency An issue or PR with this label depends on a new feature in cudf and removed ? - Needs Triage Need team to review and classify labels Oct 5, 2021
@NVnavkumar
Copy link
Collaborator

See cuDF issue: rapidsai/cudf#11222

@sameerz
Copy link
Collaborator

sameerz commented Jan 10, 2023

Depends on #7485 and #5430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cudf_dependency An issue or PR with this label depends on a new feature in cudf feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants