Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
srikrishnak committed Jan 16, 2025
1 parent 602f464 commit 574a317
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ func RelFromProto(rel *proto.Rel, reg expr.ExtensionRegistry) (Rel, error) {
out = &IcebergTableReadRel{
tableType: tableType,
}
} else {
return nil, fmt.Errorf("%w: only IcebergTableType Direct is supported", substraitgo.ErrInvalidRel)
}
default:
return nil, fmt.Errorf("%w: unknown ReadRel type", substraitgo.ErrInvalidRel)
}

if err := out.fromProtoReadRel(rel.Read, reg); err != nil {
Expand Down
27 changes: 27 additions & 0 deletions plan/relations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func TestRelations_Copy(t *testing.T) {
sortRel := &SortRel{input: createVirtualTableReadRel(1), sorts: []expr.SortField{{Expr: createPrimitiveFloat(1.0), Kind: types.SortAscNullsFirst}}}
virtualTableReadRel := &VirtualTableReadRel{values: []expr.VirtualTableExpressionValue{[]expr.Expression{&expr.PrimitiveLiteral[int64]{Value: 1}}}}
namedTableWriteRel := &NamedTableWriteRel{input: namedTableReadRel}
icebergTableReadRel := &IcebergTableReadRel{
baseReadRel: baseReadRel{filter: expr.NewPrimitiveLiteral(true, false)},
tableType: &Direct{
MetadataUri: "s3://bucket/path/to/metadata.json",
},
}

type relationTestCase struct {
name string
Expand Down Expand Up @@ -324,6 +330,27 @@ func TestRelations_Copy(t *testing.T) {
rewriteFunc: func(e expr.Expression) (expr.Expression, error) { return createPrimitiveFloat(9.0), nil },
expectedRel: &NamedTableWriteRel{input: createVirtualTableReadRel(6)},
},
{
name: "IcebergTableReadRel Copy with new inputs",
relation: icebergTableReadRel,
newInputs: []Rel{},
expectedSameRel: true,
},
{
name: "IcebergTableReadRel Copy with new inputs and rewriteFunc",
relation: icebergTableReadRel,
newInputs: []Rel{},
rewriteFunc: func(e expr.Expression) (expr.Expression, error) { return createPrimitiveFloat(9.0), nil },
expectedRel: &IcebergTableReadRel{
baseReadRel: baseReadRel{
filter: createPrimitiveFloat(9.0),
bestEffortFilter: createPrimitiveFloat(9.0),
},
tableType: &Direct{
MetadataUri: "s3://bucket/path/to/metadata.json",
},
},
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 574a317

Please sign in to comment.