Skip to content
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

fix: receive warnings from dbms server in neo4j queries #16598

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def refresh_schema(self) -> None:
"metadata": {"constraint": constraint, "index": index},
}
schema_counts = self.structured_query(
"CALL apoc.meta.graphSample() YIELD nodes, relationships "
"CALL apoc.meta.subGraph({}) YIELD nodes, relationships "
"RETURN nodes, [rel in relationships | {name:apoc.any.property"
"(rel, 'type'), count: apoc.any.property(rel, 'count')}]"
" AS relationships"
Expand Down Expand Up @@ -341,8 +341,7 @@ def upsert_nodes(self, nodes: List[LabelledNode]) -> None:
CALL apoc.create.addLabels(e, [row.label])
YIELD node
WITH e, row
CALL {{
WITH e, row
CALL (e, row) {{
WITH e, row
WHERE row.embedding IS NOT NULL
CALL db.create.setNodeVectorProperty(e, 'embedding', row.embedding)
Expand Down Expand Up @@ -463,7 +462,7 @@ def get_triplets(

return_statement = f"""
WITH e
CALL {{
CALL (e) {{
WITH e
MATCH (e)-[r{':`' + '`|`'.join(relation_names) + '`' if relation_names else ''}]->(t:`{BASE_ENTITY_LABEL}`)
RETURN e.name AS source_id, [l in labels(e) WHERE NOT l IN ['{BASE_ENTITY_LABEL}', '{BASE_NODE_LABEL}'] | l][0] AS source_type,
Expand Down Expand Up @@ -739,7 +738,7 @@ def _enhanced_schema_cypher(
prop_type = prop["type"]
if prop_type == "STRING":
with_clauses.append(
f"collect(distinct substring(toString(n.`{prop_name}`), 0, 50)) "
f"collect(distinct substring(toString(coalesce(n.`{prop_name}`, '')), 0, 50)) "
f"AS `{prop_name}_values`"
)
return_clauses.append(
Expand All @@ -765,8 +764,8 @@ def _enhanced_schema_cypher(
)
elif prop_type == "LIST":
with_clauses.append(
f"min(size(n.`{prop_name}`)) AS `{prop_name}_size_min`, "
f"max(size(n.`{prop_name}`)) AS `{prop_name}_size_max`"
f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, "
f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`"
)
return_clauses.append(
f"min_size: `{prop_name}_size_min`, "
Expand Down Expand Up @@ -819,7 +818,7 @@ def _enhanced_schema_cypher(
]:
if not prop_index:
with_clauses.append(
f"collect(distinct toString(n.`{prop_name}`)) "
f"collect(distinct toString(coalesce(n.`{prop_name}`, ''))) "
f"AS `{prop_name}_values`"
)
return_clauses.append(f"values: `{prop_name}_values`")
Expand All @@ -841,8 +840,8 @@ def _enhanced_schema_cypher(

elif prop_type == "LIST":
with_clauses.append(
f"min(size(n.`{prop_name}`)) AS `{prop_name}_size_min`, "
f"max(size(n.`{prop_name}`)) AS `{prop_name}_size_max`"
f"min(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_min`, "
f"max(size(coalesce(n.`{prop_name}`, []))) AS `{prop_name}_size_max`"
)
return_clauses.append(
f"min_size: `{prop_name}_size_min`, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exclude = ["**/BUILD"]
license = "MIT"
name = "llama-index-graph-stores-neo4j"
readme = "README.md"
version = "0.3.3"
version = "0.3.4"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
Expand Down
Loading