feat(hex2int): add hex2int UDF for SQLite and Postgres#67
Open
kronosapiens wants to merge 4 commits intodojoengine:mainfrom
Open
feat(hex2int): add hex2int UDF for SQLite and Postgres#67kronosapiens wants to merge 4 commits intodojoengine:mainfrom
kronosapiens wants to merge 4 commits intodojoengine:mainfrom
Conversation
Enables built-in SQLite aggregation functions (MAX, MIN, SUM, etc.) on hex-encoded integer columns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch the SQLite UDF to sqlite3_auto_extension so every connection in-process (including the /sql endpoint's AnyPool) gets hex2int without per-connection wiring. Add a matching public.hex2int() in the introspect-postgres-sink migrations, handling hex strings up to 256 bits by keeping only the lower 64 bits. Wire install_udfs() into EcsService::new, and add a Postgres integration test plus a postgres:16 service to the CI test job. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Use pointer::cast() instead of `as *const _`, and replace match-on-Result with if-let/else to address ptr_as_ptr and single_match_else lints failing CI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…Migrator The raw Migrator::run doesn't create the `introspect` schema that migration 002 writes into, so the test panicked with "schema \"introspect\" does not exist". Use SchemaMigrator, which matches how the sink itself runs these migrations in processor.rs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
hex2int(text) -> int64SQL function that converts hex-encoded integer strings (with or without0x/0Xprefix) to signed 64-bit integers, enabling built-in aggregation on hex-string columns.sqlite3_auto_extensionincrates/sqlite/src/udf.rs.install_udfs()is called once fromEcsService::new, so every connection in the process — including the/sqlendpoint'sAnyPool— picks it up automatically with no per-connection wiring.public.hex2int()shipped as migration004_hex2int_function.sqlunderintrospect-postgres-sink, so it lands on any Postgres DB the ECS sink initializes.Test plan
cargo test -p torii-sqlite— SQLite UDF unit tests (basic, no prefix, u64::MAX, NULL, zero, uppercase prefix, 256-bit zero-padded, 256-bit with non-zero high bits).cargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkpostgres:16service on thetestjob runs the Postgres integration test incrates/introspect-postgres-sink/tests/hex2int.rsagainst the real migration. Test is skipped locally whenDATABASE_URLis unset.🤖 Generated with Claude Code