apache / apache/datafusion

Fix `csv_query_approx_count` once binary type coercion PR is merged

Offen
#3,353 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Rust
Sterne
9.3k
Forks
2.4k
Ø Merge
3 T. 11 Std.
Gemergte PRs (30 T.)
360

Beschreibung

**Describe the bug**

`csv_query_approx_count` fails due to an edge case exposed in https://github.com/apache/arrow-datafusion/pull/3222

The test fails with:

```
"Plan(\"Aggregations require unique expression names but the expression \\\"APPROXDISTINCT(#aggregate_test_100.c9)\\\" at position 0 and \\\"APPROXDISTINCT(CAST(#aggregate_test_100.c9 AS Utf8))\\\" at position 1 have the same name. Consider aliasing (\\\"AS\\\") one of them.\")
```

However, the expressions are already aliased. The alias is dropped before the error check above and this part of the codebase needs some reworking. It is not trivial to fix.

**To Reproduce**

```
#[tokio::test]
async fn csv_query_approx_count() -> Result<()> {
let ctx = SessionContext::new();
register_aggregate_csv(&ctx).await?;
let sql = "SELECT approx_distinct(c9) count_c9, approx_distinct(cast(c9 as varchar)) count_c9_str FROM aggregate_test_100";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+----------+--------------+",
"| count_c9 | count_c9_str |",
"+----------+--------------+",
"| 100 | 99 |",
"+----------+--------------+",
];
assert_batches_eq!(expected, &actual);
Ok(())
}
```

**Expected behavior**
Should pass

**Additional context**
None

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem csv_query_approx_count-Reproducer, einschließlich register_aggregate_csv, execute_to_batches und des im Issue gezeigten Aggregationsfehlers. Verfolge, wo Aliase vor der Prüfung auf doppelte Ausdrücke behandelt werden, und bestätige, dass die Abfrage die erwarteten Ergebnisse 100 und 99 liefert, sobald die Änderung zur binären Typkoersion verfügbar ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust, sql
Bereich
databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.