File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -43,3 +43,18 @@ pub mod materialized;
4343
4444/// An implementation of Query Rewriting, an optimization that rewrites queries to make use of materialized views.
4545pub mod rewrite;
46+
47+ /// Configuration options for materialized view related features.
48+ #[ derive( Debug , Clone ) ]
49+ pub struct MaterializedConfig {
50+ /// Whether or not query rewriting should exploit this materialized view.
51+ pub use_in_query_rewrite : bool ,
52+ }
53+
54+ impl Default for MaterializedConfig {
55+ fn default ( ) -> Self {
56+ Self {
57+ use_in_query_rewrite : true ,
58+ }
59+ }
60+ }
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ use datafusion::{
4444use datafusion_expr:: LogicalPlan ;
4545use itertools:: Itertools ;
4646
47+ use crate :: MaterializedConfig ;
48+
4749/// The identifier of the column that [`RowMetadataSource`](row_metadata::RowMetadataSource) implementations should store row metadata in.
4850pub const META_COLUMN : & str = "__meta" ;
4951
@@ -102,6 +104,12 @@ pub fn cast_to_listing_table(table: &dyn TableProvider) -> Option<&dyn ListingTa
102104pub trait Materialized : ListingTableLike {
103105 /// The query that defines this materialized view.
104106 fn query ( & self ) -> LogicalPlan ;
107+
108+ /// Configuration to control materialized view related features.
109+ /// By default, returns the default value for [`MaterializedConfig`]
110+ fn config ( & self ) -> MaterializedConfig {
111+ MaterializedConfig :: default ( )
112+ }
105113}
106114
107115/// Register a [`Materialized`] implementation in this registry.
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ impl ViewMatcher {
6060 continue ;
6161 } ;
6262
63+ if !mv. config ( ) . use_in_query_rewrite {
64+ continue ;
65+ }
66+
6367 // Analyze the plan to normalize things such as wildcard expressions
6468 let analyzed_plan = session_state. analyzer ( ) . execute_and_check (
6569 mv. query ( ) ,
You can’t perform that action at this time.
0 commit comments