forked from datafusion-contrib/datafusion-materialized-views
-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/strict unions #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
matthewmturner
wants to merge
49
commits into
main
Choose a base branch
from
feat/strict-unions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
d4cc10f
Upgrade DataFusion 48.0.0 (#61)
xudong963 25e5ccc
Upgrade to DF49 (#75)
xudong963 3026895
Upgrade DF to 49.0.2 (#86)
zhuqi-lucas d8364fb
make cost fn accept candidates (#83)
xudong963 540f29e
Fix empty unnest columns handling when pushdown_projection_inexact (#88)
zhuqi-lucas 169eb66
upgrade to DF50 (#87)
xudong963 f485d46
Update internal DF 50
zhuqi-lucas 3707a1e
fix CI
zhuqi-lucas bf2725b
fmt
zhuqi-lucas bc4cd51
Fix ci
zhuqi-lucas d7dd6b0
fix ci
zhuqi-lucas b426f5b
fix ci
zhuqi-lucas c34bb15
fix ci
zhuqi-lucas 947bd8e
Merge pull request #13 from polygon-io/update-internal-df-50
zhuqi-lucas 9c68378
upgrade df
zhuqi-lucas 8d57dd4
Merge pull request #14 from polygon-io/upgrade-df-for-mv
xudong963 6164917
debug testing
zhuqi-lucas e6c4b35
update DF version
zhuqi-lucas b7f64b6
Support static partition columns for MV (#89)
suremarc 1af1666
support limit pushdown for oneofexec
xudong963 946ead3
Merge pull request #16 from polygon-io/branch-50-enable-limit-pushdown
xudong963 eaf03ef
Update DF version
xudong963 849e951
Merge pull request #17 from polygon-io/update_version
xudong963 65dc5e6
update df version
xudong963 a5379e2
Update datafusion
zhuqi-lucas cdc6784
[X-1289] add benchmark for heavy operation for datafusion-materialize…
zhuqi-lucas ddf4c65
fmt
zhuqi-lucas 24fb12e
fix ci
zhuqi-lucas 330f367
Merge pull request #18 from polygon-io/X-1289
zhuqi-lucas 5dac819
update datafusion
zhuqi-lucas 2a4dc27
Update df version
zhuqi-lucas 2d933c7
Fix Deps
wyatt-herkamp 0552842
update DF version
xudong963 ea368ae
Upgrade DF 51 (#20)
jcsherin 823f86c
chore: update DF version
jcsherin aeb7978
prevent rewriting strict inequality to closed interval for non-discre…
Friede80 b6a9e7f
Expose mv_plans for ViewMatcher (#22)
xudong963 3347228
Create a new OneOf node with the given branches (#23)
xudong963 560648f
update DF version
xudong963 4484dd3
update DF version
xudong963 5a14924
Update df
zhuqi-lucas 81db5c2
Update DF version
zhuqi-lucas 65457f2
Update DF version
zhuqi-lucas f60dd33
Optimize rewrite performance and SPJ new (#24)
zhuqi-lucas 88b7fb2
update DF version
xudong963 6e1307c
Update DF version (#26)
trevor-wilson-polygonio 6d0e950
[X-2048] Support view matcher with boolean binary operation (#27)
zhuqi-lucas 8835c81
Fix/aggregate output ordering streaming
xudong963 51724c1
Strict unions option
matthewmturner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(cargo clippy:*)" | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # typos configuration file | ||
| # Place this file in the project root (same level as Cargo.toml) | ||
| [files] | ||
| extend-exclude = ["Cargo.toml", "**/Cargo.toml"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; | ||
| use std::sync::Arc; | ||
| use std::time::Duration; | ||
|
|
||
| use datafusion::datasource::provider_as_source; | ||
| use datafusion::datasource::TableProvider; | ||
| use datafusion::prelude::SessionContext; | ||
| use datafusion_common::Result as DfResult; | ||
| use datafusion_expr::LogicalPlan; | ||
| use datafusion_materialized_views::rewrite::normal_form::SpjNormalForm; | ||
| use datafusion_sql::TableReference; | ||
| use tokio::runtime::Builder; | ||
|
|
||
| // Utility: generate CREATE TABLE SQL with n columns named c0..c{n-1} | ||
| fn make_create_table_sql(table_name: &str, ncols: usize) -> String { | ||
| let cols = (0..ncols) | ||
| .map(|i| format!("c{} INT", i)) | ||
| .collect::<Vec<_>>() | ||
| .join(", "); | ||
| format!( | ||
| "CREATE TABLE {table} ({cols})", | ||
| table = table_name, | ||
| cols = cols | ||
| ) | ||
| } | ||
|
|
||
| // Utility: generate a base SELECT that projects all columns and has a couple filters | ||
| fn make_base_sql(table_name: &str, ncols: usize) -> String { | ||
| let cols = (0..ncols) | ||
| .map(|i| format!("c{}", i)) | ||
| .collect::<Vec<_>>() | ||
| .join(", "); | ||
| let mut where_clauses = vec![]; | ||
| if ncols > 0 { | ||
| where_clauses.push("c0 >= 0".to_string()); | ||
| } | ||
| if ncols > 1 { | ||
| where_clauses.push("c0 + c1 >= 0".to_string()); | ||
| } | ||
| let where_part = if where_clauses.is_empty() { | ||
| "".to_string() | ||
| } else { | ||
| format!(" WHERE {}", where_clauses.join(" AND ")) | ||
| }; | ||
| format!("SELECT {cols} FROM {table}{where}", cols = cols, table = table_name, where = where_part) | ||
| } | ||
|
|
||
| // Utility: generate a query that is stricter and selects subset (so rewrite_from has a chance) | ||
| fn make_query_sql(table_name: &str, ncols: usize) -> String { | ||
| let take = std::cmp::max(1, ncols / 2); | ||
| let cols = (0..take) | ||
| .map(|i| format!("c{}", i)) | ||
| .collect::<Vec<_>>() | ||
| .join(", "); | ||
|
|
||
| let mut where_clauses = vec![]; | ||
| if ncols > 0 { | ||
| where_clauses.push("c0 >= 10".to_string()); | ||
| } | ||
| if ncols > 1 { | ||
| where_clauses.push("c0 * c1 > 100".to_string()); | ||
| } | ||
| if ncols > 10 { | ||
| where_clauses.push(format!("c{} >= 0", ncols - 1)); | ||
| } | ||
|
|
||
| let where_part = if where_clauses.is_empty() { | ||
| "".to_string() | ||
| } else { | ||
| format!(" WHERE {}", where_clauses.join(" AND ")) | ||
| }; | ||
|
|
||
| format!("SELECT {cols} FROM {table}{where}", cols = cols, table = table_name, where = where_part) | ||
| } | ||
|
|
||
| // Build fixture: create SessionContext, the table, then return LogicalPlans for base & query and table provider | ||
| fn build_fixture_for_cols( | ||
| rt: &tokio::runtime::Runtime, | ||
| ncols: usize, | ||
| ) -> DfResult<(LogicalPlan, LogicalPlan, Arc<dyn TableProvider>)> { | ||
| rt.block_on(async move { | ||
| let ctx = SessionContext::new(); | ||
|
|
||
| // create table | ||
| let table_name = "t"; | ||
| let create_sql = make_create_table_sql(table_name, ncols); | ||
| ctx.sql(&create_sql).await?.collect().await?; // create table in catalog | ||
|
|
||
| // base and query plans (optimize to normalize) | ||
| let base_sql = make_base_sql(table_name, ncols); | ||
| let query_sql = make_query_sql(table_name, ncols); | ||
|
|
||
| let base_df = ctx.sql(&base_sql).await?; | ||
| let base_plan = base_df.into_optimized_plan()?; | ||
|
|
||
| let query_df = ctx.sql(&query_sql).await?; | ||
| let query_plan = query_df.into_optimized_plan()?; | ||
|
|
||
| // get table provider (Arc<dyn TableProvider>) | ||
| let table_ref = TableReference::bare(table_name); | ||
| let provider: Arc<dyn TableProvider> = ctx.table_provider(table_ref.clone()).await?; | ||
|
|
||
| Ok((base_plan, query_plan, provider)) | ||
| }) | ||
| } | ||
|
|
||
| // Criterion benchmark | ||
| fn criterion_benchmark(c: &mut Criterion) { | ||
| // columns to test | ||
| let col_cases = vec![1usize, 10, 20, 40, 80, 160, 320]; | ||
|
|
||
| // build a tokio runtime that's broadly compatible | ||
| let rt = Builder::new_current_thread() | ||
| .enable_all() | ||
| .build() | ||
| .expect("tokio runtime"); | ||
|
|
||
| let mut group = c.benchmark_group("view_matcher_spj"); | ||
| group.warm_up_time(Duration::from_secs(1)); | ||
| group.measurement_time(Duration::from_secs(5)); | ||
| group.sample_size(30); | ||
|
|
||
| for &ncols in &col_cases { | ||
| // Build fixture | ||
| let (base_plan, query_plan, provider) = | ||
| build_fixture_for_cols(&rt, ncols).expect("fixture"); | ||
|
|
||
| // Measure SpjNormalForm::new for base_plan and query_plan separately | ||
| let id_base = BenchmarkId::new("spj_normal_form_new", format!("cols={}", ncols)); | ||
| group.throughput(Throughput::Elements(1)); | ||
| group.bench_with_input(id_base, &base_plan, |b, plan| { | ||
| b.iter(|| { | ||
| let _nf = SpjNormalForm::new(plan).unwrap(); | ||
| }); | ||
| }); | ||
|
|
||
| let id_query_nf = BenchmarkId::new("spj_normal_form_new_query", format!("cols={}", ncols)); | ||
| group.bench_with_input(id_query_nf, &query_plan, |b, plan| { | ||
| b.iter(|| { | ||
| let _nf = SpjNormalForm::new(plan).unwrap(); | ||
| }); | ||
| }); | ||
|
|
||
| // Precompute normal forms once (to measure rewrite_from cost only) | ||
| let base_nf = SpjNormalForm::new(&base_plan).expect("base_nf"); | ||
| let query_nf = SpjNormalForm::new(&query_plan).expect("query_nf"); | ||
|
|
||
| // qualifier for rewrite_from and a source created from the provider | ||
| let qualifier = TableReference::bare("mv"); | ||
| let source = provider_as_source(Arc::clone(&provider)); | ||
|
|
||
| // Benchmark rewrite_from (this is the heavy check) | ||
| let id_rewrite = BenchmarkId::new("rewrite_from", format!("cols={}", ncols)); | ||
| group.bench_with_input(id_rewrite, &ncols, |b, &_n| { | ||
| b.iter(|| { | ||
| let _res = query_nf.rewrite_from(&base_nf, qualifier.clone(), Arc::clone(&source)); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| group.finish(); | ||
| } | ||
|
|
||
| criterion_group!(benches, criterion_benchmark); | ||
| criterion_main!(benches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ allow = [ | |
| "BSD-3-Clause", | ||
| "CC0-1.0", | ||
| "Unicode-3.0", | ||
| "Zlib" | ||
| "Zlib", | ||
| "ISC", | ||
| "bzip2-1.0.6" | ||
| ] | ||
| version = 2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| [toolchain] | ||
| channel = "1.91.0" | ||
| components = ["rust-analyzer", "rustfmt", "clippy"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to put the file in the repo?