feat(opencypher): support numeric scalar functions in WHERE and aggregates (fixes #216) - #217
Vivek77741 wants to merge 2 commits into
Conversation
|
| // expression_query_value | ||
| assert_eq!( | ||
| expression_query_value(&row, &expr_abs_neg).unwrap(), | ||
| Some(QueryValue::Property(VertexPropertyValue::Integer(15))) | ||
| ); | ||
| assert_eq!( | ||
| expression_query_value(&row, &expr_abs_missing).unwrap(), | ||
| None | ||
| ); | ||
|
|
||
| // Predicate matching |
There was a problem hiding this comment.
Aggregate Evaluators Lack Coverage
The aggregate-value evaluator separately implements all five new functions, but this test exercises expression_query_value only for abs. It never runs ceil, floor, round, or sign through an aggregate, and there is no parser-to-executor test for the documented aggregate syntax. Add end-to-end aggregate cases so differences between eval_row_expression and expression_query_value do not go unnoticed.
Knowledge Base Used: openCypher query interface
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
@Vivek77741 Only collaborators with push access can ask OpenHack to act on this repository. |
✅ OpenHack SummarySecurity review of feat(opencypher): support numeric scalar functions in WHERE and aggregates (fixes #216). 4 changed files; 0 findings at or above the low reporting threshold. Confidence Score: 5/5No reportable security findings were detected in this scan. Security merge-readiness rubric: 1 = critical, 2 = high, 3 = medium, 4 = low, 5 = no reportable findings. This score reflects scan findings, not a guarantee of correctness or complete coverage. Files Needing Attention: None Important Files Changed
Last reviewed commit: 7b40d4b · View review on OpenHack
|
Fixes #216
Motivation & Summary
In standard OpenCypher (and ISO GQL), numeric scalar functions are essential for performing mathematical filtering and calculations on node and relationship properties. Previously, HydraDB's OpenCypher parser and execution engine lacked support for these functions, rejecting queries such as
MATCH (n:Item) WHERE abs(n.delta) > 5 RETURN n.idorRETURN collect(abs(n.delta))with parse or unsupported query errors.This PR adds support for standard numeric scalar functions:
abs(n): Absolute value of integers (IntegerandSignedInteger) and floats.ceil(n): Smallest integer greater than or equal ton(preserving integers, ceiling floats).floor(n): Largest integer less than or equal ton(preserving integers, flooring floats).round(n): Nearest integer rounding for numeric values (preserving integers, rounding floats).sign(n): Signum indicator (-1,0, or1) for numeric values.Changes
src/query/opencypher.rs):RowExpressionwithAbs,Ceil,Floor,Round, andSignvariants wrappingBox<RowExpression>.lower_row_expression, loweredsys::CYPHER_AST_APPLY_OPERATORinvocations for single-argumentabs,ceil,floor,round, andsigncalls.row_expression_namefor fallback column aliases.lowers_numeric_scalar_function_expressions.src/shard/query.rs):Abs,Ceil,Floor,Round, andSignineval_row_expressionfor row predicate comparisons.Abs,Ceil,Floor,Round, andSigninexpression_query_valuefor aggregate projections.RowScalarValue::MissingandNone(preserving three-valued logic).test_eval_row_expression_numeric_scalar_functionsverifying execution acrossInteger,SignedInteger,Float, and missing values.cypher-compat.md):abs,ceil,floor,round, andsignsupport inWHEREcomparisons and aggregate expressions.