Commit cb5a0de
committed
fix(calcite): preserve SQL aggregate aliases in plan
SELECT col, COUNT(*) AS cnt produces an identity-shaped projection that
only renames a field. RelBuilder.project (force=false) treats such a
rename-only projection over unchanged columns as a no-op and skips
emitting the LogicalProject, so the alias was dropped from the output
schema (the column came back as the raw expression name, e.g. COUNT(*)).
Force the projection only when an AS genuinely renames a field, mirroring
how Calcite's own SqlToRelConverter materializes SELECT-list aliases. The
PPL path is unaffected: it never produces an AS RexCall through
visitProject (rename/eval/fields/stats build output names differently).
Signed-off-by: Chen Dai <daichen@amazon.com>1 parent ea39ffd commit cb5a0de
2 files changed
Lines changed: 56 additions & 1 deletion
File tree
- api/src/test/java/org/opensearch/sql/api
- core/src/main/java/org/opensearch/sql/calcite
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
358 | 394 | | |
359 | 395 | | |
360 | 396 | | |
| |||
Lines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
485 | 489 | | |
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
489 | 508 | | |
490 | 509 | | |
491 | 510 | | |
| |||
0 commit comments