@@ -23,7 +23,7 @@ use std::{
23
23
24
24
use arrow:: datatypes:: SchemaRef ;
25
25
use async_trait:: async_trait;
26
- use common_types:: { projected_schema:: ProjectedSchema , request_id:: RequestId , schema:: Schema } ;
26
+ use common_types:: { projected_schema:: ProjectedSchema , request_id:: RequestId , schema:: Schema , UPDATE_MODE } ;
27
27
use datafusion:: {
28
28
config:: { ConfigEntry , ConfigExtension , ExtensionOptions } ,
29
29
datasource:: TableProvider ,
@@ -186,10 +186,16 @@ impl TableProviderAdapter {
186
186
fn check_and_build_predicate_from_filters ( & self , filters : & [ Expr ] ) -> PredicateRef {
187
187
let unique_keys = self . read_schema . unique_keys ( ) ;
188
188
189
+ let options = & self . table . options ( ) ;
190
+ let is_append = match options. get ( UPDATE_MODE ) {
191
+ Some ( mode) if mode == "APPEND" => true ,
192
+ _ => false
193
+ } ;
194
+
189
195
let push_down_filters = filters
190
196
. iter ( )
191
197
. filter_map ( |filter| {
192
- if Self :: only_filter_unique_key_columns ( filter, & unique_keys) {
198
+ if Self :: only_filter_unique_key_columns ( filter, & unique_keys) && is_append {
193
199
Some ( filter. clone ( ) )
194
200
} else {
195
201
None
@@ -238,7 +244,7 @@ impl TableProvider for TableProviderAdapter {
238
244
}
239
245
240
246
fn supports_filter_pushdown ( & self , _filter : & Expr ) -> Result < TableProviderFilterPushDown > {
241
- Ok ( TableProviderFilterPushDown :: Inexact )
247
+ Ok ( TableProviderFilterPushDown :: Exact )
242
248
}
243
249
244
250
/// Get the type of this table for metadata/catalog purposes.
@@ -265,7 +271,7 @@ impl TableSource for TableProviderAdapter {
265
271
/// Tests whether the table provider can make use of a filter expression
266
272
/// to optimize data retrieval.
267
273
fn supports_filter_pushdown ( & self , _filter : & Expr ) -> Result < TableProviderFilterPushDown > {
268
- Ok ( TableProviderFilterPushDown :: Inexact )
274
+ Ok ( TableProviderFilterPushDown :: Exact )
269
275
}
270
276
}
271
277
0 commit comments