Add tests for join/link multi value filtering
This commit is contained in:
committed by
Jože Fortun
parent
863ee99515
commit
f89d3d77e1
@@ -639,6 +639,81 @@ func TestStepJoinLocal(t *testing.T) {
|
||||
expression: "l_val == 'l2 v1'",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "filtering mv field single edge-case",
|
||||
outAttributes: append(basicAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
leftAttributes: append(basicLocalAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
rightAttributes: basicForeignAttrs,
|
||||
|
||||
joinPred: JoinPredicate{Left: "l_pk", Right: "f_fk"},
|
||||
lIn: []simpleRow{
|
||||
{"l_pk": 1, "l_const": []string{"a"}, "l_val": "l1 v1"},
|
||||
// For this row we'll use a single 'b', combined with a single value in the
|
||||
// mv field has an edge-case in the current implementation
|
||||
{"l_pk": 2, "l_const": []string{"bbbbbbb"}, "l_val": "l2 v1"},
|
||||
},
|
||||
fIn: []simpleRow{
|
||||
{"f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
{"f_pk": 2, "f_fk": 2, "f_val": "f2 v1"},
|
||||
},
|
||||
|
||||
out: []simpleRow{
|
||||
{"l_pk": 1, "l_const": []string{"a"}, "l_val": "l1 v1", "f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
},
|
||||
|
||||
f: internalFilter{
|
||||
expression: "'a' IN l_const OR 'b' IN l_const",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "filtering mv field on left attr",
|
||||
outAttributes: append(basicAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
leftAttributes: append(basicLocalAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
rightAttributes: basicForeignAttrs,
|
||||
|
||||
joinPred: JoinPredicate{Left: "l_pk", Right: "f_fk"},
|
||||
lIn: []simpleRow{
|
||||
{"l_pk": 1, "l_const": []string{"a", "b"}, "l_val": "l1 v1"},
|
||||
{"l_pk": 2, "l_const": []string{"b", "c"}, "l_val": "l2 v1"},
|
||||
},
|
||||
fIn: []simpleRow{
|
||||
{"f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
{"f_pk": 2, "f_fk": 2, "f_val": "f2 v1"},
|
||||
},
|
||||
|
||||
out: []simpleRow{
|
||||
{"l_pk": 1, "l_const": []string{"a", "b"}, "l_val": "l1 v1", "f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
},
|
||||
|
||||
f: internalFilter{
|
||||
expression: "'b' IN l_const AND 'c' NOT IN l_const",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "filtering mv field on right attr",
|
||||
outAttributes: basicAttrs,
|
||||
leftAttributes: append(basicLocalAttrs, simpleAttribute{ident: "r_const", multivalue: true}),
|
||||
rightAttributes: append(basicForeignAttrs, simpleAttribute{ident: "r_const", multivalue: true}),
|
||||
|
||||
joinPred: JoinPredicate{Left: "l_pk", Right: "f_fk"},
|
||||
lIn: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1"},
|
||||
{"l_pk": 2, "l_val": "l2 v1"},
|
||||
},
|
||||
fIn: []simpleRow{
|
||||
{"f_pk": 1, "f_fk": 1, "r_const": []string{"a", "b"}, "f_val": "f1 v1"},
|
||||
{"f_pk": 2, "f_fk": 2, "r_const": []string{"b", "c"}, "f_val": "f2 v1"},
|
||||
},
|
||||
|
||||
out: []simpleRow{
|
||||
{"l_pk": 1, "r_const": []string{"a", "b"}, "l_val": "l1 v1", "f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
},
|
||||
|
||||
f: internalFilter{
|
||||
expression: "'b' IN r_const AND 'c' NOT IN r_const",
|
||||
},
|
||||
},
|
||||
}
|
||||
paging := []testCase{
|
||||
{
|
||||
|
||||
@@ -432,6 +432,90 @@ func TestStepLinkLeft(t *testing.T) {
|
||||
expression: "f_val == 'f1 v1'",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "filtering mv field single edge-case",
|
||||
leftAttributes: append(basicLeftAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
rightAttributes: basicRightAttrs,
|
||||
leftOutAttributes: append(basicOutLeftAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
rightOutAttributes: basicOutRightAttrs,
|
||||
linkPred: LinkPredicate{Left: "l_pk", Right: "f_fk"},
|
||||
|
||||
lIn: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1", "l_const": []string{"a"}},
|
||||
// For this row we'll use a single 'b', combined with a single value in the
|
||||
// mv field has an edge-case in the current implementation
|
||||
{"l_pk": 2, "l_val": "l2 v1", "l_const": []string{"bbbbbbb"}},
|
||||
},
|
||||
|
||||
fIn: []simpleRow{
|
||||
{"f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
{"f_pk": 2, "f_fk": 2, "f_val": "f2 v1"},
|
||||
},
|
||||
|
||||
out: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1", "l_const": []string{"a"}},
|
||||
{"$sys.ref": "right", "f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
},
|
||||
|
||||
f: internalFilter{
|
||||
expression: "'a' IN l_const OR 'b' IN l_const",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "filtering mv field left",
|
||||
leftAttributes: append(basicLeftAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
rightAttributes: basicRightAttrs,
|
||||
leftOutAttributes: append(basicOutLeftAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
rightOutAttributes: basicOutRightAttrs,
|
||||
linkPred: LinkPredicate{Left: "l_pk", Right: "f_fk"},
|
||||
|
||||
lIn: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1", "l_const": []string{"a", "b"}},
|
||||
{"l_pk": 2, "l_val": "l2 v1", "l_const": []string{"b", "c"}},
|
||||
},
|
||||
|
||||
fIn: []simpleRow{
|
||||
{"f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
{"f_pk": 2, "f_fk": 2, "f_val": "f2 v1"},
|
||||
},
|
||||
|
||||
out: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1", "l_const": []string{"a", "b"}},
|
||||
{"$sys.ref": "right", "f_pk": 1, "f_fk": 1, "f_val": "f1 v1"},
|
||||
},
|
||||
|
||||
f: internalFilter{
|
||||
expression: "'b' IN l_const AND 'c' NOT IN l_const",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "filtering mv field right",
|
||||
leftAttributes: basicLeftAttrs,
|
||||
rightAttributes: append(basicRightAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
leftOutAttributes: basicOutLeftAttrs,
|
||||
rightOutAttributes: append(basicOutRightAttrs, simpleAttribute{ident: "l_const", multivalue: true}),
|
||||
linkPred: LinkPredicate{Left: "l_pk", Right: "f_fk"},
|
||||
|
||||
lIn: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1"},
|
||||
{"l_pk": 2, "l_val": "l2 v1"},
|
||||
},
|
||||
|
||||
fIn: []simpleRow{
|
||||
{"f_pk": 1, "f_fk": 1, "f_val": "f1 v1", "r_const": []string{"a", "b"}},
|
||||
{"f_pk": 2, "f_fk": 2, "f_val": "f2 v1", "r_const": []string{"b", "c"}},
|
||||
},
|
||||
|
||||
out: []simpleRow{
|
||||
{"l_pk": 1, "l_val": "l1 v1"},
|
||||
{"$sys.ref": "right", "f_pk": 1, "f_fk": 1, "f_val": "f1 v1", "r_const": []string{"a", "b"}},
|
||||
},
|
||||
|
||||
f: internalFilter{
|
||||
expression: "'b' IN r_const AND 'c' NOT IN r_const",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sorting := []testCase{
|
||||
|
||||
@@ -7,11 +7,12 @@ import (
|
||||
|
||||
type (
|
||||
simpleAttribute struct {
|
||||
ident string
|
||||
source string
|
||||
expr string
|
||||
primary bool
|
||||
t Type
|
||||
ident string
|
||||
source string
|
||||
expr string
|
||||
primary bool
|
||||
multivalue bool
|
||||
t Type
|
||||
}
|
||||
|
||||
simpleRow map[string]any
|
||||
@@ -48,8 +49,9 @@ func saToAggAttr(sa ...simpleAttribute) []AggregateAttr {
|
||||
|
||||
func (sa simpleAttribute) Properties() MapProperties {
|
||||
return MapProperties{
|
||||
IsPrimary: sa.primary,
|
||||
Type: sa.t,
|
||||
IsPrimary: sa.primary,
|
||||
Type: sa.t,
|
||||
IsMultivalue: sa.multivalue,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user