Cypher : added 418 tests for Cypher Neo4J functions#3428
Cypher : added 418 tests for Cypher Neo4J functions#3428ExtReMLapin wants to merge 15 commits intoArcadeData:mainfrom
Conversation
Summary of ChangesHello @ExtReMLapin, 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 significantly expands the test coverage for OpenCypher functions within ArcadeDB. It introduces a total of 418 new comprehensive tests, meticulously designed to align with Neo4j's Cypher documentation, ensuring a high degree of feature set compatibility. The added tests span a broad spectrum of function types, from data aggregation and list manipulation to complex mathematical, spatial, and temporal operations, enhancing the robustness and reliability of the OpenCypher implementation. Highlights
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This PR adds a comprehensive suite of tests for Cypher functions, which is a great addition for ensuring compatibility and correctness. However, since the code was AI-generated and not fully reviewed, I've found several areas that need attention. My main concerns are:
- The assertion style is often verbose and can be simplified (e.g.,
assertThat(result.hasNext()).isTrue()instead ofassertThat(result.hasNext() != false).isTrue()). - There appear to be inconsistencies in the expected behavior of functions that compare different data types (like
min(),max(),coll.sort()), which may not align with Neo4j's documented behavior. This needs clarification. - Many tests have weak assertions (e.g., just checking for non-null) and could be made more specific to better validate the function's output.
- I've identified a few tests that are either flaky or incomplete.
I've left specific comments with suggestions for improvement. Addressing these points will significantly improve the quality and reliability of this new test suite.
...com/arcadedb/query/opencypher/functions/OpenCypherAggregatingFunctionsComprehensiveTest.java
Show resolved
Hide resolved
| void collSortBasic() { | ||
| final ResultSet result = database.command("opencypher", | ||
| "RETURN coll.sort([true, 'a', 1, 2]) AS result"); | ||
| Assertions.assertThat(result.hasNext() != false).isTrue(); | ||
| @SuppressWarnings("unchecked") | ||
| final List<Object> sorted = (List<Object>) result.next().getProperty("result"); | ||
| assertThat(sorted).hasSize(4); | ||
| // Cypher ordering: strings < booleans < numbers | ||
| assertThat(sorted.get(0)).isEqualTo("a"); | ||
| assertThat(sorted.get(1)).isEqualTo(true); |
There was a problem hiding this comment.
The comment // Cypher ordering: strings < booleans < numbers and the subsequent assertions appear to contradict the standard Neo4j Cypher type ordering, which is numbers < strings < booleans. This inconsistency could be confusing and may indicate an issue with either the test's assumption or the underlying implementation's sorting logic. Please clarify the expected sorting behavior to ensure it aligns with the goal of Neo4j compatibility.
| void sizeString() { | ||
| final ResultSet result = database.command("opencypher", | ||
| "MATCH (a) WHERE size(a.name) > 6 RETURN size(a.name) AS result"); | ||
| Assertions.assertThat(result.hasNext() != false).isTrue(); | ||
| assertThat(((Number) result.next().getProperty("result")).intValue()).isEqualTo(7); |
There was a problem hiding this comment.
This test is potentially flaky because it queries for names longer than 6 characters without an ORDER BY clause and then asserts a specific size (7, which corresponds to 'Charlie'). The query could return any of the matching names first, and the test would fail if it's not 'Charlie'.
To make this test deterministic, you should either make the query more specific (e.g., MATCH (a:Administrator {name: 'Charlie'})) or assert a property that holds true for all results (e.g., isGreaterThan(6)).
...com/arcadedb/query/opencypher/functions/OpenCypherAggregatingFunctionsComprehensiveTest.java
Outdated
Show resolved
Hide resolved
...com/arcadedb/query/opencypher/functions/OpenCypherAggregatingFunctionsComprehensiveTest.java
Outdated
Show resolved
Hide resolved
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| database = new DatabaseFactory("./target/databases/testOpenCypherTemporalFunctions").create(); |
There was a problem hiding this comment.
The database path ./target/databases/... is inconsistent with other test files in this PR, which use ./databases/.... For consistency across the test suite, it's better to use the same base directory for test databases.
| database = new DatabaseFactory("./target/databases/testOpenCypherTemporalFunctions").create(); | |
| database = new DatabaseFactory("./databases/testOpenCypherTemporalFunctions").create(); |
| final ResultSet result = database.command("opencypher", | ||
| "RETURN duration({days: 14, hours: 16, minutes: 12}) AS result"); | ||
| Assertions.assertThat(result.hasNext() != false).isTrue(); | ||
| Assertions.assertThat(result.next().getProperty("result") != null).isTrue(); |
There was a problem hiding this comment.
This test only asserts that the result is not null, which is a very weak validation. To make the test more meaningful, it should validate the actual content or properties of the created duration object. For example, you could check if the duration corresponds to 14 days, 16 hours, and 12 minutes. This applies to many other tests in this file that only check for non-null results.
| void durationArithmetic() { | ||
| final ResultSet result = database.command("opencypher", | ||
| "WITH duration({days: 10}) AS dur1, duration({hours: 24}) AS dur2 " + | ||
| "RETURN dur1 AS d1, dur2 AS d2"); | ||
| Assertions.assertThat(result.hasNext() != false).isTrue(); | ||
| final var row = result.next(); | ||
| Assertions.assertThat(row.getProperty("d1") != null).isTrue(); | ||
| Assertions.assertThat(row.getProperty("d2") != null).isTrue(); | ||
| } |
There was a problem hiding this comment.
The test name durationArithmetic is misleading as no arithmetic operation is performed. The test only creates two duration objects and returns them. To properly test duration arithmetic, you should perform an operation like addition or subtraction and assert the result (e.g., RETURN dur1 + dur2 AS result).
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| database = new DatabaseFactory("./target/databases/testOpenCypherVectorFunctions").create(); |
There was a problem hiding this comment.
The database path ./target/databases/... is inconsistent with other test files in this PR, which typically use ./databases/.... For consistency across the test suite, please use the same base directory for test databases.
| database = new DatabaseFactory("./target/databases/testOpenCypherVectorFunctions").create(); | |
| database = new DatabaseFactory("./databases/testOpenCypherVectorFunctions").create(); |
| final ResultSet result = database.command("opencypher", | ||
| "RETURN vector([1, 2, 3], 3, INTEGER) AS result"); | ||
| Assertions.assertThat(result.hasNext() != false).isTrue(); | ||
| Assertions.assertThat(result.next().getProperty("result") != null).isTrue(); |
There was a problem hiding this comment.
This test only asserts that the created vector is not null. This is a weak assertion. It would be much more valuable to assert the properties of the vector, such as its dimensions and values, to ensure it was created correctly. This applies to several other tests in this file that only check for non-null results.
🧪 CI InsightsHere's what we observed from your CI run for 99aa587. 🟢 All jobs passed!But CI Insights is watching 👀 |
|
|
Not sure what should be done @lvca
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3428 +/- ##
==========================================
+ Coverage 62.37% 63.05% +0.68%
==========================================
Files 1291 1291
Lines 85339 85339
Branches 17532 17532
==========================================
+ Hits 53226 53814 +588
+ Misses 24535 23948 -587
+ Partials 7578 7577 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
With latest changes, from
to
|
|
Down to
|
…penCypherAggregatingFunctionsComprehensiveTest.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…penCypherAggregatingFunctionsComprehensiveTest.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@ExtReMLapin I'd like to release 26.2.1 asap. What's the status of this PR? Could you also please rebase on the latest main (a big refactoring with packages pushed yesterday). Or we can merge this after 26.2.1 is out. WDYT? |
|
@lvca honestly a release with current state should be good enough, much more than the first OpenCypher release As stated in the first post, as of right now the main issues are :
latest run : |
|
Maybe my message wasn’t clear enough, a release without THIS PR is okay, trivial fixes compared to prior 3 weeks fixes |
What does this PR do?
Based on neo4j documentation https://neo4j.com/docs/cypher-manual/current/functions/
Motivation
1:1 feature set compatibility
Additional Notes
Claude wrote all of this , I did not review all functions individually
mvn test -pl engine -Dtest="com.arcadedb.query.opencypher.functions.*Comprehensive*"Tests run: 594, Failures: 16, Errors: 55, Skipped: 0after 58da446As of right now :
Checklist
mvn clean packagecommand