Skip to content

fix(cosmos): support quoted bracket property access in queries - #297

Open
thomhurst wants to merge 3 commits into
floci-io:mainfrom
thomhurst:fix/cosmos-bracket-property-access
Open

fix(cosmos): support quoted bracket property access in queries#297
thomhurst wants to merge 3 commits into
floci-io:mainfrom
thomhurst:fix/cosmos-bracket-property-access

Conversation

@thomhurst

@thomhurst thomhurst commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Queries such as IS_DEFINED(c.rsvpVersionsByUserId[""]) miss references stored only in an RSVP version map because quoted bracket members were unresolved.

Resolve quoted bracket members alongside dotted members, preserving dots, spaces, empty names, and escaped characters. Share property parsing with composite-index validation and preserve correlated subquery aliases of any length. Carry escaped quotes safely through whitespace normalization, parameter substitution, clause scanning, and projection. Bracket projections use decoded property names, and parameter values retain literal backslashes.

Validation:

  • Original four property tests and both initial review regressions failed before their respective fixes.
  • Three additional review regressions failed first: escaped keys in complete SQL queries, bracket projection names, and trailing backslashes in parameters.
  • All 142 Cosmos Java tests pass. Extended .NET Cosmos SDK test passes against the packaged JVM server, covering the erasure shape plus escaped and dotted property projections.
  • Full Java suite: 1,074 tests, one failure in unchanged SqlProvisioningServiceTest.boundsRetainedTerminalOperations, 14 existing skips. Retention sorts ConcurrentHashMap values only by endTime, so equal timestamps make the expected first eviction unspecified. The preceding full run passed with 1,073 tests. SQL files are unchanged.
  • Full diff reviewed and simplified; git diff --check passes.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extends the embedded Cosmos SQL evaluator to resolve quoted bracket property members consistently across predicates, projections, correlated subqueries, and composite-index validation.

  • Parses dotted and quoted bracket members through a shared property-path implementation.
  • Preserves escaped characters and literal backslashes throughout SQL normalization, parameter substitution, and clause scanning.
  • Uses decoded bracket member names for projected output.
  • Adds focused Java regressions and an end-to-end .NET Cosmos SDK compatibility test.

Confidence Score: 5/5

The PR appears safe to merge; the previous query-resolution findings are fixed and no new actionable regressions remain.

The current implementation defines and uses the shared helper successfully, recognizes correlated aliases without the former length limit, preserves quoted dots during index normalization, and safely carries escaped bracket keys and parameter backslashes through parsing and projection. All previous findings are resolved in the current code.

Important Files Changed

Filename Overview
src/main/java/io/floci/az/services/cosmos/CosmosQueryEngine.java Adds shared quoted-member parsing, safe string handling, unlimited correlated aliases, and decoded bracket projection names without a remaining actionable defect.
src/main/java/io/floci/az/services/cosmos/CosmosIndexingPolicy.java Reuses parsed property members so quoted dots remain within one composite-index path segment.
src/test/java/io/floci/az/services/cosmos/CosmosBracketPropertyTest.java Covers bracket-member resolution, escaped keys, projection names, parameter backslashes, correlated aliases, and index normalization.
compatibility-tests/sdk-test-dotnet/CosmosBracketPropertyCompatibilityTests.cs Verifies the bracket-property behavior and decoded projection shape through the real .NET Cosmos SDK.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    SDK[Cosmos SDK query] --> Substitute[Substitute parameters]
    Substitute --> Scan[Normalize and scan SQL clauses]
    Scan --> Parse[propertyNames parses dotted and bracket members]
    Parse --> Resolve[Resolve document or correlated-scope values]
    Parse --> Index[Normalize composite-index paths]
    Resolve --> Project[Project using decoded member names]
    Project --> Result[Cosmos-compatible result]
Loading

Reviews (3): Last reviewed commit: "fix(cosmos): preserve quoted keys throug..." | Re-trigger Greptile

Comment thread src/main/java/io/floci/az/services/cosmos/CosmosQueryEngine.java
Comment thread src/main/java/io/floci/az/services/cosmos/CosmosQueryEngine.java Outdated
Comment thread src/main/java/io/floci/az/services/cosmos/CosmosQueryEngine.java
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