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
19 changes: 15 additions & 4 deletions src/mysql_filter_pushdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ namespace duckdb {
string MySQLFilterPushdown::CreateExpression(string &column_name, vector<unique_ptr<TableFilter>> &filters, string op) {
vector<string> filter_entries;
for (auto &filter : filters) {
filter_entries.push_back(TransformFilter(column_name, *filter));
auto new_filter = TransformFilter(column_name, *filter);
if (new_filter.empty()) {
continue;
}
filter_entries.push_back(std::move(new_filter));
}
if (filter_entries.empty()) {
return string();
}
return "(" + StringUtil::Join(filter_entries, " " + op + " ") + ")";
}
Expand Down Expand Up @@ -109,12 +116,16 @@ string MySQLFilterPushdown::TransformFilters(const vector<column_t> &column_ids,
}
string result;
for (auto &entry : filters->filters) {
auto column_name = MySQLUtils::WriteIdentifier(names[column_ids[entry.first]]);
auto &filter = *entry.second;
auto new_filter = TransformFilter(column_name, filter);
if (new_filter.empty()) {
continue;
}
if (!result.empty()) {
result += " AND ";
}
auto column_name = MySQLUtils::WriteIdentifier(names[column_ids[entry.first]]);
auto &filter = *entry.second;
result += TransformFilter(column_name, filter);
result += new_filter;
}
return result;
}
Expand Down
14 changes: 14 additions & 0 deletions test/sql/attach_filter_pushdown.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ SELECT * FROM s1.filter_pushdown_string WHERE i='52525'
----
52525

query I
select * from s1.filter_pushdown_string where i > '10' order by i limit 10
----
100
1000
10000
10001
10002
10003
10004
10005
10006
10007

# timestamp pushdown
query I
SELECT COUNT(*) FROM s1.datetime_tbl WHERE d >= DATE '2000-01-01'
Expand Down
Loading