diff --git a/regress/journey_planner_npm/cypher.ts b/regress/journey_planner_npm/cypher.ts index 20fb3f8ffd..2769f3b928 100644 --- a/regress/journey_planner_npm/cypher.ts +++ b/regress/journey_planner_npm/cypher.ts @@ -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", @@ -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", @@ -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]], }, ]; diff --git a/regress/journey_planner_npm/journey.ts b/regress/journey_planner_npm/journey.ts index e4ad5d466f..d446dc32b5 100644 --- a/regress/journey_planner_npm/journey.ts +++ b/regress/journey_planner_npm/journey.ts @@ -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..]", diff --git a/test/query/ir/journey/JourneyLegsTest.cpp b/test/query/ir/journey/JourneyLegsTest.cpp index 593df63a4d..e71369a1a7 100644 --- a/test/query/ir/journey/JourneyLegsTest.cpp +++ b/test/query/ir/journey/JourneyLegsTest.cpp @@ -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; diff --git a/test/query/ir/journey/JourneyParetoTest.cpp b/test/query/ir/journey/JourneyParetoTest.cpp index 00a17ec2da..e910d48394 100644 --- a/test/query/ir/journey/JourneyParetoTest.cpp +++ b/test/query/ir/journey/JourneyParetoTest.cpp @@ -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 "; diff --git a/test/query/ir/match/PatternFromATaggedCellTest.cpp b/test/query/ir/match/PatternFromATaggedCellTest.cpp index 6e24f26551..4c733b2dd8 100644 --- a/test/query/ir/match/PatternFromATaggedCellTest.cpp +++ b/test/query/ir/match/PatternFromATaggedCellTest.cpp @@ -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"}});