Adding splat[] short hand to explode,collect,flatten,groupby,path,pivot,select and more

This commit is contained in:
Mike Farah
2024-06-16 10:48:01 +10:00
parent f1964dece0
commit d58870b056
14 changed files with 146 additions and 13 deletions
+20
View File
@@ -14,6 +14,16 @@ var uniqueOperatorScenarios = []expressionScenario{
"D0, P[], (!!seq)::[2, 1, 3]\n",
},
},
{
description: "Unique splat",
skipDoc: true,
document: `[2,1,2]`,
expression: `unique[]`,
expected: []string{
"D0, P[0], (!!int)::2\n",
"D0, P[1], (!!int)::1\n",
},
},
{
description: "Unique nulls",
subdescription: "Unique works on the node value, so it considers different representations of nulls to be different",
@@ -64,6 +74,16 @@ var uniqueOperatorScenarios = []expressionScenario{
"D0, P[], (!!seq)::[{name: harry, pet: cat}, {pet: fish}]\n",
},
},
{
description: "unique by splat",
skipDoc: true,
document: `[{name: harry, pet: cat}, {pet: fish}, {name: harry, pet: dog}]`,
expression: `unique_by(.name)[]`,
expected: []string{
"D0, P[0], (!!map)::{name: harry, pet: cat}\n",
"D0, P[1], (!!map)::{pet: fish}\n",
},
},
{
skipDoc: true,
document: `[{name: harry, pet: cat}, {pet: fish}, {name: harry, pet: dog}]`,