Files
seaweedfs/weed/parquet_pushdown/request_validation_predicate_test.go
T
Chris Lu 9561d95507 parquet_pushdown: predicate must be a bound expression with schema id
Without naming a schema, a serialized predicate's column references
are ambiguous: the same field name can refer to different field IDs
across schema-evolution events, and Substrait field-reference IDs
mean nothing without saying which schema they index into.

Make the request shape unambiguous:

- Add ParquetPushdownRequest.SchemaId (Iceberg schema id) to the
  proto and to the design's API sketch.
- Document the binding contract in the design: the predicate must
  carry only field-id references; the connector binds before
  sending, the server checks ids against the schema.
- Validation now rejects (predicate set, schema_id == 0) with
  InvalidArgument before any work is done. Deeper "every field id
  exists in the snapshot's schema" check needs catalog access and
  lands in M3.
- Update / add tests covering the new gate.
2026-04-25 15:07:12 -07:00

34 lines
935 B
Go

package parquet_pushdown
import (
"testing"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
pb "github.com/seaweedfs/seaweedfs/weed/pb/parquet_pushdown_pb"
)
// A predicate paired with a SchemaId is the well-formed shape; a
// well-formed predicate without SchemaId must be rejected (deeper
// catalog binding lands in M3).
func TestValidateRequest_PredicateRequiresSchemaId(t *testing.T) {
req := validRequest()
req.PredicateKind = pb.PredicateKind_PREDICATE_KIND_SUBSTRAIT
req.Predicate = []byte("bound expression bytes")
req.SchemaId = 7
if err := validateRequest(req); err != nil {
t.Fatalf("predicate + schema_id should pass, got %v", err)
}
req.SchemaId = 0
err := validateRequest(req)
if err == nil {
t.Fatal("predicate without schema_id should be rejected")
}
if status.Code(err) != codes.InvalidArgument {
t.Fatalf("got %v, want InvalidArgument (err=%v)", status.Code(err), err)
}
}