Skip to content

Remote table WHERE clause pushdown#226

Merged
gruuya merged 13 commits intomainfrom
remote-table-where-pushdown
Dec 1, 2022
Merged

Remote table WHERE clause pushdown#226
gruuya merged 13 commits intomainfrom
remote-table-where-pushdown

Conversation

@gruuya
Copy link
Copy Markdown
Contributor

@gruuya gruuya commented Nov 28, 2022

Implement a FDW-like mechanism to enable pushdown of filter qualifiers to a remote data source as an optimization to skip redundant row fetching over the network.

The mechanism is based on the DataFusion ExpressionVisitor, which allows us to walk the filter expression AST, and determine if all entities are ship-able, and if so convert them if needed to the source native form. The conversion and the entire ship-ability logic is customizable.

Closes #224.

Supports generics over the source type, so that one can override/customize the pushdown logic for operators, scalar values, etc.
@gruuya gruuya requested a review from mildbyte November 28, 2022 12:53
Comment thread src/remote_tables/provider.rs Outdated
Comment thread src/remote_tables/provider.rs Outdated
Comment thread src/remote_tables/pushdown_visitor.rs Outdated
Comment thread src/remote_tables/pushdown_visitor.rs
Comment thread src/remote_tables/pushdown_visitor.rs Outdated
Comment thread src/remote_tables/pushdown_visitor.rs
#[case::complex_binary_expression(
or(and(or(col("a").eq(lit(1)), col("b").gt(lit(10))), col("c").lt_eq(lit(15.0))), col("d").not_eq(lit("some_string"))),
"(a = 1 OR b > 10) AND c <= 15 OR d != 'some_string'")
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a couple of tests here for:

  • strings with single quotes in them
  • timestamps
  • column names with spaces getting quoted properly

(they won't be integration tests but we'll be able to have some cases for them being escaped / serialized correctly)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests added now.

Comment thread src/remote_tables/pushdown_visitor.rs
Comment thread src/remote_tables/pushdown_visitor.rs
@mildbyte
Copy link
Copy Markdown
Contributor

Thanks! :)

Comment thread src/remote_tables/provider.rs Outdated
SourceType::MySQL => filter_expr_to_sql(filter, MySQLFilterPushdown {}),
_ => {
debug!(
"Filter not shipable due to unsupported source type {:?}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Filter not shipable due to unsupported source type {:?}",
"Filter not shippable due to unsupported source type {:?}",

Comment thread src/remote_tables/pushdown_visitor.rs
@gruuya gruuya merged commit d095fb5 into main Dec 1, 2022
@gruuya gruuya deleted the remote-table-where-pushdown branch December 1, 2022 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter pushdown in remote tables

2 participants