Skip to content
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
38 changes: 20 additions & 18 deletions regress/journey_planner_npm/cypher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,6 @@ export const ERROR_CASES: Case[] = [
},
];

// The engine takes a parameter as a label so far (TUR-48), so the values the cases after the
// labels read are declared up front with WITH. The parameter map is parsed whole either way,
// so a map holding every kind of value still proves the client encodes each one.
export const PARAMETER_CASES: Case[] = [
{
name: "matches the label a parameter names",
Expand All @@ -523,15 +520,15 @@ export const PARAMETER_CASES: Case[] = [
rows: [["F1"], ["F2"]],
},
{
name: "parses a parameter map holding every kind of value",
query: "MATCH (s:$label) RETURN count(s)",
name: "returns every kind of value a parameter map holds",
query: "MATCH (s:$label) RETURN count(s), $values",
options: {
parameters: {
label: "STATION",
unused: [470, 2.5, double(2), -1n, 2n ** 62n, "Oxford 🚆", true, null, [], {}, { stop: { crs: "PAD", platforms: [1, 2] } }],
values: [470, 2.5, double(2), -1n, 2n ** 62n, "Oxford 🚆", true, null, [], {}, { stop: { crs: "PAD", platforms: [1, 2] } }],
},
},
rows: [[5n]],
rows: [[5n, [470n, 2.5, 2.0, -1n, 2n ** 62n, "Oxford 🚆", true, null, [], {}, { stop: { crs: "PAD", platforms: [1n, 2n] } }]]],
},
{
name: "parses a parameter map larger than the client's first buffer",
Expand All @@ -546,29 +543,34 @@ export const PARAMETER_CASES: Case[] = [
error: { status: "EXEC_ERROR", message: "Parameter $label is not defined" },
},
{
name: "returns a constant of every scalar type",
query: "WITH 470 AS integer, 2.5 AS ratio, 2.0 AS whole, 'Oxford 🚆' AS text, true AS flag, null AS nothing " +
"RETURN integer, ratio, whole, text, flag, nothing",
name: "returns a parameter of every scalar type",
query: "RETURN $integer, $ratio, $whole, $text, $flag, $nothing",
options: { parameters: { integer: 470, ratio: 2.5, whole: double(2), text: "Oxford 🚆", flag: true, nothing: null } },
types: ["INT64", "DOUBLE", "DOUBLE", "STRING", "BOOL", "PROPERTY_NULL"],
rows: [[470n, 2.5, 2.0, "Oxford 🚆", true, null]],
},
{
name: "returns a list and a map constant",
query: "WITH [480, 'S1', [2.5], null] AS calls, {crs: 'PAD', platforms: [1, 2]} AS stop RETURN calls, stop",
name: "returns a list and a map parameter",
query: "RETURN $calls, $stop",
options: { parameters: { calls: [480, "S1", [2.5], null], stop: { crs: "PAD", platforms: [1, 2] } } },
rows: [[[480n, "S1", [2.5], null], { crs: "PAD", platforms: [1n, 2n] }]],
},
{
name: "returns an integer constant past a double's precision",
query: "WITH 4611686018427387905 AS big RETURN big",
name: "returns an integer parameter past a double's precision",
query: "RETURN $big",
options: { parameters: { big: 2n ** 62n + 1n } },
rows: [[2n ** 62n + 1n]],
},
{
name: "keeps the stations a list constant names",
query: "WITH ['OXF', 'PAD'] AS stops MATCH (s:STATION) WHERE s.crs IN stops RETURN s.name",
name: "keeps the stations a list parameter names",
query: "MATCH (s:STATION) WHERE s.crs IN $stops RETURN s.name",
options: { parameters: { stops: ["OXF", "PAD"] } },
rows: [["Oxford"], ["London Paddington"]],
},
{
name: "reads a key of a map constant",
query: "WITH {from: 470, to: 500} AS window RETURN window.from, window.to - window.from",
name: "reads a key of a map parameter",
query: "RETURN $window.from, $window.to - $window.from",
options: { parameters: { window: { from: 470, to: 500 } } },
rows: [[470n, 30n]],
},
];
Expand Down
26 changes: 26 additions & 0 deletions regress/journey_planner_npm/journey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,32 @@ export const LEG_CASES: Case[] = [
["F1", 474n, 545n],
],
},
{
name: "reads the window from parameters",
query: "MATCH (o:STATION {crs: 'OXF'}), (d:STATION {crs: 'PAD'}) " +
"WITH o, d, ['DID', 'RDG', 'PAD'] AS interchanges " +
"MATCH leg1=(o)-[:WED]->(firstStop:MODE) -[:NEXT * 0..99]-> (lastStop:MODE)-[:ARRIVE]-(inter:STATION) " +
"WHERE inter.crs IN interchanges " +
"AND NOT EXISTS {(lastStop)-[:NEXT|ARRIVE]->{2,20}(d)} " +
"AND CASE WHEN firstStop:FIXED " +
"THEN ($depart_before > firstStop.start AND $depart_from < firstStop.end) " +
"ELSE $depart_before >= firstStop.depart >= $depart_from " +
"END " +
"RETURN firstStop.service, " +
"coalesce(lastStop.arrive, $depart_from) + inter.minInterchange AS departAfter, " +
"coalesce(lastStop.arrive, $depart_before) + inter.maxInterchange AS departBefore",
options: { parameters: { depart_from: 470, depart_before: 500 } },
rows: [
["S1", 555n, 635n],
["S2", 509n, 550n],
["S3", 531n, 575n],
["S5", 504n, 545n],
["S6", 514n, 555n],
["S7", 506n, 547n],
["S10", 501n, 542n],
["F1", 474n, 545n],
],
},
{
name: "slices the interchanges at coll.indexOf",
query: LEGS_FROM_OXFORD + "RETURN firstStop.service, interchanges[coll.indexOf(interchanges, inter.crs)+1..]",
Expand Down
3 changes: 1 addition & 2 deletions test/query/ir/journey/JourneyLegsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ TEST_F(JourneyLegsTest, findsTheSameLegsAtEveryChunkSize) {
}

// The customer's search as written, its window given as parameters.
// Disabled: an expression parses and types a parameter, but codegen cannot read one yet (TUR-48).
TEST_F(JourneyLegsTest, DISABLED_readsTheWindowFromParameters) {
TEST_F(JourneyLegsTest, readsTheWindowFromParameters) {
ParameterMap parameters;

ParameterValue departFrom;
Expand Down
3 changes: 1 addition & 2 deletions test/query/ir/journey/JourneyParetoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ TEST_F(JourneyParetoTest, keepsTheLegsTheQueryBeforeReturned) {
}

// The customer's collect of one map per leg.
// Disabled: collect() rejects a map argument in the analyzer (TUR-100).
TEST_F(JourneyParetoTest, DISABLED_collectsTheLegsAsMaps) {
TEST_F(JourneyParetoTest, collectsTheLegsAsMaps) {
std::string query;
findLegsFromOxford(query, "['DID', 'RDG', 'PAD']", 470, 500);
query += "WITH ";
Expand Down
4 changes: 1 addition & 3 deletions test/query/ir/match/PatternFromATaggedCellTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ TEST_F(PatternFromATaggedCellTest, DISABLED_setsAPropertyOfTheRelationshipTheVal
{{"Adam"}});
}

// Disabled: the analyzer turns away a key spelled in the query as an index, m['person'],
// asking for m.person instead.
TEST_F(PatternFromATaggedCellTest, DISABLED_startsAMatchFromANodeReadByALiteralIndex) {
TEST_F(PatternFromATaggedCellTest, startsAMatchFromANodeReadByALiteralIndex) {
expectRows("MATCH (n:Person {name: 'Remy'}) WITH {person: n} AS m WITH m['person'] AS p "
"MATCH (p)-[:KNOWS_WELL]->(f) RETURN f.name",
{{"Adam"}});
Expand Down
Loading