fix: PolarDB compatibility with Apache AGE 1.5+ #1050
+158
−82
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.
fix: PolarDB compatibility with Apache AGE 1.5+
Problem
PolarDB queries fail with newer versions of Apache AGE (1.5+) due to strict type checking in
agtype_access_operator():Error Example
Root Cause
Apache AGE 1.5+ requires explicit type casting of the
propertiescolumn (which isjsonb) toagtypebefore usingagtype_access_operator().The operator signature expects:
But the code was passing:
Solution
Add explicit type casting
properties::text::agtypein allagtype_access_operator()calls:Two-step casting:
jsonb → text → agtypeproperties::text- Convert JSONB to text representation::agtype- Parse text as agtype (AGE's graph type)This ensures type compatibility with Apache AGE's strict type checking.
Changes
Affected Locations (104 instances)
Applied systematic fix to all
agtype_access_operator()calls in:Pattern Applied
Debug Addition
Added initialization logging for troubleshooting:
Apache AGE Version Compatibility
Testing
Test Environment
Test Cases
All queries now execute without type errors.
Migration Guide
For Users on AGE 1.4.x
No action needed - backward compatible.
For Users on AGE 1.5+
Update to this version to fix query errors. No data migration required.
For New Installations
Works out of the box with all AGE versions.
Performance Impact
Negligible - type casting is compile-time operation:
Benchmarked on 100K nodes:
Breaking Changes
None - This is a pure bugfix for compatibility.
Alternative Solutions Considered
❌ Option 1: Change column type to agtype
Rejected: Breaking change, requires data migration.
❌ Option 2: Create wrapper function
Rejected: Adds complexity, harder to maintain.
✅ Option 3: Explicit casting (chosen)
Minimal change, backward compatible, clear intent.
Related Issues
Checklist
References