@@ -11070,6 +11070,64 @@ def test_string_cypher_multi_alias_with_three_stage_case_aggregation() -> None:
1107011070 assert all (r ["postCount" ] > 0 for r in records )
1107111071
1107211072
11073+ def test_issue_1038_ic4_return_side_case_expression_regression_lock () -> None :
11074+ """Regression lock for #1038: RETURN-side CASE over IC4-shaped post timestamp ranges."""
11075+ graph = _mk_graph (
11076+ pd .DataFrame (
11077+ {
11078+ "id" : ["p1" , "f1" , "f2" , "post1" , "post2" , "post3" , "tag1" , "tag2" ],
11079+ "label__Person" : [True , True , True , False , False , False , False , False ],
11080+ "label__Post" : [False , False , False , True , True , True , False , False ],
11081+ "label__Tag" : [False , False , False , False , False , False , True , True ],
11082+ "name" : ["" , "" , "" , "" , "" , "" , "TagA" , "TagB" ],
11083+ "creationDate" : [
11084+ 0 ,
11085+ 0 ,
11086+ 0 ,
11087+ 1275350400000 ,
11088+ 1275264000000 ,
11089+ 1306799999999 ,
11090+ 0 ,
11091+ 0 ,
11092+ ],
11093+ }
11094+ ),
11095+ pd .DataFrame (
11096+ {
11097+ "s" : ["p1" , "p1" , "post1" , "post2" , "post3" , "post1" , "post2" , "post3" ],
11098+ "d" : ["f1" , "f2" , "f1" , "f1" , "f2" , "tag1" , "tag1" , "tag2" ],
11099+ "type" : [
11100+ "KNOWS" ,
11101+ "KNOWS" ,
11102+ "HAS_CREATOR" ,
11103+ "HAS_CREATOR" ,
11104+ "HAS_CREATOR" ,
11105+ "HAS_TAG" ,
11106+ "HAS_TAG" ,
11107+ "HAS_TAG" ,
11108+ ],
11109+ }
11110+ ),
11111+ )
11112+
11113+ result = graph .gfql (
11114+ "MATCH (person:Person {id: $pid})-[:KNOWS]-(friend:Person), "
11115+ "(friend)<-[:HAS_CREATOR]-(post:Post)-[:HAS_TAG]->(tag:Tag) "
11116+ "WITH DISTINCT tag, post "
11117+ "RETURN tag.name AS tagName, post.id AS rawPostId, "
11118+ "CASE WHEN 1275350400000 <= post.creationDate AND post.creationDate < 1306886400000 "
11119+ "THEN post.id ELSE null END AS postId "
11120+ "ORDER BY tagName ASC, rawPostId ASC" ,
11121+ params = {"pid" : "p1" },
11122+ )
11123+
11124+ assert result ._nodes .to_dict (orient = "records" ) == [
11125+ {"tagName" : "TagA" , "rawPostId" : "post1" , "postId" : "post1" },
11126+ {"tagName" : "TagA" , "rawPostId" : "post2" , "postId" : None },
11127+ {"tagName" : "TagB" , "rawPostId" : "post3" , "postId" : "post3" },
11128+ ]
11129+
11130+
1107311131# ---------------------------------------------------------------------------
1107411132# Issue #996: MATCH (connected) OPTIONAL MATCH ... RETURN mixed + CASE
1107511133# ---------------------------------------------------------------------------
0 commit comments