Add explicit lookup.key and lookup.semantic operations - #1193
Closed
mborodii-prog wants to merge 1 commit into
Closed
mborodii-prog wants to merge 1 commit into
mborodii-prog wants to merge 1 commit into
Conversation
9 tasks
mborodii-prog
deleted the
feat/Add-lookup.key-and-lookup.semantic-operations-and-runtime-contract
branch
September 25, 2026 06:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related discussion: wrangleworks/Wrangles-Docs#34
What changes
Adds explicit
lookup.keyandlookup.semanticoperations so callers can state which saved-model lookup behavior they expect. Previously, recipes used the genericlookupoperation and the model's stored variant determined the behavior.The new operations validate the model before lookup execution:
lookup.keylookupkeylookup.semanticlookupembedding/wrangles/lookupAPI.lookupcallable and its existing behavior available.by_row,by_dataframe, andby_matrixrecipe modes.by_matrixrequiresmatrix_variables.noutsideby_rowfor the new recipe operations, instead of silently ignoring it.Examples
Use existing saved-model execution IDs for
KEY_MODEL_IDandSEMANTIC_MODEL_ID. In Excel, define these recipe variables or replace the placeholders with the actual IDs. Catalog IDs such as101and102are not execution model IDs.The examples below use the actual field names from the manual Excel fixtures:
Column1contains values such asBoltandNut, and the semantic model also exposesScore. If a model stores its value underOutput, useOutputinstead ofColumn1on the left side of the mapping.Select the input table, including headers, before running each Excel recipe.
Key lookup with a named output field
For an input column
SKUcontainingABC-001andABC-002:For the test model,
OutputcontainsBoltandNutas individual field values.Semantic lookup with a value and score
In the manual Excel test, both
steel boltandsteel bolt eight millimetrematched the stored bolt description and returnedBolt. The value and score appeared in separate columns, with all six input rows and theirRowIDorder preserved.Full records and multiple semantic matches
An output name that does not match a stored field receives the complete record. For example,
output: MatchRecordreturns a dictionary containing the model's fields rather than selecting one field.To distribute three semantic matches into separate columns:
Match 1,Match 2, andMatch 3contain match dictionaries. This uses the existing backend ranking and does not introduce a new scoring algorithm.Direct Python calls
For a single match, passing one column name returns its values; passing a list of column names returns rows of values. Omitting
columnsreturns complete records. Withn > 1, matches remain dictionaries.How it was verified
Automated
Verified against commit
d8db39bawith local Python 3.12:Result: 75 passed. These are offline tests with stubbed model metadata and API responses; they do not establish live-service or Python 3.14 CI results.
Coverage includes explicit variant validation, wrong-purpose models, legacy lookup behavior, Python return shapes, forwarded arguments and batching, all three recipe modes, output renaming, wildcard match expansion, empty inputs,
wherefiltering, DataFrame accessors, and generated recipe schemas. The branch diff also passesgit diff --check.Manual Excel verification
OutputandScorecolumns.RowIDorder were preserved.lookup.semanticwith legacylookupreturned the sameOutputvalues and row order for the tested model.The manual checks above are a subset of the prepared test plan. They do not claim that the full Excel suite, including top-n and negative cases, has passed.
Compatibility and risk
semanticare rejected by the new names; genericlookupretains its existing handling.variant=embedding; the operation name islookup.semantic.lookupin recipes that adopted the explicit names. Existing model data needs no migration.Remaining verification and known limitations
Score=1.001for the explicit semantic call andScore=1for legacy lookup on the first row; the other displayed scores and all output labels matched. Both paths share the same API implementation, but the cause of this observed difference has not been established. Exact score parity remains unverified.n > 1with a single named model-field output can raiseColumns must be same length as key. It was reproduced offline with both generic and explicit lookup. Use a wildcard such asMatch *or an unnamed output such asMatchesfor that case.Ready-for-review checklist
mainand has no merge conflicts