Skip to content

#3571 fix: handle @in and @out internal properties on function results#3577

Merged
robfrank merged 1 commit intomainfrom
fix/3571-in-and-aout
Mar 4, 2026
Merged

#3571 fix: handle @in and @out internal properties on function results#3577
robfrank merged 1 commit intomainfrom
fix/3571-in-and-aout

Conversation

@robfrank
Copy link
Collaborator

@robfrank robfrank commented Mar 4, 2026

SuffixIdentifier.execute(Identifiable) only handled @Rid, @type, and @cat as special record attributes but fell through to document.get() for @in and @out, which returned null since these are not stored as regular document properties. Added explicit handling to call Edge.getIn()/getOut().

SuffixIdentifier.execute(Identifiable) only handled @Rid, @type, and @cat
as special record attributes but fell through to document.get() for @in
and @out, which returned null since these are not stored as regular
document properties. Added explicit handling to call Edge.getIn()/getOut().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robfrank robfrank linked an issue Mar 4, 2026 that may be closed by this pull request
@robfrank robfrank self-assigned this Mar 4, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the SQL parser where internal @in and @out properties of Edge records were not being correctly resolved. Previously, these properties would return null because the system attempted to retrieve them as regular document properties. The fix introduces specific handling for these properties on Edge objects, ensuring that graph traversal and property access functions as expected. This enhancement improves the reliability and correctness of graph queries involving edge directions.

Highlights

  • Bug Fix for @in and @out Properties: Resolved an issue where @in and @out internal properties were not correctly retrieved for Edge objects, resulting in null values.
  • Enhanced Property Handling: Modified SuffixIdentifier.execute() to explicitly call Edge.getIn() and Edge.getOut() when these properties are accessed on Edge instances.
  • Improved Test Coverage: Added comprehensive unit tests to validate the correct behavior of @in and @out property access on edges in various query scenarios.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • engine/src/main/java/com/arcadedb/query/sql/parser/SuffixIdentifier.java
    • Added imports for IN_PROPERTY and OUT_PROPERTY constants.
    • Implemented logic to retrieve @in and @out properties directly from Edge objects using getIn() and getOut() methods.
  • engine/src/test/java/com/arcadedb/query/sql/Issue3571InternalPropertyOnFunctionResultTest.java
    • Added import for java.util.Map.
    • Introduced new test cases (testInEIndexedAtIn, testInEIndexedAtOut, testInEAtInList, testMapWithAtOut) to verify the correct handling of @in and @out properties on edges in various query contexts.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mergify
Copy link
Contributor

mergify bot commented Mar 4, 2026

🧪 CI Insights

Here's what we observed from your CI run for 198f72d.

🟢 All jobs passed!

But CI Insights is watching 👀

@claude
Copy link

claude bot commented Mar 4, 2026

Code Review

Overall: Good, minimal fix for a real bug. The implementation is correct and well-tested. A few minor observations below.

Fix in SuffixIdentifier.java

The approach is correct. The execute(Identifiable, CommandContext) method was missing explicit handling for @in/@out, causing them to fall through to document.get(recordAttribute.name) which returns null (these are not stored as regular document properties).

The new code is consistent with how RecordAttribute.evaluate(Result, CommandContext) already handles @in/@out, and uses the Java 21 pattern-matching syntax (instanceof Edge edge) consistently with the rest of the codebase.

One subtle correctness point worth acknowledging: when @in/@out is accessed on a non-Edge Identifiable (e.g. a vertex or document), the new conditions don't match and the code falls through to ((Document) currentRecord.getRecord()).get(recordAttribute.name), which correctly returns null. This is the right behavior and is not a regression.

Tests

The test coverage is good - each combination of function access pattern and internal property is exercised. A couple of minor gaps:

  1. Missing testInEAtOutList - testInEAtInList tests inE().@in returning a list of RIDs, but there is no equivalent test for inE().@out. Given @in and @out go through the same code path in execute(Iterable, ...), this is low risk but would make coverage symmetric.

  2. testMapWithAtOut key assertion - the test verifies the map value is a non-null RID, but does not verify the key is the edge RID string. Adding an assertion like assertThat(map.keySet().iterator().next()).isInstanceOf(String.class) would make it more complete.

  3. Self-loop edge in @in/@out tests - V3571g has an edge from itself to itself, so @in and @out both point to the same vertex. This is fine for testing that a non-null RID is returned, but the tests do not distinguish whether @in returns the in-vertex and @out returns the out-vertex (they'd both return the same RID here). Not a blocker, just worth noting if you ever want to strengthen these assertions.

  4. Per-test schema types - using IF NOT EXISTS for CREATE but DELETE FROM V3571* for cleanup is a valid pattern; the types accumulate across runs but the data is cleared. This is consistent with other tests in the file.

Summary

The fix is correct, appropriately scoped, and the tests cover the primary use cases. The items above are minor suggestions for completeness, not blockers.

@robfrank robfrank merged commit 24c5260 into main Mar 4, 2026
12 of 13 checks passed
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue where internal properties @in and @out were not correctly handled on function results. The change in SuffixIdentifier.java adds explicit handling for these properties, which seems correct. The accompanying tests are comprehensive and verify the fix. I've provided a few suggestions to improve code consistency in the implementation and to enhance the new tests by reducing code duplication and improving efficiency.

Comment on lines +99 to +102
} else if (IN_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge)
return edge.getIn();
else if (OUT_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge)
return edge.getOut();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the preceding if-else blocks that use the doc variable, you could use doc here as well instead of calling currentRecord.getRecord() again.

Suggested change
} else if (IN_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge)
return edge.getIn();
else if (OUT_PROPERTY.equalsIgnoreCase(recordAttribute.name) && currentRecord.getRecord() instanceof Edge edge)
return edge.getOut();
} else if (IN_PROPERTY.equalsIgnoreCase(recordAttribute.name) && doc instanceof Edge edge)
return edge.getIn();
else if (OUT_PROPERTY.equalsIgnoreCase(recordAttribute.name) && doc instanceof Edge edge)
return edge.getOut();

Comment on lines +169 to +173
database.command("sql", "CREATE VERTEX TYPE V3571g IF NOT EXISTS");
database.command("sql", "CREATE EDGE TYPE E3571g IF NOT EXISTS");
database.command("sql", "DELETE FROM V3571g");
database.command("sql", "INSERT INTO V3571g");
database.command("sql", "CREATE EDGE E3571g FROM (SELECT FROM V3571g) TO (SELECT FROM V3571g)");
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The setup logic for creating vertex and edge types is duplicated across multiple test methods (testInEIndexedAtIn, testInEIndexedAtOut, testInEAtInList, testMapWithAtOut). To improve maintainability and reduce code duplication, consider extracting this logic into a private helper method.

For example:

private void setupGraph(final String vertexType, final String edgeType) {
  database.command("sql", "CREATE VERTEX TYPE " + vertexType + " IF NOT EXISTS");
  database.command("sql", "CREATE EDGE TYPE " + edgeType + " IF NOT EXISTS");
  database.command("sql", "DELETE FROM " + vertexType);
  database.command("sql", "INSERT INTO " + vertexType);
  database.command("sql", "CREATE EDGE " + edgeType + " FROM (SELECT FROM " + vertexType + ") TO (SELECT FROM " + vertexType + ")");
}

Then you can call setupGraph("V3571g", "E3571g"); at the beginning of your test.

Comment on lines +251 to +252
assertThat(map.values().iterator().next()).isNotNull();
assertThat(map.values().iterator().next()).isInstanceOf(RID.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

You are calling map.values().iterator().next() twice. This is inefficient and could be problematic with some iterators. It's better to call it once and store the result in a local variable.

      final Object value = map.values().iterator().next();
      assertThat(value).isNotNull();
      assertThat(value).isInstanceOf(RID.class);

@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-9.91%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (109d438) 103646 77261 74.54%
Head commit (198f72d) 134195 (+30549) 86734 (+9473) 64.63% (-9.91%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3577) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.47%. Comparing base (109d438) to head (198f72d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3577      +/-   ##
==========================================
- Coverage   65.59%   65.47%   -0.12%     
==========================================
  Files        1514     1514              
  Lines      103646   103646              
  Branches    21449    21449              
==========================================
- Hits        67987    67867     -120     
- Misses      26414    26521     +107     
- Partials     9245     9258      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

robfrank added a commit that referenced this pull request Mar 5, 2026
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.

SQL: accessing internal properties in a map

1 participant