Skip to content

Commit 620d84c

Browse files
committed
main fixes
1 parent b365cb9 commit 620d84c

3 files changed

Lines changed: 3 additions & 83 deletions

File tree

src/duckdb_py/arrow/filter_pushdown_visitor.cpp

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -159,87 +159,6 @@ py::object TransformExpression(const Expression &expression, const vector<string
159159
py::object TransformFilter(const TableFilter &filter, vector<string> column_path, FilterBackend &backend,
160160
const ArrowType *arrow_type, const string &timezone_config) {
161161
switch (filter.filter_type) {
162-
case TableFilterType::CONSTANT_COMPARISON: {
163-
auto &constant_filter = filter.Cast<ConstantFilter>();
164-
auto col = backend.MakeColumnRef(column_path);
165-
return EmitCompare(backend, constant_filter.comparison_type, std::move(col), constant_filter.constant,
166-
arrow_type, timezone_config);
167-
}
168-
case TableFilterType::IS_NULL: {
169-
auto col = backend.MakeColumnRef(column_path);
170-
return backend.IsNull(std::move(col));
171-
}
172-
case TableFilterType::IS_NOT_NULL: {
173-
auto col = backend.MakeColumnRef(column_path);
174-
return backend.IsNotNull(std::move(col));
175-
}
176-
case TableFilterType::CONJUNCTION_AND: {
177-
auto &and_filter = filter.Cast<ConjunctionAndFilter>();
178-
py::object result = py::none();
179-
for (idx_t i = 0; i < and_filter.child_filters.size(); i++) {
180-
py::object child_expression =
181-
TransformFilter(*and_filter.child_filters[i], column_path, backend, arrow_type, timezone_config);
182-
if (child_expression.is(py::none())) {
183-
continue;
184-
}
185-
if (result.is(py::none())) {
186-
result = std::move(child_expression);
187-
} else {
188-
result = backend.And(std::move(result), std::move(child_expression));
189-
}
190-
}
191-
return result;
192-
}
193-
case TableFilterType::CONJUNCTION_OR: {
194-
auto &or_filter = filter.Cast<ConjunctionOrFilter>();
195-
py::object result = py::none();
196-
for (idx_t i = 0; i < or_filter.child_filters.size(); i++) {
197-
py::object child_expression =
198-
TransformFilter(*or_filter.child_filters[i], column_path, backend, arrow_type, timezone_config);
199-
if (child_expression.is(py::none())) {
200-
continue;
201-
}
202-
if (result.is(py::none())) {
203-
result = std::move(child_expression);
204-
} else {
205-
result = backend.Or(std::move(result), std::move(child_expression));
206-
}
207-
}
208-
return result;
209-
}
210-
case TableFilterType::STRUCT_EXTRACT: {
211-
auto &struct_filter = filter.Cast<StructFilter>();
212-
column_path.push_back(struct_filter.child_name);
213-
const ArrowType *child_type = nullptr;
214-
if (arrow_type) {
215-
child_type = &arrow_type->GetTypeInfo<ArrowStructInfo>().GetChild(struct_filter.child_idx);
216-
}
217-
return TransformFilter(*struct_filter.child_filter, std::move(column_path), backend, child_type,
218-
timezone_config);
219-
}
220-
case TableFilterType::OPTIONAL_FILTER: {
221-
auto &optional_filter = filter.Cast<OptionalFilter>();
222-
if (!optional_filter.child_filter) {
223-
return py::none();
224-
}
225-
try {
226-
return TransformFilter(*optional_filter.child_filter, column_path, backend, arrow_type, timezone_config);
227-
} catch (const NotImplementedException &) {
228-
return py::none();
229-
}
230-
}
231-
case TableFilterType::IN_FILTER: {
232-
auto &in_filter = filter.Cast<InFilter>();
233-
auto col = backend.MakeColumnRef(column_path);
234-
// The column's logical type for IN comes from the values themselves
235-
// (they share the comparison type). Empty IN lists are not produced
236-
// by the optimizer so we can safely index values[0].
237-
LogicalType col_logical_type =
238-
in_filter.values.empty() ? LogicalType::SQLNULL : in_filter.values.front().type();
239-
return backend.IsIn(std::move(col), in_filter.values, col_logical_type, timezone_config);
240-
}
241-
case TableFilterType::DYNAMIC_FILTER:
242-
return py::none();
243162
case TableFilterType::EXPRESSION_FILTER: {
244163
auto &expression_filter = filter.Cast<ExpressionFilter>();
245164
return TransformExpression(*expression_filter.expr, column_path, backend, arrow_type, timezone_config);

src/duckdb_py/pyconnection.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,8 @@ void DuckDBPyConnection::InstallExtension(const string &extension, bool force_in
19371937

19381938
void DuckDBPyConnection::LoadExtension(const string &extension) {
19391939
auto &connection = con.GetConnection();
1940-
ExtensionHelper::LoadExternalExtension(*connection.context, extension);
1940+
const ExtensionLoadOptions extension_opts = {extension};
1941+
ExtensionHelper::LoadExternalExtension(*connection.context, extension_opts);
19411942
}
19421943

19431944
shared_ptr<DuckDBPyConnection> DefaultConnectionHolder::Get() {

tests/fast/arrow/test_polars_filter_pushdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def test_no_crash_correct_result(self, factory):
513513
("price", 100),
514514
]
515515

516-
def test_top_n_nulls_first_includes_min(self):
516+
def test_top_n_nulls_first_includes_min(self, factory):
517517
"""ORDER BY x ASC NULLS FIRST LIMIT 1 pushes OPTIONAL(IS_NULL OR DYNAMIC_FILTER) into the scan.
518518
519519
The OR branch must not be partially translated: dropping the

0 commit comments

Comments
 (0)