Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check license
command: check licenses

coverage:
if: github.event.pull_request.draft == false
Expand Down
19 changes: 19 additions & 0 deletions src/materialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ pub fn cast_to_listing_table(table: &dyn TableProvider) -> Option<&dyn ListingTa
})
}

// Re-exported for backward compatibility with downstream code that used
// to import `RewriteReadiness` from `crate::materialized`. The enum
// itself lives in `crate::rewrite::readiness` now (see PR #55 review),
// so all readiness-related types are grouped in one file.
pub use crate::rewrite::readiness::RewriteReadiness;

/// A hive-partitioned table in object storage that is defined by a user-provided query.
pub trait Materialized: ListingTableLike {
/// The query that defines this materialized view.
Expand All @@ -118,6 +124,19 @@ pub trait Materialized: ListingTableLike {
fn static_partition_columns(&self) -> Vec<String> {
<Self as ListingTableLike>::partition_columns(self)
}

/// Report whether this MV is currently safe to route queries to. See
/// [`RewriteReadiness`] for the semantics of each variant. Consulted by
/// [`ViewMatcher`](crate::rewrite::exploitation::ViewMatcher) during LP
/// rewrite; `NotReady` MVs are dropped from the candidate set upstream
/// of the cost function, so they never win a rewrite.
///
/// Default is `Unknown`, which means "include as candidate but the
/// cost function decides" — backward-compatible for providers that
/// don't distinguish lifecycle states.
fn rewrite_readiness(&self) -> RewriteReadiness {
RewriteReadiness::Unknown
}
}

/// Register a [`Materialized`] implementation in this registry.
Expand Down
6 changes: 1 addition & 5 deletions src/materialized/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,7 @@ fn pushdown_projection_inexact(plan: LogicalPlan, indices: &HashSet<usize>) -> R
)
.map(LogicalPlan::Filter)
}
LogicalPlan::Window(Window {
input,
window_expr: _,
..
}) => {
LogicalPlan::Window(Window { input, .. }) => {
// Window nodes take their input and append window expressions to the end.
// If our projection doesn't include window expressions, we can just turn
// the window into a regular projection.
Expand Down
20 changes: 9 additions & 11 deletions src/materialized/file_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,15 @@ impl FileMetadataExec {
return None;
}

let (column, literal) = if let Some(left_column) =
binary_expr.left().as_any().downcast_ref::<Column>()
{
let right_literal = binary_expr.right().as_any().downcast_ref::<Literal>()?;
(left_column, right_literal)
} else if let Some(right_column) = binary_expr.right().as_any().downcast_ref::<Column>() {
let left_literal = binary_expr.left().as_any().downcast_ref::<Literal>()?;
(right_column, left_literal)
} else {
return None;
};
let (column, literal) =
if let Some(left_column) = binary_expr.left().as_any().downcast_ref::<Column>() {
let right_literal = binary_expr.right().as_any().downcast_ref::<Literal>()?;
(left_column, right_literal)
} else {
let right_column = binary_expr.right().as_any().downcast_ref::<Column>()?;
let left_literal = binary_expr.left().as_any().downcast_ref::<Literal>()?;
(right_column, left_literal)
};

if column.index() != column_idx {
return None;
Expand Down
2 changes: 2 additions & 0 deletions src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub mod exploitation;

pub mod normal_form;

pub mod readiness;

mod util;

extensions_options! {
Expand Down
Loading
Loading