Skip to content

Fixes to Spark API show() and udf.register()#550

Open
Shooter23 wants to merge 2 commits into
duckdb:mainfrom
Shooter23:main
Open

Fixes to Spark API show() and udf.register()#550
Shooter23 wants to merge 2 commits into
duckdb:mainfrom
Shooter23:main

Conversation

@Shooter23

Copy link
Copy Markdown

Match signature to Spark API's show() method to PySpark's and translate parameters to DuckDB's show().

Fix call to create_function() in Spark API's UDFRegistration.register(). It lacked the correct third argument (input parameters, set to None). It assumes a PySpark style return type parameter (eg T.StringType()) and translates it to the DuckDB SQL type for the create_function() call. Sets null_handling='special' to match PySpark UDF behavior.

Match Spark API show() signature to PySpark's.
Convert (more or less) show() parameters to DuckDB show() parameters.
  - n -> max_rows
  - truncate -> max_col_width (not quite the same)
  - vertical -> render_mode='COLUMNS' (not quite the same)
Call to create_function() under Spark API udf.register() fixes:
  - Pass None for third (function parameters) argument.
  - Assume udf.register() receives a PySpark return type.
  - Convert to DuckDB return type for create_function() call.
PySpark UDFs take nulls as valid input.
Vis-a-vis other UDF options (exception handling and side effects)
PySpark UDFs behave like the DuckDB defaults.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant