Skip to content

Fix inline property filter support for ANY graph queries#453

Closed
aheev wants to merge 1 commit intoLadybugDB:mainfrom
aheev:fix-filter-open-graph
Closed

Fix inline property filter support for ANY graph queries#453
aheev wants to merge 1 commit intoLadybugDB:mainfrom
aheev:fix-filter-open-graph

Conversation

@aheev
Copy link
Copy Markdown
Contributor

@aheev aheev commented May 4, 2026

Two bugs prevented MATCH (a:Label { prop: val }) from working in ANY graphs:

  1. JSON string serialization mismatch in ColumnCaster (scan_table.cpp): yyjson_val_write() serialized JSON strings as '"Alice"' (with JSON quote delimiters), but CAST(STRING → JSON) on the RHS produced 'Alice' (no delimiters). Numbers accidentally worked because both sides produced '30'. Fix: add jsonExtractScalarToString() which uses yyjson_get_str() for string JSON values (returns raw string content), falling back to jsonToString() for numbers and booleans.

  2. Cardinality estimator crash (cardinality_estimator.cpp): getTableStatsIfPossible() called entry->getColumnID(propertyName) without checking whether the property actually exists as a column. In ANY graphs, properties like 'age' are stored as JSON in the 'data' column — not as individual columns — so nameToPropertyIDMap.at('age') threw unordered_map::at. Fix: add entry->containsProperty(propertyName) guard before getColumnID call.

Also updates the QueryDynamicProperties test expectation: with the scan fix, string properties now return unquoted values (e.g., Alice instead of "Alice"), consistent with regular graph property access.

Adds four new test cases to test/test_files/graph/any.test:

  • InlineIntPropertyFilter
  • InlineStringPropertyFilter
  • InlinePropertyFilterReturnStar
  • InlinePropertyFilterNoMatch

Closes #451

Two bugs prevented MATCH (a:Label { prop: val }) from working in ANY graphs:

1. JSON string serialization mismatch in ColumnCaster (scan_table.cpp):
   yyjson_val_write() serialized JSON strings as '"Alice"' (with JSON quote
   delimiters), but CAST(STRING → JSON) on the RHS produced 'Alice' (no
   delimiters). Numbers accidentally worked because both sides produced '30'.
   Fix: add jsonExtractScalarToString() which uses yyjson_get_str() for string
   JSON values (returns raw string content), falling back to jsonToString() for
   numbers and booleans.

2. Cardinality estimator crash (cardinality_estimator.cpp):
   getTableStatsIfPossible() called entry->getColumnID(propertyName) without
   checking whether the property actually exists as a column. In ANY graphs,
   properties like 'age' are stored as JSON in the 'data' column — not as
   individual columns — so nameToPropertyIDMap.at('age') threw unordered_map::at.
   Fix: add entry->containsProperty(propertyName) guard before getColumnID call.

Also updates the QueryDynamicProperties test expectation: with the scan fix,
string properties now return unquoted values (e.g., Alice instead of "Alice"),
consistent with regular graph property access.

Adds four new test cases to test/test_files/graph/any.test:
- InlineIntPropertyFilter
- InlineStringPropertyFilter
- InlinePropertyFilterReturnStar
- InlinePropertyFilterNoMatch

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aheev aheev mentioned this pull request May 4, 2026
@adsharma
Copy link
Copy Markdown
Contributor

adsharma commented May 4, 2026

This handles only the node filters. I was working on a more generic fix that handles both node and edge filters:

MATCH (a:User)-[e:livesIn {since: 2020}]->(c:City) RETURN e.since;

Please review the incoming PR. Main delta is it touches map_extend.cpp

@aheev
Copy link
Copy Markdown
Contributor Author

aheev commented May 5, 2026

fixed by #454

@aheev aheev closed this May 5, 2026
@aheev aheev deleted the fix-filter-open-graph branch May 5, 2026 14:48
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.

Bug: open type graph error

2 participants