Skip to content

Add SQL filter compilation for properties JSON#1291

Open
edwinyyyu wants to merge 4 commits intoMemMachine:mainfrom
edwinyyyu:sql_json_properties
Open

Add SQL filter compilation for properties JSON#1291
edwinyyyu wants to merge 4 commits intoMemMachine:mainfrom
edwinyyyu:sql_json_properties

Conversation

@edwinyyyu
Copy link
Copy Markdown
Contributor

@edwinyyyu edwinyyyu commented Apr 1, 2026

Purpose of the change

Needed for SQLAlchemySegmentStore, SQLite VectorStore implementations.

Description

Old:
Based on #1201 for some utilities.

1201 --> 1291 --> 1292
    |         \-> 1199 --> 1205
     \-> 1086

New:
Based on #1296.

1201 (merged) --> 1296 (merged) --> 1291 --> 1292
                               |         \-> 1199 --> 1205
                                \-> 1086

Add unified, well-tested way to encode/decode properties as SQL JSON to avoid repeated reimplementation.

Consumers of existing behavior are modified to use raw JSON encoding -- they may be moved to properties JSON in the future if appropriate. In particular, existing consumers of existing compile_sql_filter do not handle datetimes (no way of handling type collisions -- the new method uses a discriminated union).

Type of change

Breaking: filters will no longer ignore unknown keys.

It's confusing and potentially dangerous (especially with more complex filters including NOT, AND, OR) what treating unknown keys as None is supposed to mean. New behavior: If a filter is meant to be sent to multiple memories simultaneously, then all memories must support those fields.

It maybe would be okay if it obeyed SQL 3VL, but there is no case where a filter on one memory's field should affect the filter for another memory.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g., code style improvements, linting)
  • Documentation update
  • Project Maintenance (updates to build scripts, CI, etc., that do not affect the main project)
  • Security (improves security without changing functionality)

How Has This Been Tested?

  • Unit Test
  • Integration Test
  • End-to-end Test
  • Test Script (please provide)
  • Manual verification (list step-by-step instructions)

Checklist

[Please delete options that are not relevant.]

  • I have signed the commit(s) within this pull request
  • My code follows the style guidelines of this project (See STYLE_GUIDE.md)
  • I have performed a self-review of my own code
  • I have commented my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • Confirmed all checks passed
  • Contributor has signed the commit(s)
  • Reviewed the code
  • Run, Tested, and Verified the change(s) work as expected

@edwinyyyu edwinyyyu force-pushed the sql_json_properties branch from 6ccc211 to 7715ed4 Compare April 1, 2026 22:02
@edwinyyyu edwinyyyu marked this pull request as draft April 1, 2026 22:38
@edwinyyyu
Copy link
Copy Markdown
Contributor Author

edwinyyyu commented Apr 1, 2026

Need to support system-defined metadata too. Will combine with existing compile_sql_filter.

@edwinyyyu edwinyyyu force-pushed the sql_json_properties branch from 7715ed4 to a9e83e5 Compare April 2, 2026 00:19
@edwinyyyu edwinyyyu marked this pull request as ready for review April 2, 2026 00:20
@edwinyyyu edwinyyyu changed the title Add SQL JSON properties utilities Add SQL filter compilation for properties JSON Apr 2, 2026
@edwinyyyu
Copy link
Copy Markdown
Contributor Author

Discovered client tests were wrong all along -- filters silently failed before. Need to fix.

@edwinyyyu edwinyyyu force-pushed the sql_json_properties branch from 842325b to 631cc96 Compare April 2, 2026 05:21
@edwinyyyu edwinyyyu modified the milestones: v0.3.5, v0.3.4 Apr 2, 2026
Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
@edwinyyyu edwinyyyu force-pushed the sql_json_properties branch from 631cc96 to e431c68 Compare April 3, 2026 00:01
Signed-off-by: Edwin Yu <edwinyyyu@gmail.com>
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.

1 participant