New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support nested containers as attribute type #658
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe recent updates introduce enhanced support for nested data structures within graph entities, specifically focusing on nested arrays and maps. This includes new functionalities for creating, updating, and serializing maps, as well as improved error handling and validation for entity attributes that utilize these complex types. Changes
Assessment against linked issues
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Actionable comments outside the diff hunks (1)
tests/flow/test_effects.py (1)
Line range hint
36-36
: Avoid using a bareexcept
statement.- except: + except Exception as e: + # Handle or log the exception e appropriatelyUsing a bare
except
can catch unexpected events such as memory errors, interrupts, system exit, and so on. It's better to catch specific exceptions to avoid masking other errors.
v: vecf32([-1.1, 2.2, -3.3]), | ||
m: {a:1, b:{c:'string_val'}} | ||
}""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Several files in the codebase still use the old function signature.
- The search did not reveal specific handling for the attributes
v
andm
in serialization or deserialization processes. - The only related mention was a generic comment in
tests/flow/test_persistency.py
about property handling, which does not confirm specific management forv
andm
.
Analysis chain
Ensure the new attributes v
and m
are correctly handled in the test.
Check the serialization and deserialization processes for the updated attributes in edge updates using map overwrite.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify that the attributes 'v' and 'm' are being correctly serialized and deserialized.
rg --type py "serialize_v_attribute"
rg --type py "serialize_m_attribute"
rg --type py "deserialize_v_attribute"
rg --type py "deserialize_m_attribute"
Length of output: 151
Script:
#!/bin/bash
# Broaden the search to check for any serialization or deserialization related to 'v' and 'm' in Python files
rg --type py -A 3 -B 3 "v" | grep -i "serialize\|deserialize"
rg --type py -A 3 -B 3 "m" | grep -i "serialize\|deserialize"
Length of output: 397
fd627f7
to
9e67ebc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
"CREATE ({v: []})", # empty array | ||
"CREATE ({v: [[]]})", # nested array | ||
"CREATE ({v: [{}]})", # map within array | ||
"CREATE ({v: {x:{}}})", # nested map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add additional values to nested maps.
|
||
for query in queries: | ||
try: | ||
self.graph.query(query) | ||
self.env.assertTrue(False) | ||
except redis.exceptions.ResponseError as e: | ||
self.env.assertContains("Property values can only be of primitive types or arrays of primitive types", str(e)) | ||
self.env.assertContains("Property values can only be of primitive types arrays or maps", str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rephrase,
e.g. "properties can't contain Graph entities nor Paths."
("CREATE (a {v: {s:1}}) RETURN a.v", {'s': 1}), | ||
|
||
# map with NULL element | ||
("CREATE (a {v: {s: null}}) RETURN a.v", {'s': None}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include a scenario which tests map containing strings
|
||
try: | ||
self.graph.query("MERGE (n:N) ON MATCH SET n = {v: 1}, n.a.b=3 RETURN n") | ||
self.env.assertTrue(False) | ||
except ResponseError as e: | ||
self.env.assertContains("RedisGraph does not currently support non-alias references on the left-hand side of SET expressions", str(e)) | ||
self.env.assertContains("FalkorDB does not currently support non-alias references on the left-hand side of SET expressions", str(e)) | ||
|
||
# Fail when a property is a complex type nested within an array type | ||
def test13_invalid_complex_type_in_array(self): | ||
# Test combinations of invalid types with nested and top-level arrays | ||
# Invalid types are NULL, maps, nodes, edges, and paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comment
try: | ||
res = self.graph.query(q) | ||
except ResponseError as e: | ||
self.env.assertContains("", str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fill in exception error message
@@ -60,6 +60,29 @@ static void _RdbSaveSIVector | |||
SerializerIO_WriteFloat(rdb, values[i]); | |||
} | |||
} | |||
static void _RdBSaveMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talk to Dudi regarding update procedure.
@@ -9,6 +9,7 @@ | |||
// forward declarations | |||
static SIValue _RdbLoadPoint(SerializerIO rdb); | |||
static SIValue _RdbLoadSIArray(SerializerIO rdb); | |||
static SIValue _RdbLoadMap (SerializerIO rdb, SIType t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space!
// a map containing an invalid type | ||
if(SI_TYPE(val) == T_MAP) { | ||
SIType invalid_types = ~SI_VALID_PROPERTY_VALUE & ~T_NULL; | ||
bool res = SIArray_ContainsType(val, invalid_types); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong function call, should be SIMap_ContainsType!
Performance test for Saving / Loading graphs with plenty of maps, some of which are small others might be quite large. |
Resolves #657, #31
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests