Skip to content

Commit 4e7848a

Browse files
dust1jiacai2050
authored andcommitted
add: add check table is in append mode
1 parent 33dec40 commit 4e7848a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

table_engine/src/provider.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::{
2323

2424
use arrow::datatypes::SchemaRef;
2525
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};
2727
use datafusion::{
2828
config::{ConfigEntry, ConfigExtension, ExtensionOptions},
2929
datasource::TableProvider,
@@ -186,10 +186,16 @@ impl TableProviderAdapter {
186186
fn check_and_build_predicate_from_filters(&self, filters: &[Expr]) -> PredicateRef {
187187
let unique_keys = self.read_schema.unique_keys();
188188

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+
189195
let push_down_filters = filters
190196
.iter()
191197
.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 {
193199
Some(filter.clone())
194200
} else {
195201
None
@@ -238,7 +244,7 @@ impl TableProvider for TableProviderAdapter {
238244
}
239245

240246
fn supports_filter_pushdown(&self, _filter: &Expr) -> Result<TableProviderFilterPushDown> {
241-
Ok(TableProviderFilterPushDown::Inexact)
247+
Ok(TableProviderFilterPushDown::Exact)
242248
}
243249

244250
/// Get the type of this table for metadata/catalog purposes.
@@ -265,7 +271,7 @@ impl TableSource for TableProviderAdapter {
265271
/// Tests whether the table provider can make use of a filter expression
266272
/// to optimize data retrieval.
267273
fn supports_filter_pushdown(&self, _filter: &Expr) -> Result<TableProviderFilterPushDown> {
268-
Ok(TableProviderFilterPushDown::Inexact)
274+
Ok(TableProviderFilterPushDown::Exact)
269275
}
270276
}
271277

0 commit comments

Comments
 (0)