Repository navigation
fix(amber): stop JSONL scan reading null as text - #8740
CaroFernando wants to merge 2 commits into
Conversation
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8740 +/- ##
=========================================
Coverage 91.68% 91.68%
- Complexity 5132 5134 +2
=========================================
Files 1305 1305
Lines 58229 58230 +1
Branches 7600 7601 +1
=========================================
+ Hits 53385 53389 +4
+ Misses 2937 2936 -1
+ Partials 1907 1905 -2
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 579 | 0.354 | 17,079/23,351/23,351 us | 🔴 +21.8% / 🔴 +64.6% |
| ⚪ | bs=100 sw=10 sl=64 | 1,282 | 0.782 | 76,744/93,917/93,917 us | ⚪ within ±5% / 🟢 -11.6% |
| 🔴 | bs=1000 sw=10 sl=64 | 1,436 | 0.877 | 696,643/765,761/765,761 us | 🔴 +5.1% / 🟢 -18.5% |
Baseline details
Latest main cb1d619 from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 579 tuples/sec | 616 tuples/sec | 900.3 tuples/sec | -6.0% | -35.7% |
| bs=10 sw=10 sl=64 | MB/s | 0.354 MB/s | 0.376 MB/s | 0.549 MB/s | -5.9% | -35.6% |
| bs=10 sw=10 sl=64 | p50 | 17,079 us | 14,023 us | 11,014 us | +21.8% | +55.1% |
| bs=10 sw=10 sl=64 | p95 | 23,351 us | 24,726 us | 14,189 us | -5.6% | +64.6% |
| bs=10 sw=10 sl=64 | p99 | 23,351 us | 24,726 us | 17,391 us | -5.6% | +34.3% |
| bs=100 sw=10 sl=64 | throughput | 1,282 tuples/sec | 1,330 tuples/sec | 1,187 tuples/sec | -3.6% | +8.0% |
| bs=100 sw=10 sl=64 | MB/s | 0.782 MB/s | 0.812 MB/s | 0.724 MB/s | -3.7% | +8.0% |
| bs=100 sw=10 sl=64 | p50 | 76,744 us | 76,179 us | 86,789 us | +0.7% | -11.6% |
| bs=100 sw=10 sl=64 | p95 | 93,917 us | 90,213 us | 94,657 us | +4.1% | -0.8% |
| bs=100 sw=10 sl=64 | p99 | 93,917 us | 90,213 us | 104,753 us | +4.1% | -10.3% |
| bs=1000 sw=10 sl=64 | throughput | 1,436 tuples/sec | 1,476 tuples/sec | 1,219 tuples/sec | -2.7% | +17.8% |
| bs=1000 sw=10 sl=64 | MB/s | 0.877 MB/s | 0.901 MB/s | 0.744 MB/s | -2.7% | +17.9% |
| bs=1000 sw=10 sl=64 | p50 | 696,643 us | 675,255 us | 846,616 us | +3.2% | -17.7% |
| bs=1000 sw=10 sl=64 | p95 | 765,761 us | 728,597 us | 887,594 us | +5.1% | -13.7% |
| bs=1000 sw=10 sl=64 | p99 | 765,761 us | 728,597 us | 940,017 us | +5.1% | -18.5% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,345.29,200,128000,579,0.354,17078.55,23350.90,23350.90
1,100,10,64,20,1560.11,2000,1280000,1282,0.782,76743.97,93917.42,93917.42
2,1000,10,64,20,13925.47,20000,12800000,1436,0.877,696643.04,765760.95,765760.95…ython (apache#8704) ### What changes were proposed in this PR? The JSON Lines and Arrow sources implement `StandaloneCodeGenerator`, so an exported script starts from the same data the workflow did. Arrow is read into pandas' nullable dtypes rather than its numpy ones. Arrow says of every value whether it is there, and a numpy column has nowhere to put that: a missing double and a stored NaN both land on NaN, and a missing integer costs the column its integer type. The engine reads the file's own answer, so a set operation keeps a NaN row a null row does not match, a holed integer column is still made of integers, and a long past 2^53 is not rounded on its way through a float. The other sources state the types they need one at a time, their formats having no way to say it once. A file also states the width and the sign of each of its numbers, and Texera has no column narrower than a double or a 32-bit integer. A single-precision or 16-bit column was arriving null, the parse having no case for the Float and Short those vectors hand back, and an unsigned one arrived as the -1 its storage counts down to. Each now reads as the Texera type that holds it, an unsigned 32-bit column as a long and an unsigned 64-bit one refused for want of a wider one, and the script normalizes the same widths so a later sum comes to the same number on both sides. This is the rule the Parquet source already follows. The end of an exported Arrow window is counted in Long, as the CSV readers count theirs. A timestamp is read as the engine reads one. The engine hands each field to DateParserUtils, so a row states its own format, any year reads, an offset is moved to the local zone, and the reading is cut to the millisecond. pandas' date parsing does none of that. So JSONL reads the column as text and converts it with the helper apache#8597 adds. This PR also changes the engine. `ArrowUtils` handed a TIMESTAMP column to a Python worker as an Arrow millisecond timestamp labelled UTC. A Python operator saw an aware datetime cut to the millisecond, and a year past 2262 overflowed. It is now a zoneless microsecond timestamp. That is what Texera's own Python side declares for a TIMESTAMP (`pa.timestamp("us")`), and what an exported script holds. Two things a user can see change. A Python UDF now receives a naive datetime instead of one in UTC. A result downloaded as an Arrow file now carries a zoneless microsecond timestamp column instead of a UTC millisecond one. A TIMESTAMP parameter a Python UDF declares is now parsed the same way, as a naive wall clock with any offset moved to the machine's zone, so it compares with a row's instead of raising. ### Any related issues, documentation, discussions? Part of apache#8325, step 12b; that issue lists the set in order. It uses apache#8341's shared source code and apache#8597's timestamp helpers. Its JSON Lines export reads a JSON `null` as the text `"null"`, as the engine does today (apache#8674). If apache#8740 merges first, that part changes to read a null before this one merges. Closes apache#8702, the task this change is the whole of. It also finishes apache#8602, where a scan window of no rows left the type inference nothing to read and JSONL declared a schema of no columns. apache#8341 fixes the CSV half. Closes apache#8602. ### How was this PR tested? Each operator asserts the block it emits in its own spec, and the Arrow spec runs the engine's own executor and the generated script over the same file. The engine change is covered in both ArrowUtilsSpec files, which include a round trip on either side of the nanosecond range, and in the Python tests of the timestamp parser. Once the verification lands, every operator is also run both ways on every configuration its schema offers; this branch is cut from main and does not carry that machinery, so those runs are not on this diff's CI. Arrow is the one worth calling out. Its column of timestamps only matches once apache#7672 is in: before that the engine read the file's numbers through the JVM's zone while `pd.read_feather` read the wall clock the file states, and the two differed by whatever the machine was set to. That change has since landed. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5) --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Removing release/v1.2: cleaning the nulls in the source file works around it. |
|
Looks right to me, and the JSONL scan is the only caller. One case gets worse: a key that is null in all 100 sampled rows now drops out of the schema, so a later |
|
@CaroFernando could you take a look at the null-key suggestion above? |
JSONUtils.JSONToMap turned a JSON null into the literal string "null" (NullNode.asText()), so one null widened the whole column to STRING during schema inference and the cell held the text null. Nulls now produce no map entry, so the JSONL scan operator treats them as missing values: schema inference stays numeric and the cell is empty. Closes apache#8674
Dropping a null's key lost the column when a key was null on every sampled row, so a later row's value for it was gone. JSONToMap now keeps the key and maps it to null, which the scan reads as an empty cell the same way it reads a missing key. The Python export of the JSONL source copied the old "null" text, so _texera_json_text now returns None for a null as well, and texera_helpers/__init__.py is regenerated from it.
3d8ffde to
bfe10ff
Compare
|
@kz930 Thanks for catching this. A null now keeps its key with a null value, so the column survives; your 101-line case is now a test. I also rebased onto main and made the Python export (#8704) read a null as None to match. An all-null sampled column is still typed INTEGER. That comes from inferSchemaFromRows and already affects the CSV scan, which is tracked in #8791. |
What changes were proposed in this PR?
When a JSONL file has a JSON null in a row, the JSONL File Scan reads it as
the literal text "null". That happens because JSONToMap writes every value
node into the map using asText(), and for NullNode that returns "null". One
null in a column then breaks schema inference: it can't parse "null" as a
number, so the column falls back to STRING and the cell shows the word null.
This PR makes JSONToMap keep the key of a NullNode but map it to a Scala null,
in both places it can show up: object fields and array elements in flatten
mode. Keeping the key matters for schema inference, which builds the column
list from the keys it sees in the sample: a key that is null on every sampled
row still becomes a column, so a later row's value for it is not lost. At
runtime the executor already reads a null value the same way as a missing key,
as an empty cell, and during schema inference the other rows decide the type.
So for the example in the issue:
{"a":1} {"a":null} used to give column a as STRING with values "1" and "null"
it now gives INTEGER with values 1 and an empty cell
The Python export of the JSONL source (#8704) copied the old behavior on
purpose:
_texera_json_textturned a null into "null" so the exported scriptmatched the executor. It now returns None like the executor, and
texera_helpers/__init__.pyis regenerated from it.A column that is null on every sampled row is typed INTEGER, which is what
inferSchemaFromRows does for an all-null column, so a later text value in it is
skipped. That already happens in the CSV scan and is tracked in #8791; this PR
leaves it to that issue.
The two tests in JSONUtilsSpec that expected the string "null" were written
on purpose to pin the old behavior until a fix came along, so they are
updated here.
Any related issues, documentation, discussions?
Closes #8674
Related to #8791
How was this PR tested?
New tests:
under flatten, and inside a flattened array.
{"v":1}and{"v":null}give INTEGER with anempty cell; a key that is null on all 100 sampled lines keeps its column, and
line 101's
{"b":5}lands in it.for an INTEGER column and a STRING column, matching the executor.
WorkflowCore 891 passed; WorkflowOperator 3118 passed, 1 canceled (the
LargeBinary read, which needs an S3 endpoint); translator and
WorkflowToPythonResourceSpec 135 passed.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude