@@ -161,6 +161,40 @@ func TestPrimitiveMatcher(t *testing.T) {
161161 assert .False (t , match .Matches (arrow .Null ))
162162}
163163
164+ func TestREEMatcher (t * testing.T ) {
165+ tests := []struct {
166+ runEnds exec.TypeMatcher
167+ enc exec.TypeMatcher
168+ matchRunEnds arrow.DataType
169+ nomatchRunEnds arrow.DataType
170+ matchEnc arrow.DataType
171+ nomatchEnc arrow.DataType
172+ }{
173+ {exec .Integer (), exec .Integer (), arrow .PrimitiveTypes .Int16 , arrow .FixedWidthTypes .Float16 , arrow .PrimitiveTypes .Int8 , arrow .BinaryTypes .String },
174+ {exec .SameTypeID (arrow .INT32 ), exec .BinaryLike (), arrow .PrimitiveTypes .Int32 , arrow .PrimitiveTypes .Int64 , arrow .BinaryTypes .String , arrow .PrimitiveTypes .Int32 },
175+ {exec .SameTypeID (arrow .INT64 ), exec .SameTypeID (arrow .STRUCT ), arrow .PrimitiveTypes .Int64 , arrow .PrimitiveTypes .Int32 , arrow .StructOf (arrow.Field {Name : "a" , Type : arrow .PrimitiveTypes .Int16 }), arrow .PrimitiveTypes .Int8 },
176+ }
177+
178+ for _ , tt := range tests {
179+ t .Run (tt .enc .String (), func (t * testing.T ) {
180+ matcher := exec .RunEndEncoded (tt .runEnds , tt .enc )
181+ assert .False (t , matcher .Matches (tt .matchEnc ))
182+ assert .True (t , matcher .Matches (arrow .RunEndEncodedOf (tt .matchRunEnds , tt .matchEnc )))
183+ assert .False (t , matcher .Matches (arrow .RunEndEncodedOf (tt .matchRunEnds , tt .nomatchEnc )))
184+ assert .False (t , matcher .Matches (arrow .RunEndEncodedOf (tt .nomatchRunEnds , tt .matchEnc )))
185+ assert .False (t , matcher .Matches (arrow .RunEndEncodedOf (tt .nomatchRunEnds , tt .nomatchEnc )))
186+
187+ assert .Equal (t , "run_end_encoded(run_ends=" + tt .runEnds .String ()+ ", values=" + tt .enc .String ()+ ")" , matcher .String ())
188+
189+ assert .True (t , matcher .Equals (exec .RunEndEncoded (tt .runEnds , tt .enc )))
190+ assert .False (t , matcher .Equals (exec .Primitive ()))
191+ assert .False (t , matcher .Equals (exec .RunEndEncoded (exec .SameTypeID (tt .nomatchRunEnds .ID ()), exec .SameTypeID (tt .nomatchEnc .ID ()))))
192+ assert .False (t , matcher .Equals (exec .RunEndEncoded (exec .SameTypeID (tt .matchRunEnds .ID ()), exec .SameTypeID (tt .nomatchEnc .ID ()))))
193+ assert .False (t , matcher .Equals (exec .RunEndEncoded (exec .SameTypeID (tt .nomatchRunEnds .ID ()), exec .SameTypeID (tt .matchEnc .ID ()))))
194+ })
195+ }
196+ }
197+
164198func TestInputTypeAnyType (t * testing.T ) {
165199 var ty exec.InputType
166200 assert .Equal (t , exec .InputAny , ty .Kind )
0 commit comments