NoahKusaba commented on issue #2945:
URL:
https://github.com/apache/datafusion-ballista/issues/2945#issuecomment-7154362139
I ran the spike: DataFusion 56.0.0's `.slt` files on plain DataFusion, on
standalone Ballista with the static planner, and on standalone Ballista with
AQE.
**Setup**
- A `harness = false` test in a new `ballista/sqllogictest` crate. It uses
`datafusion-sqllogictest` 56.0.0's `DataFusion` engine and `TestContext`
unchanged, and runs from a DataFusion 56.0.0 checkout with its `testing` /
`parquet-testing` submodules, because the files read data by relative paths.
- Each file runs on each engine in its own process. Each Ballista run starts
its own standalone cluster from the file's `SessionState`.
- Plain `EXPLAIN` records are dropped. `EXPLAIN ANALYZE` still runs
(`dml_delete.slt` deletes rows with it), but its output isn't checked.
- `configMatrix` is honoured. `max_partitions_per_task = 1` is not in the
matrix yet.
- Debug build, 300 s timeout per file per engine.
**Two harness workarounds, needed for any signal at all**
- Almost every file creates tables with `CREATE TABLE … AS VALUES`. Ballista
can't serialize a `MemTable` in a logical plan ("LogicalExtensionCodec is not
provided"), so nearly every query failed before it reached a planner.
- Since standalone runs in one process, the harness composes Ballista's
logical codec with one that encodes such a table as a reference to the same
`Arc<dyn TableProvider>`. It does the same for a `DataSinkExec` that Ballista's
physical codec can't encode, so `INSERT INTO` a memory table lands in the table
later queries read. This stands in for a catalog the scheduler would share on a
real cluster. Every other node Ballista can't serialize still fails.
**Totals (544 files)**
| engine | files pass | files fail | timeout | failed records |
|---|---|---|---|---|
| datafusion | 539 | 4 | 0 | 12 |
| ballista-static | 307 | 236 | 0 | 4002 |
| ballista-aqe | 300 | 233 | 10 | 3848 |
The 4 DataFusion failures are timezone/DST casts. Ballista's lockfile has
arrow 60.2.0 and DataFusion 56.0.0 used 60.1.0, which most likely explains them.
### AQE vs static
These are records that pass on static but not on AQE, counted only where
both planners finished: 68 records.
**Wrong results.** Of the 27 result mismatches, most return the right rows
in an order that violates the query's `ORDER BY`. Some have no outer `ORDER
BY`, so those are only order-sensitive tests. The clear bugs:
- `pg_compat/pg_compat_window.slt:795`: `count(c3) OVER (PARTITION BY c2)`
next to `row_number() OVER (PARTITION BY c2, c9)` gives counts of 4, 5 and 7
where it should give 23, 22 and 14. A window partition appears to be split
across tasks.
- `join_disable_repartition_joins.slt:96`: `RIGHT SEMI JOIN … ORDER BY a2,
t2.b LIMIT 10` returns unsorted rows and the wrong top 10.
- Rows out of `ORDER BY` order:
- `lateral_join.slt` 185, 195, 205, 215, 308, 403 (`ORDER BY t1.id` over a
`LATERAL` / correlated aggregate)
- `push_down_topk_through_join.slt` 139, 229, 258, 445, 902, 1006, 1076,
1108, 1236, 1310 (`LEFT JOIN … ORDER BY b LIMIT n`)
- `push_down_filter_parquet.slt:1556`
- `union_by_name.slt:243`
**Planning errors**
- 24 records: `SelectJoinRule: null_aware LeftAnti join with 2 keys needs
the number of its NOT IN value keys, set it with with_null_aware_value_keys`.
These are correlated `NOT IN` subqueries in `null_aware_anti_join.slt` and
`null_aware_mark_join.slt`, for example `SELECT * FROM test_table t1 WHERE c1
NOT IN (SELECT c2 FROM test_table t2 WHERE t1.c1 = t2.c1)`.
- 15 records: the `SanityCheckPlan … after DistributedExchangeRule` failure
from #2942, an `ORDER BY` over a `UNION ALL` of constant branches. They are in
`select.slt`, `order_by_all.slt`, `string/concat.slt`,
`spark/string/concat.slt`, `sort_merge_join.slt`, `pg_compat_union.slt`,
`arrow_files.slt` and `datetime/timestamps.slt`.
- 2 records: `Internal error: Schema mismatch … Got: Schema { fields: [] }`,
for example `SELECT id FROM naconst_t1 WHERE 1 NOT IN (SELECT id FROM
naconst_t2) ORDER BY id`.
**Hangs.** 10 files time out on AQE only. One query reproduces it alone, and
static answers it immediately:
```sql
WITH empty AS (SELECT 10 WHERE false)
SELECT NULL IN (SELECT * FROM empty), NULL NOT IN (SELECT * FROM empty) FROM
(SELECT 1) t;
-- static: false true; AQE: never returns
```
In the other timeouts, the statement AQE stalls on (for example a `CREATE
TABLE … AS VALUES` in `functional_dependencies.slt`) passes alone. Those look
like an earlier query leaving the cluster stuck, and I haven't reduced them
yet. Timed out on AQE: `window`, `sort_pushdown`, `functional_dependencies`,
`order`, `null_aware_multi_column`, `piecewise_merge_join_matrix`,
`predicates`, `subquery_projection`, `subquery`, `union`.
### Static vs AQE
Records that fail on static only, apart from order-sensitive tests without
`ORDER BY`:
- `preserve_file_partitioning.slt:312`: `GROUP BY f_dkey ORDER BY f_dkey`
returns rows out of order.
- `pg_compat/pg_compat_window.slt:1029`: `Assertion failed:
window_expr[0].partition_by().len() == ordered_partition_by_indices.len()` with
several `RANGE` frames.
- `piecewise_merge_join_nested_nulls.slt` under its `batch_size = 1` matrix
entry: `cannot restrict a UnionExec branch to partitions []: its ProjectionExec
keeps a partition count of 1`. That is the static-planner side of what #2914
fixed for AQE.
### Failures on both planners
3,741 records in 226 files fail on both planners and pass on DataFusion.
Largest groups:
| records | cause |
|---|---|
| 2085 | `Invalid function` on the client.
`SessionState::upgrade_for_ballista` replaces the session's scalar, aggregate
and window functions with DataFusion's defaults, so Spark functions and UDFs
registered before `standalone_with_state` / `remote_with_state` are gone
(`format_string`, `pmod`, `parse_url`, …). The executor, built from the
original state, still has them. |
| 459 + 56 | `table … not found` / `doesn't exist`. Some are knock-ons of
the next row. Others name tables that `TestContext` registers for the file
(`table_with_metadata`, `range_partitioned`); I haven't looked into those yet. |
| 60 | `CREATE TABLE … AS SELECT arrow_cast(…)` fails with `Mismatch between
schema and batches`: the batches Ballista returns don't match the plan's schema
|
| 177 | task failures at runtime |
| 125 | `Internal error: Schema mismatch` |
| 188 | result mismatches |
| 49 + 9 | recursive CTEs: `RecursiveQueryExec` / `WorkTableExec` aren't
serializable |
| 43 | materialized CTEs: logical plan serde not implemented |
| 16 + 15 | `UPDATE` / `DELETE`: `MemUpdateExec` / `MemDeleteExec` aren't
serializable |
Next steps:
- Work around the function drop in the harness, or fix it in
`upgrade_for_ballista`, then re-run to get a real count for the both-planner
group.
- Reduce the stalled AQE runs.
- File issues for the AQE wrong results above.
- Add `max_partitions_per_task = 1` to the matrix.
I'll open the harness as a draft PR.
--
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]