Commit 5851bdb
authored
Resolve SQL unified query gaps for SELECT clauses and window functions (#5450)
* fix(calcite): handle Limit, Alias projection, RelationSubquery, and Values dual-table in visitor
Add visitLimit to support LIMIT/OFFSET clauses. Handle Alias nodes in
project list by referencing already-computed aggregate fields instead of
re-analyzing. Add visitRelationSubquery for derived tables in FROM
clause. Fix visitValues to treat a single empty row as a dual-table
(SELECT without FROM). Make bucketNullable lookup null-safe with
getOrDefault in visitAggregation.
Add integration tests covering LIMIT OFFSET, aggregate with alias,
GROUP BY without bucket nullable, SELECT with alias, derived table
subquery, and SELECT without FROM clause.
Signed-off-by: Chen Dai <daichen@amazon.com>
* feat(calcite): support window functions, ROW_NUMBER, and register ISNULL
Add AggregateFunction handling in visitWindowFunction to support
aggregate-based window expressions with DISTINCT and ORDER BY keys.
Add translateOrderKeys utility for window ORDER BY translation.
Register row_number in WINDOW_FUNC_MAPPING and skip aggregate
signature validation for it (it has no field/args). Pass distinct
flag through makeOver call chain.
RANK and DENSE_RANK are deferred to a follow-up alongside the open
PPL eventstats/streamstats issue (#5168) which involves the same
function registration and a separate ORDER BY semantics question.
Register ISNULL as alias for IS_NULL in PPLFuncImpTable.
Add integration tests for window functions with ORDER BY,
ROW_NUMBER, COUNT DISTINCT OVER, and ISNULL.
Signed-off-by: Chen Dai <daichen@amazon.com>
---------
Signed-off-by: Chen Dai <daichen@amazon.com>1 parent dcdb5ba commit 5851bdb
6 files changed
Lines changed: 267 additions & 15 deletions
File tree
- api/src/test/java/org/opensearch/sql/api
- core/src/main/java/org/opensearch/sql
- calcite
- utils
- expression/function
Lines changed: 150 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 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 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
262 | 412 | | |
Lines changed: 36 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
| |||
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
| |||
542 | 544 | | |
543 | 545 | | |
544 | 546 | | |
545 | | - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
546 | 559 | | |
547 | 560 | | |
548 | 561 | | |
| |||
766 | 779 | | |
767 | 780 | | |
768 | 781 | | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
769 | 789 | | |
770 | 790 | | |
771 | 791 | | |
| |||
1624 | 1644 | | |
1625 | 1645 | | |
1626 | 1646 | | |
1627 | | - | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
1628 | 1650 | | |
1629 | 1651 | | |
1630 | 1652 | | |
| |||
1931 | 1953 | | |
1932 | 1954 | | |
1933 | 1955 | | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
1934 | 1964 | | |
1935 | 1965 | | |
1936 | 1966 | | |
| |||
4125 | 4155 | | |
4126 | 4156 | | |
4127 | 4157 | | |
4128 | | - | |
| 4158 | + | |
| 4159 | + | |
| 4160 | + | |
4129 | 4161 | | |
4130 | 4162 | | |
4131 | | - | |
4132 | | - | |
4133 | 4163 | | |
| 4164 | + | |
4134 | 4165 | | |
4135 | 4166 | | |
4136 | 4167 | | |
| |||
Lines changed: 63 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
563 | 568 | | |
564 | 569 | | |
565 | 570 | | |
566 | | - | |
567 | | - | |
568 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
569 | 590 | | |
570 | 591 | | |
571 | 592 | | |
572 | 593 | | |
573 | 594 | | |
574 | | - | |
| 595 | + | |
| 596 | + | |
575 | 597 | | |
576 | 598 | | |
577 | 599 | | |
578 | 600 | | |
579 | 601 | | |
580 | 602 | | |
581 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
582 | 616 | | |
583 | 617 | | |
584 | 618 | | |
585 | 619 | | |
586 | 620 | | |
587 | 621 | | |
588 | 622 | | |
| 623 | + | |
589 | 624 | | |
590 | 625 | | |
591 | 626 | | |
592 | | - | |
| 627 | + | |
593 | 628 | | |
594 | 629 | | |
595 | 630 | | |
596 | 631 | | |
| 632 | + | |
597 | 633 | | |
598 | 634 | | |
599 | 635 | | |
600 | | - | |
| 636 | + | |
601 | 637 | | |
602 | 638 | | |
603 | 639 | | |
604 | | - | |
605 | | - | |
606 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
607 | 661 | | |
608 | 662 | | |
609 | 663 | | |
| |||
0 commit comments