HyukjinKwon opened a new pull request, #919:
URL: https://github.com/apache/spark-connect-rust/pull/919
### What changes were proposed in this pull request?
A follow-up of the known-differences audit against pyspark-client 4.3.0
(finding 5).
PySpark's `createDataFrame` under a struct
(`pyspark/sql/connect/session.py`) converts the data first, of the errors of
its conversion, and then sends `LocalRelation(table, schema=_schema.json())`.
`json()` writes the `jsonValue` of each element of the fields of each struct,
in their order. Data of no rows, of any kind it takes the length of (rows, a
pandas DataFrame, a pyarrow Table, an array of one or two dimensions), sends
`LocalRelation(schema=_schema.json())` without a conversion.
So for a struct whose `fields` hold an element that is not a `StructField`,
as after `s.fields.append("x")`, also in an inner struct changed in place after
the outer one was made:
- of no rows, PySpark raises the `AttributeError` of the first element that
has no `jsonValue`, `'str' object has no attribute 'jsonValue'`, and writes an
element that has its own `jsonValue` with it;
- of a pandas DataFrame of rows, its conversion first deduplicates the names
of the fields (`_deduplicate_field_names`), which raises the `IndexError` of an
element past the cached `names`;
- of an array of rows, its conversion reads no field, so the `json()` after
it raises the `AttributeError` of an element of no `jsonValue`, and an element
that has one is sent;
- of local rows or a pyarrow Table, its conversion reads the fields, of the
`AttributeError` of an element that lacks what it reads; an element that has
all of it (a duck-typed field) is converted and sent of its `jsonValue`.
The drop-in instead lowered the schema into the core's struct type and
raised `TypeError: StructType fields must be StructField objects` of no rows,
of an array of rows and of a duck-typed field, and raised
`AXIS_LENGTH_MISMATCH` for a pandas DataFrame of another width than the fields.
So:
- **`types::foreign_schema_json` writes the `json()` of such a schema as
PySpark's does.** It walks the fields of each struct (`for f in self`), through
struct fields, array elements and map keys and values, reading the attributes
of each type as PySpark's `jsonValue` reads them, in its order:
- an element that is not a `StructField` contributes its own `jsonValue`,
so one without `jsonValue` raises Python's `AttributeError`; a struct, an array
or a map that is itself an element of `fields` is written of its elements in
turn;
- a `StructField` is written as PySpark's `StructField.jsonValue`:
`getCollationMetadata` reads its `dataType` and its `name`, then its
`metadata`, `name`, `dataType` and `nullable`, with the collations of the
strings of its arrays and maps in its metadata (`__COLLATIONS`) and its type
without them (`_dataTypeJsonValue`). So a Python subclass of a property of its
own, such as a `dataType` that builds a new struct at each read, is written of
what each read gives;
- an array and a map are written of their `typeName`, their types and
their flags; another type, and a Python subclass's own `json` or `jsonValue`,
are their own.
- **`ForeignFields` tells such a schema apart**, looking at each type object
once: of the children that it keeps, which the lowering into the core's types
reads, and, of a Python subclass of an attribute of its own (`dataType`,
`elementType`, `keyType`, `valueType`, `fields` or `__iter__`), of what the
attribute gives, which PySpark reads. It holds a strong reference to each
object it looked at, with the answer, so that an object that is read and freed,
as of such a property, cannot leave its answer to another object that later
takes its address.
- **`createDataFrame` of no rows sends that JSON.** It does so before it
looks at the kind of data, after it checks the dimensions of an array, as
PySpark does. `emptyDataFrame`, which is `createDataFrame([], schema)`, gets it
too.
- **`createDataFrame` of rows writes that JSON after PySpark's conversion of
the data** (`create_of_unlowered_schema`, which was `unlowered_schema_error`,
and `pyarrow_import::create_dataframe`):
- a pandas DataFrame deduplicates the names of the fields first, of
PySpark's `_deduplicate_field_names`;
- the conversion of local rows, a pandas DataFrame or an array of rows
returns its table, and the JSON raises its `AttributeError`, or the relation of
the table is sent of the JSON as its schema (`DataType::Unparsed`), with `toDF`
of the names of the struct for a pandas DataFrame, as PySpark's;
- a pyarrow Table is sent of the JSON too.
- **The other uses of such a struct still lower it**, unchanged: its JSON,
simple string and tree string, a lookup by name, `add`, pickles and copies, and
the plans of `to`, `cast`, `from_json` and a reader's schema.
`dev/parity/known-differences.md` keeps only those other uses in the row of
such an element, and the constructors of a `StructField`, an `ArrayType` or a
`MapType` of such a struct, which raise the `TypeError` when made.
`docs/compatibility.md` describes `createDataFrame` under such a struct, which
is now PySpark's of any data but a pandas DataFrame of another width than the
fields, which raises `AXIS_LENGTH_MISMATCH` as of any struct (the first entry
of the KD, of SPARK-60902; SPARK-62221 makes it PySpark's).
Checked on both clients against a Spark 4.3.0 server, of no rows and of the
other uses:
| case | pyspark-client 4.3.0 | drop-in before (master) | drop-in now |
|---|---|---|---|
| createDataFrame([], bad) | raises AttributeError: 'str' object has no
attribute 'jsonValue' | raises TypeError: StructType fields must be StructField
objects | raises AttributeError: 'str' object has no attribute 'jsonValue' |
| createDataFrame((), bad) | raises AttributeError: 'str' object has no
attribute 'jsonValue' | raises TypeError: StructType fields must be StructField
objects | raises AttributeError: 'str' object has no attribute 'jsonValue' |
| createDataFrame(pandas of no rows, bad) | raises AttributeError: 'str'
object has no attribute 'jsonValue' | raises TypeError: StructType fields must
be StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| createDataFrame(pyarrow of no rows, bad) | raises AttributeError: 'str'
object has no attribute 'jsonValue' | raises TypeError: StructType fields must
be StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| createDataFrame(numpy of no rows, 1-dim, bad) | raises AttributeError:
'str' object has no attribute 'jsonValue' | raises TypeError: StructType fields
must be StructField objects | raises AttributeError: 'str' object has no
attribute 'jsonValue' |
| createDataFrame(numpy of no rows, 2-dim, bad) | raises AttributeError:
'str' object has no attribute 'jsonValue' | raises TypeError: StructType fields
must be StructField objects | raises AttributeError: 'str' object has no
attribute 'jsonValue' |
| createDataFrame([], nested bad) | raises AttributeError: 'str' object has
no attribute 'jsonValue' | raises TypeError: StructType fields must be
StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| createDataFrame([], ArrayType(bad) field) | raises AttributeError: 'str'
object has no attribute 'jsonValue' | raises TypeError: StructType fields must
be StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| createDataFrame([], MapType(str, bad) field) | raises AttributeError:
'str' object has no attribute 'jsonValue' | raises TypeError: StructType fields
must be StructField objects | raises AttributeError: 'str' object has no
attribute 'jsonValue' |
| createDataFrame([], MapType(bad, str) field) | raises AttributeError:
'str' object has no attribute 'jsonValue' | raises TypeError: StructType fields
must be StructField objects | raises AttributeError: 'str' object has no
attribute 'jsonValue' |
| createDataFrame([], nested duck) | StructType([StructField('s',
ArrayType(StructType([StructField('a', LongType(), True), StructFi | raises
TypeError: StructType fields must be StructField objects |
StructType([StructField('s', ArrayType(StructType([StructField('a', LongType(),
True), StructFi |
| createDataFrame([], fields of a duck, then a str) | raises AttributeError:
'str' object has no attribute 'jsonValue' | raises TypeError: StructType fields
must be StructField objects | raises AttributeError: 'str' object has no
attribute 'jsonValue' |
| createDataFrame([], bad of a None) | raises AttributeError: 'NoneType'
object has no attribute 'jsonValue' | raises TypeError: StructType fields must
be StructField objects | raises AttributeError: 'NoneType' object has no
attribute 'jsonValue' |
| createDataFrame([], bad of an int) | raises AttributeError: 'int' object
has no attribute 'jsonValue' | raises TypeError: StructType fields must be
StructField objects | raises AttributeError: 'int' object has no attribute
'jsonValue' |
| createDataFrame([], bad of a duck) | StructType([StructField('a',
LongType(), True), StructField('d', LongType(), True)]) | raises TypeError:
StructType fields must be StructField objects | StructType([StructField('a',
LongType(), True), StructField('d', LongType(), True)]) |
| createDataFrame([], bad of a duck) collect | [] | raises TypeError:
StructType fields must be StructField objects | [] |
| createDataFrame([], bad of a raising duck) | raises KeyError: 'boom' |
raises TypeError: StructType fields must be StructField objects | raises
KeyError: 'boom' |
| createDataFrame([], bad then a str) | raises AttributeError: 'str' object
has no attribute 'jsonValue' | raises TypeError: StructType fields must be
StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| createDataFrame([], valid) | StructType([StructField('a', LongType(),
True)]) | StructType([StructField('a', LongType(), True)]) |
StructType([StructField('a', LongType(), True)]) |
| createDataFrame([], 'a long') | StructType([StructField('a', LongType(),
True)]) | StructType([StructField('a', LongType(), True)]) |
StructType([StructField('a', LongType(), True)]) |
| createDataFrame([(1,)], bad) | raises AttributeError: 'str' object has no
attribute 'dataType' | raises AttributeError: 'str' object has no attribute
'dataType' | raises AttributeError: 'str' object has no attribute 'dataType' |
| createDataFrame(pandas 1 row, bad) | raises IndexError: list index out of
range | raises PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch:
Expected axis has 2 elements, | raises IndexError: list index out of range |
| createDataFrame(pyarrow 1 row, bad) | raises AttributeError: 'str' object
has no attribute 'name' | raises AttributeError: 'str' object has no attribute
'name' | raises AttributeError: 'str' object has no attribute 'name' |
| json() | raises AttributeError: 'str' object has no attribute 'jsonValue'
| raises TypeError: StructType fields must be StructField objects | raises
TypeError: StructType fields must be StructField objects |
| cast at the call | raises AttributeError: 'str' object has no attribute
'simpleString' | raises TypeError: StructType fields must be StructField
objects | raises TypeError: StructType fields must be StructField objects |
| to | StructType([StructField('a', LongType(), True), x]) | raises
TypeError: StructType fields must be StructField objects | raises TypeError:
StructType fields must be StructField objects |
| from_json | raises AttributeError: 'str' object has no attribute
'jsonValue' | raises TypeError: StructType fields must be StructField objects |
raises TypeError: StructType fields must be StructField objects |
| read.schema | raises AttributeError: 'str' object has no attribute
'jsonValue' | raises TypeError: StructType fields must be StructField objects |
raises TypeError: StructType fields must be StructField objects |
23 of 28 cases match PySpark now; 4 with drop-in before (master)
The 5 that still differ are the other uses of such a struct, which lower it
(the KD row).
"bad" is `StructType([StructField("a", LongType())])` after
`fields.append("x")`, and a nested case is made first and then changed in
place, as the drop-in's `StructField`, `ArrayType` and `MapType` raise the
`TypeError` when made of such a struct. A duck is an object with its own
`jsonValue`. Six rows still differ, as the KD row says. Five are the uses that
still lower the struct: its own JSON, `cast`, `to`, `from_json` and a reader's
schema. The sixth is a pandas DataFrame of rows, which this PR does not change.
Empty data of a valid schema, or of none, gives the same result on both clients
in all 16 cases (four kinds of data under four schemas), before and after this
PR.
A pandas DataFrame of rows under such a struct (the same as master before
this round; "valid 1 field" is of a valid struct, see below):
| case | pyspark-client 4.3.0 | master (as e2 before this round) | drop-in
now |
|---|---|---|---|
| pandas 1 column, bad | raises IndexError: list index out of range | raises
PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 2
elements, | raises IndexError: list index out of range |
| pandas 2 columns, bad | raises IndexError: list index out of range |
raises IndexError: list index out of range | raises IndexError: list index out
of range |
| pandas 1 column, bad of names mutated too | raises AttributeError: 'str'
object has no attribute 'dataType' | raises PySparkValueError:
[AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 2 elements, | raises
AttributeError: 'str' object has no attribute 'dataType' |
| pandas 2 columns, bad of names mutated too | raises AttributeError: 'str'
object has no attribute 'dataType' | raises AttributeError: 'str' object has no
attribute 'dataType' | raises AttributeError: 'str' object has no attribute
'dataType' |
| pandas 1 column, bad of a None | raises IndexError: list index out of
range | raises PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch:
Expected axis has 2 elements, | raises IndexError: list index out of range |
| pandas, nested struct | raises IndexError: list index out of range |
raises IndexError: list index out of range | raises IndexError: list index out
of range |
| pandas, nested array | raises IndexError: list index out of range | raises
IndexError: list index out of range | raises IndexError: list index out of
range |
| pandas, nested map value | raises IndexError: list index out of range |
raises IndexError: list index out of range | raises IndexError: list index out
of range |
| pandas 2 columns, valid 1 field | StructType([StructField('a', LongType(),
True)]) rows=[Row(a=1)] | raises PySparkValueError: [AXIS_LENGTH_MISMATCH]
Length mismatch: Expected axis has 1 elements, | raises PySparkValueError:
[AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 1 elements, |
| pandas 1 column, valid | StructType([StructField('a', LongType(), True)])
rows=[Row(a=1)] | StructType([StructField('a', LongType(), True)])
rows=[Row(a=1)] | StructType([StructField('a', LongType(), True)])
rows=[Row(a=1)] |
9 of 10 cases match PySpark now; 6 with master (as e2 before this round)
An array of rows under such a struct:
| case | pyspark-client 4.3.0 | e2 before (9358d45a) | drop-in now |
|---|---|---|---|
| 2-D of 2 columns, 'x' | raises AttributeError: 'str' object has no
attribute 'jsonValue' | raises TypeError: StructType fields must be StructField
objects | raises AttributeError: 'str' object has no attribute 'jsonValue' |
| 2-D of 2 columns, None | raises AttributeError: 'NoneType' object has no
attribute 'jsonValue' | raises TypeError: StructType fields must be StructField
objects | raises AttributeError: 'NoneType' object has no attribute 'jsonValue'
|
| 2-D of 2 columns, 5 | raises AttributeError: 'int' object has no attribute
'jsonValue' | raises TypeError: StructType fields must be StructField objects |
raises AttributeError: 'int' object has no attribute 'jsonValue' |
| 2-D of 3 columns, 'x', 'y' | raises AttributeError: 'str' object has no
attribute 'jsonValue' | raises TypeError: StructType fields must be StructField
objects | raises AttributeError: 'str' object has no attribute 'jsonValue' |
| 2-D of 2 columns, nested struct 'x' | raises AttributeError: 'str' object
has no attribute 'jsonValue' | raises TypeError: StructType fields must be
StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| 2-D of 2 columns, nested array 'x' | raises AttributeError: 'str' object
has no attribute 'jsonValue' | raises TypeError: StructType fields must be
StructField objects | raises AttributeError: 'str' object has no attribute
'jsonValue' |
| 1-D, 'x' | raises PySparkValueError: [AXIS_LENGTH_MISMATCH] Length
mismatch: Expected axis has 2 elements, | raises PySparkValueError:
[AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 2 elements, | raises
PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 2
elements, |
| 2-D of 1 column, 'x' | raises PySparkValueError: [AXIS_LENGTH_MISMATCH]
Length mismatch: Expected axis has 2 elements, | raises PySparkValueError:
[AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 2 elements, | raises
PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 2
elements, |
| 2-D of 2 columns, Duck | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) rows=[Row( | raises TypeError: StructType
fields must be StructField objects | StructType([StructField('a', LongType(),
True), StructField('d', LongType(), True)]) rows=[Row( |
9 of 9 cases match PySpark now; 2 with e2 before (9358d45a)
Rows of each kind under an element that has what PySpark reads of a field
("duck": `name`, `dataType`, `nullable`, `metadata`, `jsonValue` and the
conversion methods; "names too": the cached `names` extended as well;
"jsonValue only": an object of a `jsonValue` only):
| case | pyspark-client 4.3.0 | e2 before (9358d45a) | drop-in now |
|---|---|---|---|
| duck: rows | raises PySparkValueError: [AXIS_LENGTH_MISMATCH] Length
mismatch: Expected axis has 1 ele | raises PySparkValueError:
[AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 1 ele | raises
PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 1
ele |
| duck: ndarray | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | raises TypeError: StructType fields
must be StructField objects | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r |
| duck: pandas | raises IndexError: list index out of range | raises
IndexError: list index out of range | raises IndexError: list index out of
range |
| duck: pyarrow | raises ArrowInvalid: tried to rename a table of 2 columns
but only 1 names were provid | raises ArrowInvalid: tried to rename a table of
2 columns but only 1 names were provid | raises ArrowInvalid: tried to rename a
table of 2 columns but only 1 names were provid |
| duck: no rows | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | StructType([StructField('a',
LongType(), True), StructField('d', LongType(), True)]) r |
StructType([StructField('a', LongType(), True), StructField('d', LongType(),
True)]) r |
| duck, names too: rows | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) rows | raises TypeError: StructType fields
must be StructField objects | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) rows |
| duck, names too: ndarray | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | raises TypeError: StructType fields
must be StructField objects | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r |
| duck, names too: pandas | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) ro | raises TypeError: StructType fields
must be StructField objects | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) ro |
| duck, names too: pyarrow | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | raises TypeError: StructType fields
must be StructField objects | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r |
| duck, names too: no rows | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | StructType([StructField('a',
LongType(), True), StructField('d', LongType(), True)]) r |
StructType([StructField('a', LongType(), True), StructField('d', LongType(),
True)]) r |
| jsonValue only: rows | raises PySparkValueError: [AXIS_LENGTH_MISMATCH]
Length mismatch: Expected axis has 1 ele | raises PySparkValueError:
[AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 1 ele | raises
PySparkValueError: [AXIS_LENGTH_MISMATCH] Length mismatch: Expected axis has 1
ele |
| jsonValue only: ndarray | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | raises TypeError: StructType fields
must be StructField objects | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r |
| jsonValue only: pandas | raises IndexError: list index out of range |
raises IndexError: list index out of range | raises IndexError: list index out
of range |
| jsonValue only: pyarrow | raises AttributeError: 'JsonOnly' object has no
attribute 'name' | raises AttributeError: 'JsonOnly' object has no attribute
'name' | raises AttributeError: 'JsonOnly' object has no attribute 'name' |
| jsonValue only: no rows | StructType([StructField('a', LongType(), True),
StructField('d', LongType(), True)]) r | StructType([StructField('a',
LongType(), True), StructField('d', LongType(), True)]) r |
StructType([StructField('a', LongType(), True), StructField('d', LongType(),
True)]) r |
15 of 15 cases match PySpark now; 9 with e2 before (9358d45a)
The one case that still differs, "pandas 2 columns, valid 1 field", is of a
valid struct and is not changed here: PySpark's conversion of a pandas
DataFrame zips its columns with the fields, so a frame wider than the fields
loses its extra columns, and a narrower one fails PyArrow's rename (`tried to
rename a table of 1 columns but only 2 names were provided`), where the drop-in
raises `AXIS_LENGTH_MISMATCH` of both. It is a separate gap.
Fields of a Python subclass whose `dataType` property builds a new struct at
each read, valid (one field) or holding a `jsonValue`-only element (two), in
the order given; the structs that the fields were made of hold such an element
(kept foreign) or not (kept valid). The column is the sent schema:
| struct that the fields were made of / structs that `dataType` reads |
pyspark-client 4.3.0 | e2 before (e6f49ceb) | drop-in now |
|---|---|---|---|
| kept foreign / valid/foreign | sent: fields of ['valid', 'foreign'] |
TypeError: StructType fields must be StructField objects | sent: fields of
['valid', 'foreign'] |
| kept foreign / foreign/valid | sent: fields of ['foreign', 'valid'] |
sent: fields of ['foreign', 'valid'] | sent: fields of ['foreign', 'valid'] |
| kept foreign / valid/foreign/valid/foreign | sent: fields of ['valid',
'foreign', 'valid', 'foreign'] | TypeError: StructType fields must be
StructField objects | sent: fields of ['valid', 'foreign', 'valid', 'foreign'] |
| kept foreign / valid/valid | sent: fields of ['valid', 'valid'] | sent:
fields of ['valid', 'valid'] | sent: fields of ['valid', 'valid'] |
| kept foreign / foreign/foreign | sent: fields of ['foreign', 'foreign'] |
sent: fields of ['foreign', 'foreign'] | sent: fields of ['foreign', 'foreign']
|
| kept valid / valid/foreign | sent: fields of ['valid', 'foreign'] | sent:
fields of ['valid', 'valid'] | sent: fields of ['valid', 'foreign'] |
| kept valid / foreign/valid | sent: fields of ['foreign', 'valid'] | sent:
fields of ['valid', 'valid'] | sent: fields of ['foreign', 'valid'] |
| kept valid / valid/foreign/valid/foreign | sent: fields of ['valid',
'foreign', 'valid', 'foreign'] | sent: fields of ['valid', 'valid', 'valid',
'valid'] | sent: fields of ['valid', 'foreign', 'valid', 'foreign'] |
| kept valid / valid/valid | sent: fields of ['valid', 'valid'] | sent:
fields of ['valid', 'valid'] | sent: fields of ['valid', 'valid'] |
| kept valid / foreign/foreign | sent: fields of ['foreign', 'foreign'] |
sent: fields of ['valid', 'valid'] | sent: fields of ['foreign', 'foreign'] |
10 of 10 cases match PySpark now; 4 with e2 before (e6f49ceb)
### Why are the changes needed?
So that `createDataFrame` under such a schema raises PySpark's errors, of
any data, and sends PySpark's relation where PySpark sends one.
### Does this PR introduce _any_ user-facing change?
Yes: `createDataFrame` (and `emptyDataFrame`) under a struct whose fields
hold an element that is not a `StructField`:
- of no rows, and of an array of rows, raises the `AttributeError` of the
first element that has no `jsonValue`, as PySpark does, where it raised
`TypeError`;
- of a pandas DataFrame of rows, raises PySpark's `IndexError` of
`_deduplicate_field_names`, where it raised `AXIS_LENGTH_MISMATCH` of a frame
of another width than the fields;
- of an element that has what PySpark reads of it, sends PySpark's relation,
of the JSON of the element, where it raised `TypeError`.
### How was this patch tested?
- **New offline test** in `python/tests/test_dropin_offline.py`, with the
mock server:
`test_create_dataframe_of_a_struct_of_a_foreign_field_is_pysparks`. It covers:
- every kind of data of no rows, and nested structs, array elements, map
keys and map values changed in place;
- elements of `None`, an int, an object with its own `jsonValue` (whose
JSON is sent, nested too), and one whose `jsonValue` raises, and that no
request is sent when the call raises;
- a pandas DataFrame of rows of one and of two columns, of the
`IndexError`, of names changed too (the `AttributeError` of `dataType`), and
nested;
- an array of rows of the `AttributeError` of `json()`, nested, and of
`AXIS_LENGTH_MISMATCH` of another width;
- the relation that rows, a pyarrow Table, a pandas DataFrame (with `toDF`
of the names) and an array of rows send of a duck-typed element: PySpark's JSON
of the schema, and the converted data.
- a struct and an array of one that are themselves elements of `fields`,
of a duck-typed element (their JSON) and of a str (the `AttributeError`), and a
map of a collated key in a field of such a struct (its `__COLLATIONS` metadata).
- fields of a Python subclass whose `dataType` property builds a new
struct at each read, of the structs that the fields were made of holding an
element that is not a `StructField` or not, in five orders of the structs read:
each is written of the elements of the struct read, as PySpark's `jsonValue`
reads it. This fails on the previous revision (e6f49ceb) of `TypeError:
StructType fields must be StructField objects`, of a memo keyed by the address
of a struct that was freed.
It fails on master, and on the previous revisions of this change (at the
array of rows, and at the subclass of a `dataType` property).
- **Probes of both clients** against a Spark 4.3.0 server: the tables above.
Data under a valid schema, or of no schema, gives the same results on both
clients as before.
- **The Rust and Python gates** (`gates.sh build rust py`):
- `cargo fmt --all --check`;
- `cargo +1.100.0 clippy -p apache-spark-connect-core -p
apache-spark-connect -p pyspark-rs --all-targets -- -D warnings`;
- `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps`;
- `cargo test -p pyspark-rs --lib`: 18 passed;
- ruff 0.14.0, `test_ruff_excludes.py`, `scripts/audit_no_stubs.sh`, the
stub and dispatch generators, the test-list guards and the license checks;
- `test_type_stubs_offline.py`: 15 passed, 4 skipped;
- the offline suite of `coverage.yml`: 7,035 passed, 114 skipped.
- **`scripts/check_vendored_upstream.sh`**: every vendored file matches
Apache Spark v4.3.0.
- **`test_dropin_e2e.py`** against a Spark 4.3.0 server: 352 passed.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]