From 196d61920cee68e54ef488e26ddbeb44a6eeb4a8 Mon Sep 17 00:00:00 2001 From: Stephen Mallette Date: Thu, 14 Mar 2024 07:33:21 -0400 Subject: [PATCH] Added test for select() semantics CTR --- .../Gherkin/Gremlin.cs | 1 + gremlin-go/driver/cucumber/gremlin.go | 1 + .../gremlin-javascript/test/cucumber/gremlin.js | 1 + gremlin-python/src/main/python/radish/gremlin.py | 1 + .../gremlin/test/features/map/Select.feature | 16 ++++++++++++++++ 5 files changed, 20 insertions(+) diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs index c44e000bb5a..9fc7e76b511 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs @@ -888,6 +888,7 @@ private static IDictionary, ITraversal>> {(g,p) =>g.WithStrategies(new ProductiveByStrategy(productiveKeys: new List {})).V().As("a").Select("a").By("age")}}, {"g_withSideEffectXk_nullX_injectXxX_selectXkX", new List, ITraversal>> {(g,p) =>g.WithSideEffect("k",null).Inject("x").Select("k")}}, {"g_V_out_in_selectXall_a_a_aX_byXunfold_name_foldX", new List, ITraversal>> {(g,p) =>g.AddV("A").Property("name","a1").As("a1").AddV("A").Property("name","a2").As("a2").AddV("A").Property("name","a3").As("a3").AddV("B").Property("name","b1").As("b1").AddV("B").Property("name","b2").As("b2").AddV("B").Property("name","b3").As("b3").AddE("ab").From("a1").To("b1").AddE("ab").From("a2").To("b2").AddE("ab").From("a3").To("b3"), (g,p) =>g.V().As("a").Out().As("a").In().As("a").Select(Pop.All,"a","a","a").By(__.Unfold().Values("name").Fold())}}, + {"g_V_asXlabelX_aggregateXlocal_xX_selectXxX_selectXlabelX", new List, ITraversal>> {(g,p) =>g.V().As("label").Aggregate(Scope.Local,"x").Select("x").Select("label")}}, {"g_V_shortestPath", new List, ITraversal>> {(g,p) =>g.V().Identity().ShortestPath()}}, {"g_V_both_dedup_shortestPath", new List, ITraversal>> {(g,p) =>g.V().Both().Dedup().ShortestPath()}}, {"g_V_shortestPath_edgesIncluded", new List, ITraversal>> {(g,p) =>g.V().Identity().ShortestPath().With("~tinkerpop.shortestPath.includeEdges")}}, diff --git a/gremlin-go/driver/cucumber/gremlin.go b/gremlin-go/driver/cucumber/gremlin.go index babc62777f6..d1f6fc14932 100644 --- a/gremlin-go/driver/cucumber/gremlin.go +++ b/gremlin-go/driver/cucumber/gremlin.go @@ -859,6 +859,7 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[ "g_withStrategiesXProductiveByStrategyX_V_asXaX_selectXaX_byXageX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.ProductiveByStrategy(gremlingo.ProductiveByStrategyConfig{ProductiveKeys: []string{}})).V().As("a").Select("a").By("age")}}, "g_withSideEffectXk_nullX_injectXxX_selectXkX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithSideEffect("k", nil).Inject("x").Select("k")}}, "g_V_out_in_selectXall_a_a_aX_byXunfold_name_foldX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("A").Property("name", "a1").As("a1").AddV("A").Property("name", "a2").As("a2").AddV("A").Property("name", "a3").As("a3").AddV("B").Property("name", "b1").As("b1").AddV("B").Property("name", "b2").As("b2").AddV("B").Property("name", "b3").As("b3").AddE("ab").From("a1").To("b1").AddE("ab").From("a2").To("b2").AddE("ab").From("a3").To("b3")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("a").Out().As("a").In().As("a").Select(gremlingo.Pop.All, "a", "a", "a").By(gremlingo.T__.Unfold().Values("name").Fold())}}, + "g_V_asXlabelX_aggregateXlocal_xX_selectXxX_selectXlabelX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("label").Aggregate(gremlingo.Scope.Local, "x").Select("x").Select("label")}}, "g_V_shortestPath": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Identity().ShortestPath()}}, "g_V_both_dedup_shortestPath": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Both().Dedup().ShortestPath()}}, "g_V_shortestPath_edgesIncluded": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Identity().ShortestPath().With("~tinkerpop.shortestPath.includeEdges")}}, diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js index 55e070d495c..479575d5fc8 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js @@ -878,6 +878,7 @@ const gremlins = { g_withStrategiesXProductiveByStrategyX_V_asXaX_selectXaX_byXageX: [function({g}) { return g.withStrategies(new ProductiveByStrategy({productiveKeys:[]})).V().as("a").select("a").by("age") }], g_withSideEffectXk_nullX_injectXxX_selectXkX: [function({g}) { return g.withSideEffect("k",null).inject("x").select("k") }], g_V_out_in_selectXall_a_a_aX_byXunfold_name_foldX: [function({g}) { return g.addV("A").property("name","a1").as("a1").addV("A").property("name","a2").as("a2").addV("A").property("name","a3").as("a3").addV("B").property("name","b1").as("b1").addV("B").property("name","b2").as("b2").addV("B").property("name","b3").as("b3").addE("ab").from_("a1").to("b1").addE("ab").from_("a2").to("b2").addE("ab").from_("a3").to("b3") }, function({g}) { return g.V().as("a").out().as("a").in_().as("a").select(Pop.all,"a","a","a").by(__.unfold().values("name").fold()) }], + g_V_asXlabelX_aggregateXlocal_xX_selectXxX_selectXlabelX: [function({g}) { return g.V().as("label").aggregate(Scope.local,"x").select("x").select("label") }], g_V_shortestPath: [function({g}) { return g.V().identity().shortestPath() }], g_V_both_dedup_shortestPath: [function({g}) { return g.V().both().dedup().shortestPath() }], g_V_shortestPath_edgesIncluded: [function({g}) { return g.V().identity().shortestPath().with_("~tinkerpop.shortestPath.includeEdges") }], diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py index 25fe62acd36..448114d306a 100644 --- a/gremlin-python/src/main/python/radish/gremlin.py +++ b/gremlin-python/src/main/python/radish/gremlin.py @@ -860,6 +860,7 @@ 'g_withStrategiesXProductiveByStrategyX_V_asXaX_selectXaX_byXageX': [(lambda g:g.withStrategies(*[TraversalStrategy('ProductiveByStrategy',{'productiveKeys':[],'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.ProductiveByStrategy'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.ProductiveByStrategy')]).V().as_('a').select('a').by('age'))], 'g_withSideEffectXk_nullX_injectXxX_selectXkX': [(lambda g:g.withSideEffect('k',None).inject('x').select('k'))], 'g_V_out_in_selectXall_a_a_aX_byXunfold_name_foldX': [(lambda g:g.addV('A').property('name','a1').as_('a1').addV('A').property('name','a2').as_('a2').addV('A').property('name','a3').as_('a3').addV('B').property('name','b1').as_('b1').addV('B').property('name','b2').as_('b2').addV('B').property('name','b3').as_('b3').addE('ab').from_('a1').to('b1').addE('ab').from_('a2').to('b2').addE('ab').from_('a3').to('b3')), (lambda g:g.V().as_('a').out().as_('a').in_().as_('a').select(Pop.all_,'a','a','a').by(__.unfold().name.fold()))], + 'g_V_asXlabelX_aggregateXlocal_xX_selectXxX_selectXlabelX': [(lambda g:g.V().as_('label').aggregate(Scope.local,'x').select('x').select('label'))], 'g_V_shortestPath': [(lambda g:g.V().identity().shortestPath())], 'g_V_both_dedup_shortestPath': [(lambda g:g.V().both().dedup().shortestPath())], 'g_V_shortestPath_edgesIncluded': [(lambda g:g.V().identity().shortestPath().with_('~tinkerpop.shortestPath.includeEdges'))], diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Select.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Select.feature index ef8d815ed9a..b2f8ef8dc53 100644 --- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Select.feature +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/map/Select.feature @@ -901,3 +901,19 @@ Feature: Step - select() | m[{"a":["a1","b1","a1"]}] | | m[{"a":["a2","b2","a2"]}] | | m[{"a":["a3","b3","a3"]}] | + + Scenario: g_V_asXlabelX_aggregateXlocal_xX_selectXxX_selectXlabelX + Given the modern graph + And the traversal of + """ + g.V().as("label").aggregate(local,"x").select("x").select("label") + """ + When iterated to list + Then the result should be unordered + | result | + | v[marko] | + | v[vadas] | + | v[lop] | + | v[josh] | + | v[ripple] | + | v[peter] | \ No newline at end of file