docs: JS UDF dictionary access page + UDA _tp_delta changelog contract - #658
docs: JS UDF dictionary access page + UDA _tp_delta changelog contract#658yokofly wants to merge 2 commits into
Conversation
…ntract Closes #347, closes #631. New page `js-udf-dictionary.md` documents the global getValue / setValue / batchGetValues / batchSetValues functions available in JavaScript UDFs and UDAFs, covering prerequisites (DIRECT / COMPLEX_KEY_DIRECT layout over a mutable stream), key and value shapes, per-function reference, an end-to-end stateful UDF example, and limitations. The missing-key contract is documented from the engine behavior rather than the issue description: getValue/batchGetValues return a default-filled object for an absent key, and only return null when the `javascript_udf_getvalue_null_on_missing_key` setting is enabled. The setting, batchGetValues positional alignment, and by-name column projection all landed in 3.3.1, so the older-build differences are called out separately along with a portable key-comparison pattern. For UDAs, add a "Changelog input" section to js-udf.md and py-udf.md describing the extra trailing `_tp_delta` argument the engine appends when the input is a changelog, when it applies, its shape, worked add/subtract examples, and its independence from has_customized_emit. remote-udf.md gets a one-line clarification: remote functions are always scalar and never see the column.
✅ Deploy Preview for elastic-elion-a958b6 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Review: JS UDF dictionary access page + UDA
|
…ions * Note that the getValue/batchGetValues missing-key fix was backported to Timeplus Enterprise 2.8.19 (timeplusd 2.8.45), so readers on the 2.8 line do not mistake the "Older builds" caveats for their own behavior. * Python UDA example: use `delta=None` instead of a mutable default, and drop the `self.count > 0` guard so the add/subtract logic matches the JS example. * Declare the JS example stream column as `float32` to match the function signature. * Split the INSERT snippets out of the CREATE STREAM/SELECT blocks with a lead-in sentence, so the expected values clearly describe the streaming query output rather than the inserts. * Add the words the new page introduces to the spellchecker dictionary; `yarn run spellcheck` is now clean on all four touched files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Closes #347
Closes #631
#347 — Dictionary access from JavaScript UDF
Adds
docs/js-udf-dictionary.md(linked from the UDF sidebar section and fromjs-udf.md), documenting the globalgetValue/setValue/batchGetValues/batchSetValuesfunctions: prerequisites, key/value shapes in JavaScript, per-function reference, an end-to-end stateful-UDF example, and limitations.The issue description had stale info, so the page was written from the engine instead. Two corrections worth calling out:
nullby default.getValue/batchGetValuesreturn a default-filled object (0,'', epoch — including the key columns).nullis opt-in via thejavascript_udf_getvalue_null_on_missing_keysetting, which defaults tofalseto preserve the legacy contract (src/Core/Settings.h). The page documents both modes side by side plus a portable key-comparison pattern that works under either. Behavior matches the reference output of99042_dictionary_access_missing_keys.batchGetValuespositional alignment, and by-name column projection all landed in 3.3.1 (#12253). Older-build differences — including the result-array shift after a miss, and projection requiring key columns first — are documented in their own subsection rather than presented as current behavior.Also dropped from the issue's draft:
getCardinalityis mentioned only as a footnote, sinceDirectDictionary::getElementCount()returns0and the page is scoped to DIRECT layouts.#631 — UDA
process()receives_tp_deltaon changelog inputAdds a "Changelog input" section to
docs/js-udf.md(#udaf-changelog) anddocs/py-udf.md(#uda-changelog) covering:changelog()table function, or an upstream that emits changelog),CREATE AGGREGATE FUNCTION(the engine appends it),undefinedon append-only input; in Python it must have a default value orprocess()raisesTypeErroron changelog input,has_customized_emit.Examples are adapted from the smoke tests that pin this contract (
0022_udf2/23–27,0041_python_udf_basic/09_changelog_uda_test1.yaml), so the code shown is known-good.One premise in the issue is stale: there is no Remote UDA.
UserDefinedFunctionFactory::tryGetAggregateFunctiononly handles the JavaScript and Python UDF types; anything else throwsUNSUPPORTED.remote-udf.mdalready said remote UDFs are not for aggregation — I extended that line to say explicitly that they are always scalar and therefore never receive the column, rather than adding a section describing a feature that doesn't exist.Verification
yarn buildfrom a clean.docusaurus/build: succeeds with no broken-link or broken-anchor warnings.bun tools/missing.js:js-udf-dictionary.mdis no longer unreferenced.yarn run spellcheckcould not run —spellcheckeris not installed in this environment.🤖 Generated with Claude Code