[Feature] Add PPL outputlookup command (synchronous terminal write sink)#5621
[Feature] Add PPL outputlookup command (synchronous terminal write sink)#5621noCharger wants to merge 8 commits into
Conversation
PR Reviewer Guide 🔍(Review updated until commit a986700)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to a986700 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 7faebf1
Suggestions up to commit d39455c
Suggestions up to commit 4c9fb21
Suggestions up to commit 92cfd5f
Suggestions up to commit 9476e41
|
Adds the PPL outputlookup command: a synchronous terminal sink that materializes pipeline rows into a lookup index and returns a single rows_written count. Owned write path, independent of collect. Parse layer - Grammar tokens OUTPUTLOOKUP, OVERRIDE_IF_EMPTY, KEY_FIELD plus the outputlookupCommand rule; key_field accepts a comma-separated field list; kept usable as an identifier. - OutputLookup AST node and AstBuilder (key_field defaults append to true). - Analyzer rejects it on the V2 path (Calcite only). Terminal sink - OutputLookupTableModify extends Calcite TableModify (INSERT): the optimizer treats it as a mandatory table-modifying side effect and it exposes the standard rowcount row type. A dedicated rule lowers it to the physical EnumerableOutputLookup, wiring in the in-cluster node client. - OutputLookupWriteExec: schema inference (reserved metadata fields excluded), overwrite via a fresh backing index plus atomic alias swap, append to the current backing, override_if_empty empty guard, and a max row cap. The destination is created on demand. - Full-result write: the input is eagerly drained and the source scan pages via PIT, so a source larger than the result window is written in full. Write core - OpenSearchBulkWriter: batched bulk with 429 backoff retry; non-429 and retry-exhausted failures throw rather than being swallowed. APPEND uses an auto id, UPSERT uses a deterministic id from key_field. - LookupIdEncoder: id is base64url(SHA-256(length-prefixed canonical key)), a bounded 43-char string; multi-field keys cannot collide across boundaries, empty differs from null, and multivalue keys are rejected. Tests - Unit: parse (6), writer (5), id encoder (5), schema inference (1). - Integration: CalcitePPLOutputLookupIT (9) covering rowcount return, alias-swap overwrite, append, override_if_empty both ways, single- and multi-field key_field upsert, max, multivalue-as-array, and large-source no-truncation. Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
db5cd41 to
9476e41
Compare
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 9476e41.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit 9476e41 |
…orphan cleanup, authz) - Reject a key_field that is not a result field at plan time, so a misspelled or absent key can no longer collapse every row onto one _id. - Refuse when the destination name is already a concrete index (covers dest == source) instead of failing later on the alias swap. - On a failed overwrite, delete the freshly created backing so no orphan is left; document last-writer-wins concurrency and the crash/concurrent orphan reaper as a follow-up. - Document that writes run under the caller security context and the required destination permissions; add OutputLookupPermissionsIT proving a read-only user is denied. Tests: CalcitePPLOutputLookupIT grows to 12 (adds missing-key_field, concrete-index-dest, and failed-overwrite-no-orphan); OutputLookupPermissionsIT added under integTestWithSecurity. Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
|
Persistent review updated to latest commit 92cfd5f |
…kup-clean Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com> # Conflicts: # ppl/src/main/antlr/OpenSearchPPLParser.g4 # ppl/src/main/java/org/opensearch/sql/ppl/utils/PPLQueryDataAnonymizer.java
Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
|
Persistent review updated to latest commit 4c9fb21 |
…kup-clean Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com> # Conflicts: # ppl/src/main/java/org/opensearch/sql/ppl/parser/AstBuilder.java # ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java
|
Persistent review updated to latest commit d39455c |
…okups Overwrite of a shared/filtered (#11303) lookup now repoints the alias to a fresh dedicated backing and never deletes the shared index; only own <name>__ol_* unfiltered backings are deleted. Append onto a shared/filtered lookup is refused with migration guidance. Adds 2 ITs (migration + refusal). Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
…s-level probe Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
|
Persistent review updated to latest commit 7faebf1 |
Signed-off-by: Louis Chu <lingzhichu.clz@gmail.com>
|
Persistent review updated to latest commit a986700 |
Description
Implements the PPL
outputlookupcommand proposed in RFC #5625 — a synchronous, terminal write sink that materializes the current pipeline result into a lookup index and returns a singlerows_writtencount.The command's semantics, substrate (plain index per lookup), consistency contract (weak/eventual), the
<name>resolution/migration matrix, permission model, and alternatives considered are all covered in RFC #5625 and are not restated here — this PR is the implementation.Implementation highlights:
TableModify(INSERT) node — the optimizer treats it as a mandatory side effect (never dropped/reordered) and provides the rowcount row type.key_fieldupsert via a deterministic, collision-free_id; a multivalue key is rejected._meta.lookup; a non-lookup index is refused rather than clobbered.CalcitePPLOutputLookupIT,OutputLookupPermissionsIT, and unit tests.Related Issues
Addresses #5625
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.