Open
Description
The only diff between 1. and 2. is that in 2. there is one extra alias: , upstream_len AS upstream_len
before the RETURN clause.
Thus, when upstream_len
was not claimed, WITH CASE WHEN upstream_len IS NULL
will be TRUE forever instead of error
alias not declared.
I was aware of this behavior (differentiate from n4j on requiring explicitly specifying alias in latest WITH before RETURN), but this seems to be confusing as it treated upstream_len
as NULL instead of raising an error to warn the user to declare it.
1
MATCH (source:`Table`)
WHERE id(source) == "hive://gold.test_schema/test_table1"
OPTIONAL MATCH `path`=(source)-[upstream_len:HAS_UPSTREAM*..3]->(upstream_entity:`Table`)
WITH upstream_entity, upstream_len, `path`
OPTIONAL MATCH (upstream_entity)-[:HAS_BADGE]->(upstream_badge:Badge)
WITH CASE WHEN upstream_badge IS NULL THEN collect(NULL)
ELSE collect(distinct {key:id(upstream_badge),category:upstream_badge.Badge.category})
END AS upstream_badges, upstream_entity, upstream_len, `path`
OPTIONAL MATCH (upstream_entity:`Table`)-[upstream_read:READ_BY]->(:`User`)
WITH upstream_entity, upstream_len, upstream_badges,
sum(upstream_read.read_count) AS upstream_read_count, `path`
WITH CASE WHEN upstream_len IS NULL THEN collect(NULL)
ELSE COLLECT(distinct{level:SIZE(upstream_len), source:split(id(upstream_entity),'://')[0],
key:id(upstream_entity), badges:upstream_badges, usage:upstream_read_count, parent:id(nodes(`path`)[-2])})
END AS upstream_entities RETURN upstream_entities
+-------------------+
| upstream_entities |
+-------------------+
| [] |
+-------------------+
2
MATCH (source:`Table`)
WHERE id(source) == "hive://gold.test_schema/test_table1"
OPTIONAL MATCH `path`=(source)-[upstream_len:HAS_UPSTREAM*..3]->(upstream_entity:`Table`)
WITH upstream_entity, upstream_len, `path`
OPTIONAL MATCH (upstream_entity)-[:HAS_BADGE]->(upstream_badge:Badge)
WITH CASE WHEN upstream_badge IS NULL THEN collect(NULL)
ELSE collect(distinct {key:id(upstream_badge),category:upstream_badge.Badge.category})
END AS upstream_badges, upstream_entity, upstream_len, `path`
OPTIONAL MATCH (upstream_entity:`Table`)-[upstream_read:READ_BY]->(:`User`)
WITH upstream_entity, upstream_len, upstream_badges,
sum(upstream_read.read_count) AS upstream_read_count, `path`
WITH CASE WHEN upstream_len IS NULL THEN collect(NULL)
ELSE COLLECT(distinct{level:SIZE(upstream_len), source:split(id(upstream_entity),'://')[0],
key:id(upstream_entity), badges:upstream_badges, usage:upstream_read_count, parent:id(nodes(`path`)[-2])})
END AS upstream_entities, upstream_len AS upstream_len RETURN upstream_entities
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| downstream_entities |
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
| [{badges: [], key: "hive://gold.test_schema/test's_table4", level: 2, parent: "dynamo://gold.test_schema/test_table2", source: "hive", usage: 0}] |
| [{badges: [], key: "hive://gold.test_schema/test_table3", level: 2, parent: "dynamo://gold.test_schema/test_table2", source: "hive", usage: 0}] |
| [{badges: [], key: "hive://gold.test_schema/test_view1", level: 1, parent: "hive://gold.test_schema/test_table1", source: "hive", usage: 0}] |
| [{badges: [], key: "hive://gold.test_schema/test's_table4", level: 2, parent: "hive://gold.test_schema/test_view1", source: "hive", usage: 0}] |
| [{badges: [], key: "dynamo://gold.test_schema/test_table2", level: 1, parent: "hive://gold.test_schema/test_table1", source: "dynamo", usage: 520}] |
+-----------------------------------------------------------------------------------------------------------------------------------------------------+
Activity