Skip to content

Commit

Permalink
fix: BED-5154 - switch entity references in translation to int8[] and…
Browse files Browse the repository at this point in the history
… index values to int
  • Loading branch information
zinic committed Dec 10, 2024
1 parent 288e098 commit 2202476
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite
from edge e0
join node n0 on n0.id = e0.start_id
join node n1 on n1.id = e0.end_id)
select edges_to_path(variadic array [(s0.e0).id]::int4[])::pathcomposite as p
select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p
from s0;

-- case: match p = ()-[r1]->()-[r2]->(e) return e
Expand Down Expand Up @@ -92,7 +92,7 @@ with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite
edge e1
join node n2 on (n2.properties -> 'is_target')::bool and n2.id = e1.start_id
where (s0.n1).id = e1.end_id)
select edges_to_path(variadic array [(s1.e0).id, (s1.e1).id]::int4[])::pathcomposite as p
select edges_to_path(variadic array [(s1.e0).id, (s1.e1).id]::int8[])::pathcomposite as p
from s1;

-- case: match p = ()-[*..]->() return p limit 1
Expand Down Expand Up @@ -126,7 +126,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id)
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0
limit 1;
Expand Down Expand Up @@ -162,7 +162,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied),
s1 as (select s0.e0 as e0,
s0.ep0 as ep0,
Expand All @@ -174,7 +174,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
edge e1
join node n2 on n2.id = e1.end_id
where (s0.n1).id = e1.start_id)
select edges_to_path(variadic array [(s1.e1).id]::int4[] || s1.ep0)::pathcomposite as p
select edges_to_path(variadic array [(s1.e1).id]::int8[] || s1.ep0)::pathcomposite as p
from s1
limit 1;

Expand Down Expand Up @@ -220,8 +220,8 @@ with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite
ex0
join edge e1 on e1.id = any (ex0.path)
join node n1 on n1.id = ex0.root_id
join node n2 on e1.id = ex0.path[array_length(ex0.path, 1)::int4] and n2.id = e1.end_id)
select s1.e0 as e, edges_to_path(variadic array [(s1.e0).id]::int4[] || s1.ep0)::pathcomposite as p
join node n2 on e1.id = ex0.path[array_length(ex0.path, 1)::int] and n2.id = e1.end_id)
select s1.e0 as e, edges_to_path(variadic array [(s1.e0).id]::int8[] || s1.ep0)::pathcomposite as p
from s1;

-- case: match p = (m:NodeKind1)-[:EdgeKind1]->(c:NodeKind2) where m.objectid ends with "-513" and not toUpper(c.operatingsystem) contains "SERVER" return p limit 1000
Expand All @@ -235,6 +235,6 @@ with s0 as (select (n0.id, n0.kind_ids, n0.properties)::nodecomposite
not upper(n1.properties ->> 'operatingsystem')::text like '%SERVER%' and
n1.id = e0.end_id
where e0.kind_id = any (array [11]::int2[]))
select edges_to_path(variadic array [(s0.e0).id]::int4[])::pathcomposite as p
select edges_to_path(variadic array [(s0.e0).id]::int8[])::pathcomposite as p
from s0
limit 1000;
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id)
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id)
select s0.n0 as n, s0.n1 as e
from s0;

Expand Down Expand Up @@ -80,7 +80,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select s0.n1 as e
from s0;
Expand Down Expand Up @@ -119,7 +119,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select s0.n1 as e
from s0;
Expand Down Expand Up @@ -155,7 +155,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select s0.n0 as n
from s0;
Expand Down Expand Up @@ -191,7 +191,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied),
s1 as (select s0.e0 as e0,
s0.ep0 as ep0,
Expand Down Expand Up @@ -237,7 +237,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied),
s1 as (select s0.e0 as e0,
s0.ep0 as ep0,
Expand Down Expand Up @@ -286,7 +286,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
ex1
join edge e2 on e2.id = any (ex1.path)
join node n2 on n2.id = ex1.root_id
join node n3 on e2.id = ex1.path[array_length(ex1.path, 1)::int4] and n3.id = e2.end_id)
join node n3 on e2.id = ex1.path[array_length(ex1.path, 1)::int] and n3.id = e2.end_id)
select s2.n3 as l
from s2;

Expand Down Expand Up @@ -332,7 +332,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0
Expand Down Expand Up @@ -372,7 +372,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied
and n0.id <> n1.id)
select edges_to_path(variadic ep0)::pathcomposite as p
Expand Down Expand Up @@ -422,7 +422,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0;
Expand Down Expand Up @@ -463,7 +463,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.start_id)
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.start_id)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0
limit 10;
Expand Down Expand Up @@ -505,7 +505,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.start_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.start_id
where ex0.satisfied),
s1 as (with recursive ex1(root_id, next_id, depth, satisfied, is_cycle, path) as (select e1.start_id,
e1.end_id,
Expand Down Expand Up @@ -544,7 +544,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
ex1
join edge e1 on e1.id = any (ex1.path)
join node n1 on n1.id = ex1.root_id
join node n2 on e1.id = ex1.path[array_length(ex1.path, 1)::int4] and n2.id = e1.start_id)
join node n2 on e1.id = ex1.path[array_length(ex1.path, 1)::int] and n2.id = e1.start_id)
select edges_to_path(variadic s1.ep1 || s1.ep0)::pathcomposite as p
from s1
limit 10;
Expand Down Expand Up @@ -593,7 +593,7 @@ with s0 as (with recursive ex0(root_id, next_id, depth, satisfied, is_cycle, pat
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ with s0 as (with ex0(root_id, next_id, depth, satisfied, is_cycle, path)
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id)
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0;

Expand All @@ -46,7 +46,7 @@ with s0 as (with ex0(root_id, next_id, depth, satisfied, is_cycle, path)
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied)
select edges_to_path(variadic ep0)::pathcomposite as p
from s0;
Expand All @@ -65,7 +65,7 @@ with s0 as (with ex0(root_id, next_id, depth, satisfied, is_cycle, path)
from ex0
join edge e0 on e0.id = any (ex0.path)
join node n0 on n0.id = ex0.root_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int4] and n1.id = e0.end_id
join node n1 on e0.id = ex0.path[array_length(ex0.path, 1)::int] and n1.id = e0.end_id
where ex0.satisfied
and n0.id <> n1.id)
select edges_to_path(variadic ep0)::pathcomposite as p
Expand Down
6 changes: 3 additions & 3 deletions packages/go/cypher/models/pgsql/translate/expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (s *Translator) buildAllShortestPathsExpansionRoot(part *PatternPart, trave
pgsql.CompoundIdentifier{traversalStep.Expansion.Value.Binding.Identifier, expansionPath},
pgsql.NewLiteral(1, pgsql.Int8),
},
CastType: pgsql.Int4,
CastType: pgsql.Int,
},
},
},
Expand Down Expand Up @@ -660,7 +660,7 @@ func (s *Translator) buildExpansionPatternRoot(part *PatternPart, traversalStep
pgsql.CompoundIdentifier{traversalStep.Expansion.Value.Binding.Identifier, expansionPath},
pgsql.NewLiteral(1, pgsql.Int8),
},
CastType: pgsql.Int4,
CastType: pgsql.Int,
},
},
},
Expand Down Expand Up @@ -947,7 +947,7 @@ func (s *Translator) buildExpansionPatternStep(part *PatternPart, traversalStep
pgsql.CompoundIdentifier{traversalStep.Expansion.Value.Binding.Identifier, expansionPath},
pgsql.NewLiteral(1, pgsql.Int8),
},
CastType: pgsql.Int4,
CastType: pgsql.Int,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/go/cypher/models/pgsql/translate/projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func buildProjection(alias pgsql.Identifier, projected *BoundIdentifier, scope *
pgsql.OperatorConcatenate,
pgsql.ArrayLiteral{
Values: edgeReferences,
CastType: pgsql.Int4Array,
CastType: pgsql.Int8Array,
},
)
}
Expand Down

0 comments on commit 2202476

Please sign in to comment.