@@ -73,7 +73,7 @@ func TestFilesRowIter(t *testing.T) {
73
73
require .ElementsMatch (expected , rows )
74
74
}
75
75
76
- func TestFilesTablePushdown (t * testing.T ) {
76
+ func TestFilesTablePushdownFilters (t * testing.T ) {
77
77
ctx , _ , cleanup := setup (t )
78
78
defer cleanup ()
79
79
@@ -153,6 +153,56 @@ func TestFilesTablePushdown(t *testing.T) {
153
153
}
154
154
}
155
155
156
+ func TestFilesTablePushdownProjection (t * testing.T ) {
157
+ ctx , _ , cleanup := setup (t )
158
+ defer cleanup ()
159
+
160
+ filters := []sql.Expression {
161
+ expression .NewEquals (
162
+ expression .NewGetFieldWithTable (1 , sql .Text , FilesTableName , "file_path" , false ),
163
+ expression .NewLiteral ("LICENSE" , sql .Text ),
164
+ ),
165
+ }
166
+ table := new (filesTable ).WithFilters (filters ).(* filesTable )
167
+
168
+ testCases := []struct {
169
+ name string
170
+ projections []string
171
+ expected func (content []byte , size int64 ) bool
172
+ }{
173
+ {
174
+ "with blob_content projected" ,
175
+ []string {"blob_content" },
176
+ func (content []byte , size int64 ) bool { return int64 (len (content )) == size },
177
+ },
178
+ {
179
+ "without blob_content projected" ,
180
+ nil ,
181
+ func (content []byte , size int64 ) bool { return len (content ) == 0 },
182
+ },
183
+ }
184
+
185
+ for _ , test := range testCases {
186
+ t .Run (test .name , func (t * testing.T ) {
187
+ require := require .New (t )
188
+ tbl := table .WithProjection (test .projections )
189
+
190
+ rows , err := tableToRows (ctx , tbl )
191
+ require .NoError (err )
192
+
193
+ for _ , row := range rows {
194
+ content , ok := row [5 ].([]byte )
195
+ require .True (ok )
196
+
197
+ size , ok := row [6 ].(int64 )
198
+ require .True (ok )
199
+
200
+ require .True (test .expected (content , size ))
201
+ }
202
+ })
203
+ }
204
+ }
205
+
156
206
func TestFilesIndexKeyValueIter (t * testing.T ) {
157
207
require := require .New (t )
158
208
ctx , path , cleanup := setup (t )
0 commit comments