register_spark_dataframe_namespace
laktory.api.register_spark_dataframe_namespace(name)
ยค
Decorator for registering a custom namespace on PySpark's DataFrame class.
The decorated class receives the native PySpark DataFrame as its first
__init__ argument, so its methods are written in pure PySpark without
any Narwhals knowledge.
Use with DATAFRAME_API=NATIVE in pipeline YAML.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Namespace name, used as
TYPE:
|
Examples:
import pyspark.sql.functions as F
import laktory as lk
@lk.api.register_spark_dataframe_namespace("custom")
class CustomOps:
def __init__(self, _df):
self._df = _df
def with_x2(self):
return self._df.withColumn("x2", F.col("x1") * 2)
transformer:
nodes:
- func_name: custom.with_x2
dataframe_api: NATIVE
References
Source code in laktory/api/namespace.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |