feat(extension-paradedb): query ops and demo#433
Draft
SevInf wants to merge 2 commits intopsl-index-plusfrom
Draft
feat(extension-paradedb): query ops and demo#433SevInf wants to merge 2 commits intopsl-index-plusfrom
SevInf wants to merge 2 commits intopsl-index-plusfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-telemetry
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
Adds the paradedb extension query plane on top of upstream bm25 index-type
registration:
- 11 query operations via two shared helpers — matchOp for the five
match-mode operators (paradeDbMatch @@@, paradeDbMatchAny |||,
paradeDbMatchAll &&&, paradeDbTerm ===, paradeDbPhrase ###) and
typmodCastOp for the four typmod casts (paradeDbFuzzy, paradeDbBoost,
paradeDbConst, paradeDbSlop). Cast args wrap a JS-side integer in
LiteralExpr.of(n) because PG rejects parameterized typmods; per-op
validators enforce the documented ranges.
- paradeDbScore (pdb.score(key)) and ParadeDbProximityChain — an
immutable builder with .within(distance, term, { ordered? }) for
arbitrary-length chains mixing ## and ##>. Distances render as
LiteralExpr (chained ##/##> only accept literal slop). The chain
implements Expression<text> so it composes directly through
paradeDbMatch via the @@@ overload.
- pg_search install via SqlControlExtensionDescriptor.databaseDependencies.
examples/paradedb-demo runs every operation end-to-end against a live
paradedb container. Contract authored with the new shape:
constraints.index([cols...], { type: "bm25", options: { key_field: "id" },
name: "item_bm25_idx" }). docker-compose.yaml + init script create a
dedicated demo database to sidestep the paradedb image preloaded PostGIS
tables in the default database. CLI commands: match, top, fuzzy,
proximity, proximity-chain, chain-demo, mode-tour (curated tour of the
five match modes against contrastive seed data), cast-demo.
Also fixes a pre-existing introspection bug in adapter-postgres: the
indexes query ordered columns by pg_attribute.attnum (table declaration
order) rather than by position within pg_index.indkey (the index key
order). Multi-column indexes whose declared column order differs from
the table column declaration order would spuriously fail schema
verification — including any contract whose columns get alphabetized
during canonicalization while an index declares its own ordering.
6af7b34 to
e5643ee
Compare
…onTypes Drop matchOp/typmodCastOp helpers and inline all 11 entries in a record annotated with `DescriptorMap<CT>`, a mapped type derived from `QueryOperationTypes<CT>`. Renaming a method or changing a return codec in the type module now fails typecheck inside `descriptor-meta.ts` instead of silently drifting into a runtime mismatch.
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.
Intent
Wire up the paradedb extension's query plane on top of the bm25 index-type registration that landed on
psl-index-plus. Authoring + emit + DDL already work via the upstream registry; this PR adds the runtime-side: a complete set of paradedb query operations, the proximity chain builder, and an end-to-end CLI demo that exercises everything against a live paradedb container.Change map
The extension itself (
packages/3-extensions/paradedb) gains:src/core/descriptor-meta.ts:matchOpcovers the five match-mode operators (paradeDbMatch/@@@,paradeDbMatchAny/|||,paradeDbMatchAll/&&&,paradeDbTerm/===,paradeDbPhrase/###).typmodCastOpcovers the four typmod casts (paradeDbFuzzy,paradeDbBoost,paradeDbConst,paradeDbSlop). Each wraps its integer argument inLiteralExpr.of(n)because Postgres rejects parameterized typmods, with per-op range validators.paradeDbScoreforpdb.score(<key>).ParadeDbProximityChaininsrc/core/proximity-chain.ts— an immutable builder with.within(distance, term, { ordered? })for multi-step chains mixing##and##>. Distances render asLiteralExpr(chained operators only accept literal slop). The chain implementsExpression<text>so it composes throughparadeDbMatchvia the@@@overload.src/exports/runtime.tsandpg_searchinstall viaSqlControlExtensionDescriptor.databaseDependencies.examples/paradedb-demois a new CLI example.prisma/contract.tsauthors a singleItemmodel with a bm25 index using the upstreamconstraints.index([...], { type: 'bm25', options: { key_field: 'id' } })shape;pnpm db:initproduces the actualCREATE INDEX … USING bm25 …DDL via the registry path. Adocker-compose.yamlplusinit/01-create-demo-db.sqlcreate a dedicateddemodatabase to sidestep the paradedb image's preloaded PostGIS tables.CLI commands:
match,top,fuzzy,proximity,proximity-chain,chain-demo(hardcoded multi-step + mixed direction),mode-tour(curated comparison of the five match modes against contrastive seed data), andcast-demo(boost/const/slop).Also includes a small adapter fix in
packages/3-targets/6-adapters/postgres/src/core/control-adapter.ts— index introspection now orders columns byarray_position(indkey, attnum)rather thanattnum, so multi-column indexes whose declared column order differs from the table's column declaration order satisfy schema verification.Behavior evidence
pnpm start -- mode-tourreturns distinct, contrastive results across the five match modes against the seed data, demonstrating each operator's character (any vs all vs term vs phrase).pnpm start -- cast-demoshows boost/const/slop modifying the BM25 score as expected (pdb.boost(5)raises score ~2 → ~10;pdb.const(1)flattens to 1;pdb.slop(1)matches non-adjacent phrase tokens).Follow-ups / open questions
paradeDbFuzzy/Boost/Const/Slopare typed as returningpg/text@1; actual SQL types are paradedb-specific (pdb.fuzzy,pdb.boost, etc.). The TS fudge works because match operators are overloaded to accept these types alongsidetext, but a more honest typing would introduce a paradedb codec.text[]query input (term-set withARRAY[...], pretokenized phrase) is deferred pending scalar-list support.'q'::pdb.whitespace), highlight (pdb.snippet*), aggregations, and search-time joins are not yet exposed.Non-goals
type/options, and PSL@@indexparsing all live inpsl-index-plus, not here.bm25Index({...})andbm25.text/numeric/...authoring helpers the original branch carried were intentionally dropped in favor of the genericconstraints.index({ type, options })registry path.