Skip to content

Commit

Permalink
V2.0.15 (#1163)
Browse files Browse the repository at this point in the history
* added params support for indexed array lookup (#1159)

* cherry pick and version bump

Co-authored-by: DvirDukhan <dvir@redislabs.com>
  • Loading branch information
swilly22 and DvirDukhan committed Jun 23, 2020
1 parent 9310929 commit 179692f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/execution_plan/optimizations/utilize_indices.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ static bool _validateInExpression(AR_ExpNode *exp) {
assert(exp->op.child_count == 2);

AR_ExpNode *list = exp->op.children[1];
// In case the array is a parameter such as "WHERE x IN $arr", evaluate the parameter for in-place replacement.
if(AR_EXP_IsParameter(list)) AR_EXP_Evaluate(list, NULL);
if(list->operand.type != AR_EXP_CONSTANT || list->operand.constant.type != T_ARRAY) return false;

SIValue listValue = list->operand.constant;
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define REDISGRAPH_VERSION_MAJOR 2
#define REDISGRAPH_VERSION_MINOR 0
#define REDISGRAPH_VERSION_PATCH 14
#define REDISGRAPH_VERSION_PATCH 15

#define REDISGRAPH_SEMANTIC_VERSION(major, minor, patch) \
(major * 10000 + minor * 100 + patch)
Expand Down
10 changes: 10 additions & 0 deletions tests/flow/test_index_scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,13 @@ def test09_index_scan_with_params(self):
expected_result = ["Lucy Yanfital"]
self.env.assertEquals(query_result.result_set[0], expected_result)

def test10_index_scan_with_param_array(self):
query = "MATCH (p:person) WHERE p.age in $ages RETURN p.name"
params = {'ages':[30]}
query = redis_graph.build_params_header(params) + query
plan = redis_graph.execution_plan(query)
self.env.assertIn('Index Scan', plan)
query_result = redis_graph.query(query)
expected_result = ["Lucy Yanfital"]
self.env.assertEquals(query_result.result_set[0], expected_result)

0 comments on commit 179692f

Please sign in to comment.