Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions duckdb/experimental/spark/sql/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,26 @@ def __init__(self, relation: duckdb.DuckDBPyRelation, session: "SparkSession") -
if self.relation is not None:
self._schema = duckdb_to_spark_schema(self.relation.columns, self.relation.types)

def show(self, **kwargs) -> None: # noqa: D102
self.relation.show()
def show(
self,
n: int = 20,
truncate: Union[bool, int] = True,
vertical: bool = False,
) -> None: # noqa: D102
if isinstance(truncate, int):
max_col_width = truncate
elif truncate:
max_col_width = 20
else:
max_col_width = 9999

render_mode = 'COLUMNS' if vertical else None

self.relation.show(
max_rows=n,
max_col_width=max_col_width,
render_mode=render_mode
)

def toPandas(self) -> "PandasDataFrame": # noqa: D102
return self.relation.df()
Expand Down
8 changes: 7 additions & 1 deletion duckdb/experimental/spark/sql/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ def register( # noqa: D102
f: "Callable[..., Any] | UserDefinedFunctionLike",
returnType: Optional["DataTypeOrString"] = None,
) -> "UserDefinedFunctionLike":
self.sparkSession.conn.create_function(name, f, return_type=returnType)
self.sparkSession.conn.create_function(
name,
f,
None,
return_type=returnType.duckdb_type if returnType else None,
null_handling='special',
)

def registerJavaFunction( # noqa: D102
self,
Expand Down