diff --git a/go.sum b/go.sum index b0df017..aa15761 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,6 @@ -github.com/alecthomas/assert/v2 v2.0.3 h1:WKqJODfOiQG0nEJKFKzDIG3E29CN2/4zR9XGJzKIkbg= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= -github.com/alecthomas/participle/v2 v2.0.0-beta.5 h1:y6dsSYVb1G5eK6mgmy+BgI3Mw35a3WghArZ/Hbebrjo= -github.com/alecthomas/participle/v2 v2.0.0-beta.5/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM= github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g= github.com/alecthomas/participle/v2 v2.0.0/go.mod h1:rAKZdJldHu8084ojcWevWAL8KmEU+AT+Olodb+WoN2Y= -github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/plan/builders.go b/plan/builders.go index dbba96a..0352bb9 100644 --- a/plan/builders.go +++ b/plan/builders.go @@ -449,10 +449,6 @@ func (b *builder) VirtualTableRemap(fieldNames []string, remap []int32, values . } nfields := len(fieldNames) - if nfields == 0 { - return nil, fmt.Errorf("%w: must provide at least 1 field for virtual table", substraitgo.ErrInvalidRel) - } - if len(values[0]) != nfields { return nil, fmt.Errorf("%w: mismatched number of fields (%d) and literal values (%d) in virtual table", substraitgo.ErrInvalidRel, nfields, len(values[0])) diff --git a/plan/plan_builder_test.go b/plan/plan_builder_test.go index 92f49cb..56e132b 100644 --- a/plan/plan_builder_test.go +++ b/plan/plan_builder_test.go @@ -1414,6 +1414,62 @@ func TestSetRelations(t *testing.T) { checkRoundTrip(t, expectedJSON, p) } +func TestEmptyVirtualTable(t *testing.T) { + const expectedJSON = `{ + ` + versionStruct + `, + "relations": [ + { + "root": { + "input": { + "read": { + "common": {"direct":{}}, + "baseSchema": { + "struct": { + "nullability": "NULLABILITY_REQUIRED" + } + }, + "virtualTable": { + "values": [ + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {}, + {} + ] + } + } + } + } + } + ] + }` + + b := plan.NewBuilderDefault() + + virtual, err := b.VirtualTable(nil, make([]expr.StructLiteralValue, 20)...) + require.NoError(t, err) + + p, err := b.Plan(virtual, []string{}) + require.NoError(t, err) + + checkRoundTrip(t, expectedJSON, p) +} + func TestSetRelErrors(t *testing.T) { b := plan.NewBuilderDefault()