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

[BUG] ClassCastException in GpuStructsToJson #10477

Open
andygrove opened this issue Feb 22, 2024 · 1 comment
Open

[BUG] ClassCastException in GpuStructsToJson #10477

andygrove opened this issue Feb 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@andygrove
Copy link
Contributor

Describe the bug

spark.conf.set("spark.rapids.sql.expression.StructsToJson", true)

val df = Seq(Array("a", "b", "c"), Array("d", "e", "f")).toDF("a").repartition(2)
val df2 = df.select(to_json(col("a")).alias("my_json"))
df2.show(false)

Fails with:

Caused by: java.lang.ClassCastException: org.apache.spark.sql.types.ArrayType cannot be cast to org.apache.spark.sql.types.StructType
  at org.apache.spark.sql.rapids.GpuStructsToJson.doColumnar(GpuStructsToJson.scala:86)

Steps/Code to reproduce bug
See above

Expected behavior

With the plugin disabled, Spark produces the following output.

+-------------+
|my_json      |
+-------------+
|["a","b","c"]|
|["d","e","f"]|
+-------------+

Environment details (please complete the following information)
N/A

Additional context

@andygrove andygrove added bug Something isn't working ? - Needs Triage Need team to review and classify labels Feb 22, 2024
@andygrove
Copy link
Contributor Author

The same issue exists for Map. StructsToJson supports Structs, Arrays, and Map, but our implementation currently assumes Structs.

GpuStructsToJson:

GpuCast.castStructToJsonString(input.getBase, child.dataType.asInstanceOf[StructType].fields, ...

@mattahrens mattahrens removed the ? - Needs Triage Need team to review and classify label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants