Compare commits

...

2 Commits

Author SHA1 Message Date
Ante Pušić
cfc0cfa121
Merge branch 'master' into temporal-min-max 2024-03-06 08:52:11 +01:00
Ante Pušić
c899350009 Extend min() and max() to temporal types 2024-03-06 08:33:59 +01:00
3 changed files with 206 additions and 4 deletions

View File

@ -3912,11 +3912,13 @@ class AggregateCursor : public Cursor {
case TypedValue::Type::Int: case TypedValue::Type::Int:
case TypedValue::Type::Double: case TypedValue::Type::Double:
case TypedValue::Type::String: case TypedValue::Type::String:
case TypedValue::Type::Date:
case TypedValue::Type::LocalTime:
case TypedValue::Type::LocalDateTime:
return; return;
default: default:
throw QueryRuntimeException( throw QueryRuntimeException(
"Only boolean, numeric and string values are allowed in " "Only boolean, numeric, string, and non-duration temporal values are allowed in MIN and MAX aggregations.");
"MIN and MAX aggregations.");
} }
} }

View File

@ -236,6 +236,56 @@ Feature: Aggregations
| min(null) | | min(null) |
| null | | null |
Scenario: Min test 05: Date
Given any graph
When executing query:
"""
UNWIND [date("2024-03-05"), date("2023-04-05"), date("2023-03-06")] AS i
RETURN min(i)
"""
Then the result should be:
| min(i) |
| 2023-03-06 |
And no side effects
Scenario: Min test 06: LocalTime
Given any graph
When executing query:
"""
UNWIND [localTime("09:16:00"), localTime("09:15:59"), localTime("10:15:00")] AS i
RETURN min(i)
"""
Then the result should be:
| min(i) |
| 09:15:59.000000000 |
And no side effects
Scenario: Min test 07: LocalDateTime
Given any graph
When executing query:
"""
UNWIND [localDateTime("2024-03-05T09:15:00"),
localDateTime("2023-04-05T09:15:00"),
localDateTime("2023-03-06T09:15:00"),
localDateTime("2023-03-05T10:15:00"),
localDateTime("2023-03-05T09:16:00"),
localDateTime("2023-03-05T09:15:59")] AS i
RETURN min(i)
"""
Then the result should be:
| min(i) |
| 2023-03-05T09:15:59.000000000 |
And no side effects
Scenario: Min test 08: Duration
Given any graph
When executing query:
"""
UNWIND [duration("PT2M2.33S"), duration("PT2M2.33S")] AS i
RETURN min(i)
"""
Then an error should be raised
Scenario: Max test 01: Scenario: Max test 01:
Given an empty graph Given an empty graph
And having executed And having executed
@ -287,6 +337,56 @@ Feature: Aggregations
| max(null) | | max(null) |
| null | | null |
Scenario: Max test 05: Date
Given any graph
When executing query:
"""
UNWIND [date("2024-03-05"), date("2023-04-05"), date("2023-03-06")] AS i
RETURN max(i)
"""
Then the result should be:
| max(i) |
| 2024-03-05 |
And no side effects
Scenario: Max test 06: LocalTime
Given any graph
When executing query:
"""
UNWIND [localTime("10:15:00"), localTime("09:16:00"), localTime("09:15:59")] AS i
RETURN max(i)
"""
Then the result should be:
| max(i) |
| 10:15:00.000000000 |
And no side effects
Scenario: Max test 07: LocalDateTime
Given any graph
When executing query:
"""
UNWIND [localDateTime("2024-03-05T09:15:00"),
localDateTime("2023-04-05T09:15:00"),
localDateTime("2023-03-06T09:15:00"),
localDateTime("2023-03-05T10:15:00"),
localDateTime("2023-03-05T09:16:00"),
localDateTime("2023-03-05T09:15:59")] AS i
RETURN max(i)
"""
Then the result should be:
| max(i) |
| 2024-03-05T09:15:00.000000000 |
And no side effects
Scenario: Max test 08: Duration
Given any graph
When executing query:
"""
UNWIND [duration("PT2M2.33S"), duration("PT2M2.33S")] AS i
RETURN max(i)
"""
Then an error should be raised
Scenario: Collect test 01: Scenario: Collect test 01:
Given an empty graph Given an empty graph
And having executed And having executed
@ -329,7 +429,7 @@ Feature: Aggregations
| n | | n |
| {a_key: 13, b_key: 11, c_key: 12} | | {a_key: 13, b_key: 11, c_key: 12} |
Scenario: Combined aggregations - some evauluates to null: Scenario: Combined aggregations - some evaluate to null:
Given an empty graph Given an empty graph
And having executed And having executed
""" """

View File

@ -236,6 +236,56 @@ Feature: Aggregations
| min(null) | | min(null) |
| null | | null |
Scenario: Min test 05: Date
Given any graph
When executing query:
"""
UNWIND [date("2024-03-05"), date("2023-04-05"), date("2023-03-06")] AS i
RETURN min(i)
"""
Then the result should be:
| min(i) |
| 2023-03-06 |
And no side effects
Scenario: Min test 06: LocalTime
Given any graph
When executing query:
"""
UNWIND [localTime("09:16:00"), localTime("09:15:59"), localTime("10:15:00")] AS i
RETURN min(i)
"""
Then the result should be:
| min(i) |
| 09:15:59.000000000 |
And no side effects
Scenario: Min test 07: LocalDateTime
Given any graph
When executing query:
"""
UNWIND [localDateTime("2024-03-05T09:15:00"),
localDateTime("2023-04-05T09:15:00"),
localDateTime("2023-03-06T09:15:00"),
localDateTime("2023-03-05T10:15:00"),
localDateTime("2023-03-05T09:16:00"),
localDateTime("2023-03-05T09:15:59")] AS i
RETURN min(i)
"""
Then the result should be:
| min(i) |
| 2023-03-05T09:15:59.000000000 |
And no side effects
Scenario: Min test 08: Duration
Given any graph
When executing query:
"""
UNWIND [duration("PT2M2.33S"), duration("PT2M2.33S")] AS i
RETURN min(i)
"""
Then an error should be raised
Scenario: Max test 01: Scenario: Max test 01:
Given an empty graph Given an empty graph
And having executed And having executed
@ -287,6 +337,56 @@ Feature: Aggregations
| max(null) | | max(null) |
| null | | null |
Scenario: Max test 05: Date
Given any graph
When executing query:
"""
UNWIND [date("2024-03-05"), date("2023-04-05"), date("2023-03-06")] AS i
RETURN max(i)
"""
Then the result should be:
| max(i) |
| 2024-03-05 |
And no side effects
Scenario: Max test 06: LocalTime
Given any graph
When executing query:
"""
UNWIND [localTime("10:15:00"), localTime("09:16:00"), localTime("09:15:59")] AS i
RETURN max(i)
"""
Then the result should be:
| max(i) |
| 10:15:00.000000000 |
And no side effects
Scenario: Max test 07: LocalDateTime
Given any graph
When executing query:
"""
UNWIND [localDateTime("2024-03-05T09:15:00"),
localDateTime("2023-04-05T09:15:00"),
localDateTime("2023-03-06T09:15:00"),
localDateTime("2023-03-05T10:15:00"),
localDateTime("2023-03-05T09:16:00"),
localDateTime("2023-03-05T09:15:59")] AS i
RETURN max(i)
"""
Then the result should be:
| max(i) |
| 2024-03-05T09:15:00.000000000 |
And no side effects
Scenario: Max test 08: Duration
Given any graph
When executing query:
"""
UNWIND [duration("PT2M2.33S"), duration("PT2M2.33S")] AS i
RETURN max(i)
"""
Then an error should be raised
Scenario: Collect test 01: Scenario: Collect test 01:
Given an empty graph Given an empty graph
And having executed And having executed
@ -329,7 +429,7 @@ Feature: Aggregations
| n | | n |
| {a_key: 13, b_key: 11, c_key: 12} | | {a_key: 13, b_key: 11, c_key: 12} |
Scenario: Combined aggregations - some evauluates to null: Scenario: Combined aggregations - some evaluate to null:
Given an empty graph Given an empty graph
And having executed And having executed
""" """