Skip to content

Add vector query helpers#1617

Merged
abnegate merged 3 commits into
mainfrom
codex/add-vector-query-helpers
Jun 30, 2026
Merged

Add vector query helpers#1617
abnegate merged 3 commits into
mainfrom
codex/add-vector-query-helpers

Conversation

@atharvadeosthale

Copy link
Copy Markdown
Member

Summary

  • add vectorDot, vectorCosine, and vectorEuclidean query helpers across SDK query templates
  • add e2e query fixture coverage for the new helpers
  • include generated Rust query unit assertions and a Rector-required strict string cast

Verification

  • regenerated affected SDK examples with PHP 8.5 Docker: php, web, node, cli, react-native, dart, flutter, python, ruby, go, rust, dotnet, swift, apple, kotlin, android
  • docker run --rm -v "/Users/atharva/.codex/worktrees/a18c/sdk-generator":/app -w /app php:8.5-cli php vendor/bin/phpunit --testsuite Unit
  • docker run --rm -v "/Users/atharva/.codex/worktrees/a18c/sdk-generator":/app -w /app php:8.5-cli php vendor/bin/rector process --dry-run
  • uvx djlint templates/ --lint
  • smoke-tested generated PHP helper JSON output

@greptile-apps

greptile-apps Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds vectorDot, vectorCosine, and vectorEuclidean query helpers to every SDK template (Android, Dart, Deno, .NET, Flutter, Go, Kotlin, PHP, Python, React Native, Ruby, Rust, Swift, Web), along with matching e2e fixture calls in all per-language test files and expected JSON strings in Base.php. A minor Rector-required (string) cast is also applied in Language.php.

  • Vector query templates: All 13 SDK templates receive the three new static helpers; each wraps the vector in a single-element list so the JSON output is {\"values\":[[v1,v2,v3]]}, consistent with the expected fixtures in Base.php.
  • Type signatures: Language-idiomatic types are used throughout — number[] (TypeScript), []float64 (Go), List<double> (.NET/Swift), List<Number> (Kotlin), List<num> (Dart), array<float> (PHP); Rust uses the existing generic V: Into<Value> pattern.
  • Test coverage: Rust gains inline unit tests asserting method name, attribute, and individual vector element values; all other language e2e tests add the three println/console.log calls to drive fixture comparison.

Confidence Score: 5/5

All changes are purely additive — new methods alongside existing ones, no modifications to existing query logic — making this safe to merge.

The new vector methods follow the exact same structural pattern as the adjacent distance helpers across every SDK: same JSON envelope verified by both the per-SDK Rust unit tests and the cross-language Base.php fixture harness. No existing code paths are modified; the PHP Language.php cast is a no-op behavior change.

No files require special attention.

Important Files Changed

Filename Overview
src/SDK/Language.php Adds (string) cast before passing to \preg_replace in two places — a Rector-enforced strict-types fix with no behavior change.
templates/rust/src/query.rs.twig Adds vectorDot/vectorCosine/vectorEuclidean with V: Into<Value> generics (consistent with existing geo methods) and inline unit tests that verify method name, attribute, and individual vector element indexing.
tests/e2e/Base.php Adds three expected JSON strings for the new vector queries in the correct position (after distanceLessThan, before intersects), matching the order in all per-language test files.
templates/go/query.go.twig Adds three package-level Go functions with []float64 vector parameter, wrapping the slice inside []interface{}{} — consistent with existing distance helper patterns.
templates/dotnet/Package/Query.cs.twig Adds VectorDot/VectorCosine/VectorEuclidean with List<double> — a more precise type than the List<object> used by geo methods.
templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig Adds vector methods with List<Number> (appropriate supertype) without KDoc comments, unlike the adjacent distanceLessThan which is fully documented.
templates/android/library/src/main/java/io/package/Query.kt.twig Same as kotlin template — adds three vector helpers without KDoc, consistent with the parallel SDK template.
templates/web/src/query.ts.twig Adds three fully JSDoc-documented vector query statics with number[] — consistent with all other TypeScript templates (deno, react-native).
templates/php/src/Query.php.twig Adds three fully PHPDoc-annotated vector helpers with array<float> parameter type — complete and idiomatic for the PHP template.
templates/python/package/query.py.twig Adds three @staticmethod vector helpers without type hints, consistent with existing Python template methods like distance_less_than.
templates/rust/tests/tests.rs Adds smoke-test println calls for the three new vector methods using serde_json json! macro — no assertions, just output verification.

Reviews (3): Last reviewed commit: "Add vector query calls to Rust e2e" | Re-trigger Greptile

@abnegate abnegate merged commit fa07d52 into main Jun 30, 2026
59 checks passed
@abnegate abnegate deleted the codex/add-vector-query-helpers branch June 30, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants