mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-31 09:20:50 +01:00
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.
34 lines
935 B
Go
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)
|
|
}
|
|
}
|