Skip to content

[SPARK-59143] Close remaining PySpark 4.2.0 Spark Connect public-API parity gaps - #95

Closed
HyukjinKwon wants to merge 2 commits into
apache:masterfrom
HyukjinKwon:SPARK-59143-close-connect-parity-gaps
Closed

[SPARK-59143] Close remaining PySpark 4.2.0 Spark Connect public-API parity gaps#95
HyukjinKwon wants to merge 2 commits into
apache:masterfrom
HyukjinKwon:SPARK-59143-close-connect-parity-gaps

Conversation

@HyukjinKwon

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Closes the remaining PySpark 4.2.0 Spark Connect public-API parity gaps found by a
close inspect.signature diff of the drop-in against the reference pyspark==4.2.0
Connect client.

Import-path gaps — thin re-export shims, same pattern as the existing
connect/dataframe.py:

  • New pyspark.sql.connect.* submodules: catalog, conf, group, window,
    readwriter, tvf, udf, udtf, observation, merge,
    streaming.readwriter, streaming.query. The reference client and the official
    Connect test suite import from these paths, which previously raised ImportError.
  • New public pyspark.sql.conf (exposing RuntimeConfig, aliasing the Connect
    RuntimeConf) and pyspark.sql.tvf modules.

Signature gaps vs the reference Connect client:

  • StructType.treeString gains the maxDepth parameter (default 2147483647),
    wired through a new DataType::tree_string_with_depth in the core;
    tree_string() is preserved for existing callers.
  • StructType.fromJson / StructField.fromJson parameter renamed datajson.
  • TableValuedFunction.json_tuple / stack now take varargs *fields.
  • VariantType.toInternal parameter renamed objvariant.

The pyspark.sql.functions surface was already at full parity (all 529 reference
functions, no signature mismatches) and is unchanged.

Why are the changes needed?

The package advertises drop-in parity with the PySpark 4.2.0 Spark Connect client.
These were the residual deviations where reference-valid imports and calls could
break.

Does this PR introduce any user-facing change?

Yes, additive: previously-failing imports now resolve, and the four methods above
accept the reference parameter names/forms.

How was this patch tested?

New offline tests in python/tests/test_dropin_offline.py:

  • test_connect_submodule_import_paths (14 paths) — passes against the built extension.
  • Behavior tests for treeString(maxDepth), fromJson(json=...), and
    VariantType.toInternal(variant=...) — validated against reference
    pyspark==4.2.0 to confirm they encode the correct behavior; they exercise the
    rebuilt extension under CI.

The Rust changes were authored but not compiled on the dev box (offline); the
build + official Connect suite in CI is the build/behavior gate.

This pull request and its description were written by Isaac.

…parity gaps

A close introspection diff of the drop-in against the reference pyspark==4.2.0
Spark Connect client surfaced a small set of remaining public-API gaps. Close them.

Import-path gaps (thin re-export shims mirroring the existing connect/dataframe.py):
- Add the missing pyspark.sql.connect.* submodules: catalog, conf, group, window,
  readwriter, tvf, udf, udtf, observation, merge, streaming.readwriter,
  streaming.query. Reference code and the official Connect test suite import from
  these paths.
- Add the public pyspark.sql.conf (RuntimeConfig, aliasing the Connect RuntimeConf)
  and pyspark.sql.tvf modules.

Signature gaps vs reference:
- StructType.treeString gains the maxDepth parameter (default 2147483647), wired
  through a new DataType::tree_string_with_depth in the core; tree_string() is kept.
- StructType/StructField.fromJson parameter renamed data -> json.
- TableValuedFunction.json_tuple / stack now take varargs *fields.
- VariantType.toInternal parameter renamed obj -> variant.

Add offline tests for the new import paths and the signature fixes; the signature
tests were validated against reference pyspark 4.2.0 behavior.

Co-authored-by: Isaac <no-reply@databricks.com>
…ested field names

A struct-typed field was rendered with simple_string() in DataType::append_tree,
which inlines the nested fields (e.g. "struct<inner:int>"). That leaked the child
names into the parent's type text, so treeString(maxDepth) could not truncate them
(and at full depth printed them twice). Render a struct field as the bare type name
("struct") and let the depth-controlled recursion show its children, matching
PySpark's StructType._build_formatted_string. Non-struct fields keep simple_string().

Co-authored-by: Isaac <no-reply@databricks.com>
HyukjinKwon added a commit that referenced this pull request Sep 1, 2026
…parity gaps

## What changes were proposed in this pull request?

Closes the remaining PySpark 4.2.0 Spark Connect public-API parity gaps found by a
close `inspect.signature` diff of the drop-in against the reference `pyspark==4.2.0`
Connect client.

**Import-path gaps** — thin re-export shims, same pattern as the existing
`connect/dataframe.py`:
- New `pyspark.sql.connect.*` submodules: `catalog`, `conf`, `group`, `window`,
  `readwriter`, `tvf`, `udf`, `udtf`, `observation`, `merge`,
  `streaming.readwriter`, `streaming.query`. The reference client and the official
  Connect test suite import from these paths, which previously raised `ImportError`.
- New public `pyspark.sql.conf` (exposing `RuntimeConfig`, aliasing the Connect
  `RuntimeConf`) and `pyspark.sql.tvf` modules.

**Signature gaps** vs the reference Connect client:
- `StructType.treeString` gains the `maxDepth` parameter (default `2147483647`),
  wired through a new `DataType::tree_string_with_depth` in the core;
  `tree_string()` is preserved for existing callers.
- `StructType.fromJson` / `StructField.fromJson` parameter renamed `data` → `json`.
- `TableValuedFunction.json_tuple` / `stack` now take varargs `*fields`.
- `VariantType.toInternal` parameter renamed `obj` → `variant`.

The `pyspark.sql.functions` surface was already at full parity (all 529 reference
functions, no signature mismatches) and is unchanged.

## Why are the changes needed?

The package advertises drop-in parity with the PySpark 4.2.0 Spark Connect client.
These were the residual deviations where reference-valid imports and calls could
break.

## Does this PR introduce any user-facing change?

Yes, additive: previously-failing imports now resolve, and the four methods above
accept the reference parameter names/forms.

## How was this patch tested?

New offline tests in `python/tests/test_dropin_offline.py`:
- `test_connect_submodule_import_paths` (14 paths) — passes against the built extension.
- Behavior tests for `treeString(maxDepth)`, `fromJson(json=...)`, and
  `VariantType.toInternal(variant=...)` — validated against reference
  `pyspark==4.2.0` to confirm they encode the correct behavior; they exercise the
  rebuilt extension under CI.

The Rust changes were authored but not compiled on the dev box (offline); the
build + official Connect suite in CI is the build/behavior gate.

This pull request and its description were written by Isaac.

Closes #95 from HyukjinKwon/SPARK-59143-close-connect-parity-gaps.

Authored-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 254dd50)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
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.

2 participants