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] Let Scalar Pandas UDF support array of struct type. #1912

Closed
firestarman opened this issue Mar 11, 2021 · 2 comments · Fixed by #1944
Closed

[FEA] Let Scalar Pandas UDF support array of struct type. #1912

firestarman opened this issue Mar 11, 2021 · 2 comments · Fixed by #1944
Assignees
Labels
feature request New feature or request

Comments

@firestarman
Copy link
Collaborator

firestarman commented Mar 11, 2021

Is your feature request related to a problem? Please describe.
I wish the RAPIDS Accelerator for Apache Spark would support running Scalar Pandas UDF with array type as input, then it can work with collect_list, such as the app code as below.

@pandas_udf(returnType=IntegerType())
def pandas_udf_func(windows: pd.Series) -> pd.Series:
    return pd.Series([1]).repeat(windows.size)

spark.sql("SELECT pandas_udf_func( collect_list( struct(a, b)) ) AS ret_list FROM a_table")
@firestarman firestarman added feature request New feature or request ? - Needs Triage Need team to review and classify labels Mar 11, 2021
@firestarman firestarman self-assigned this Mar 11, 2021
@firestarman
Copy link
Collaborator Author

firestarman commented Mar 11, 2021

Now the cuDF complains the error as below when transfering data to Python. Looks like cudf does not handle struct data well.

Caused by: ai.rapids.cudf.CudfException: cuDF failure at: /home/liangcail/work/projects/on_github/cudf/cpp/src/interop/to_arrow.cpp:207: Number of field names and number of children doesn't match

	at ai.rapids.cudf.Table.convertCudfToArrowTable(Native Method)
	at ai.rapids.cudf.Table.access$1500(Table.java:46)
	at ai.rapids.cudf.Table$ArrowIPCTableWriter.write(Table.java:1010)
	at org.apache.spark.sql.rapids.execution.python.GpuArrowPythonRunner$$anon$2.$anonfun$writeIteratorToStream$5(GpuArrowEvalPythonExec.scala:455)
	at org.apache.spark.sql.rapids.execution.python.GpuArrowPythonRunner$$anon$2.$anonfun$writeIteratorToStream$5$adapted(GpuArrowEvalPythonExec.scala:453)
	at com.nvidia.spark.rapids.Arm.withResource(Arm.scala:28)
	at com.nvidia.spark.rapids.Arm.withResource$(Arm.scala:26)

@firestarman firestarman changed the title [FEA] Let Scalar Pandas UDF support array type. [FEA] Let Scalar Pandas UDF support array of struct type. Mar 11, 2021
@firestarman
Copy link
Collaborator Author

Filed an issue rapidsai/cudf#7570 for the exception above.

firestarman added a commit that referenced this issue Mar 24, 2021
This PR is to support running scalar pandas UDF with array type.

Add array type signature for related expressions and plans.
Flatten the names of nested struct columns from schema, which is also required by the cudf Arrow IPC writer.
This PR depends on rapidsai/cudf#7598

closes #1912

Signed-off-by: Firestarman <[email protected]>
@sameerz sameerz removed the ? - Needs Triage Need team to review and classify label Apr 8, 2021
nartal1 pushed a commit to nartal1/spark-rapids that referenced this issue Jun 9, 2021
This PR is to support running scalar pandas UDF with array type.

Add array type signature for related expressions and plans.
Flatten the names of nested struct columns from schema, which is also required by the cudf Arrow IPC writer.
This PR depends on rapidsai/cudf#7598

closes NVIDIA#1912

Signed-off-by: Firestarman <[email protected]>
nartal1 pushed a commit to nartal1/spark-rapids that referenced this issue Jun 9, 2021
This PR is to support running scalar pandas UDF with array type.

Add array type signature for related expressions and plans.
Flatten the names of nested struct columns from schema, which is also required by the cudf Arrow IPC writer.
This PR depends on rapidsai/cudf#7598

closes NVIDIA#1912

Signed-off-by: Firestarman <[email protected]>
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.

2 participants