Skip to content

Conversation

@SeasonPilot
Copy link
Contributor

@SeasonPilot SeasonPilot commented Nov 29, 2025

…n (#368)

Implement the ISO-GQL SAME predicate function to check if graph elements refer to the same entity by comparing their identities. This feature adds full ISO/IEC 39075:2024 Section 19.12 compliance for identity comparisons.

Changes:

  • Parser Layer:

    • Add SqlSameCall AST node for SAME function calls
    • Add SqlSameOperator with BOOLEAN return type and VARIADIC operands
    • Register operator in BuildInSqlOperatorTable
    • Add syntax tests with 4 GQL test cases
  • Runtime Layer:

    • Implement GeaFlowBuiltinFunctions.same() for identity comparison
      • Vertex comparison: compares vertex IDs using Objects.equals()
      • Edge comparison: compares both source and target IDs
      • Null handling: returns null following SQL ternary logic
      • Type safety: returns false for mismatched types
    • Add BuildInExpression.SAME constant for expression translation
    • Register SAME in ExpressionTranslator.processOtherTrans()
  • Testing:

    • Add comprehensive SameTest with 13 unit tests (100% pass rate)
    • Test coverage: identical/different IDs, null handling, mixed types, string IDs, invalid types

Implementation follows Approach 1 (Built-in Function Pattern) with minimal code changes (441 lines added across 9 files) for maximum simplicity and maintainability.

Example usage:
MATCH (a)->(b)->(c) WHERE SAME(a, c) RETURN a, b, c;

What changes were proposed in this pull request?

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

apache#368)

Implement the ISO-GQL SAME predicate function to check if graph elements
refer to the same entity by comparing their identities. This feature adds
full ISO/IEC 39075:2024 Section 19.12 compliance for identity comparisons.

Changes:
- Parser Layer:
  * Add SqlSameCall AST node for SAME function calls
  * Add SqlSameOperator with BOOLEAN return type and VARIADIC operands
  * Register operator in BuildInSqlOperatorTable
  * Add syntax tests with 4 GQL test cases

- Runtime Layer:
  * Implement GeaFlowBuiltinFunctions.same() for identity comparison
    - Vertex comparison: compares vertex IDs using Objects.equals()
    - Edge comparison: compares both source and target IDs
    - Null handling: returns null following SQL ternary logic
    - Type safety: returns false for mismatched types
  * Add BuildInExpression.SAME constant for expression translation
  * Register SAME in ExpressionTranslator.processOtherTrans()

- Testing:
  * Add comprehensive SameTest with 13 unit tests (100% pass rate)
  * Test coverage: identical/different IDs, null handling, mixed types,
    string IDs, invalid types

Implementation follows Approach 1 (Built-in Function Pattern) with
minimal code changes (441 lines added across 9 files) for maximum
simplicity and maintainability.

Example usage:
  MATCH (a)->(b)->(c) WHERE SAME(a, c) RETURN a, b, c;
@SeasonPilot
Copy link
Contributor Author

#368

Copy link
Contributor

@vamossagar12 vamossagar12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SeasonPilot
Copy link
Contributor Author

@Loognqiang PTAL

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.

2 participants