Skip to content

Commit ceeff70

Browse files
committed
Lists
Signed-off-by: Nicholas Gates <[email protected]>
2 parents 19616b3 + c93b6a7 commit ceeff70

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

vortex-array/src/arrays/dict/vtable/rules.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::arrays::FilterArray;
1717
use crate::arrays::FilterVTable;
1818
use crate::arrays::ScalarFnArray;
1919
use crate::builtins::ArrayBuiltins;
20+
use crate::expr::Pack;
2021
use crate::matchers::Exact;
2122
use crate::optimizer::ArrayOptimizer;
2223
use crate::optimizer::rules::ArrayParentReduceRule;
@@ -71,6 +72,12 @@ impl ArrayParentReduceRule<DictVTable> for DictionaryScalarFnValuesPushDownRule
7172
// Check that the scalar function can actually be pushed down.
7273
let sig = parent.scalar_fn().signature();
7374

75+
// Don't push down pack expressions since we might want to unpack them in exporters
76+
// later.
77+
if parent.scalar_fn().is::<Pack>() {
78+
return Ok(None);
79+
}
80+
7481
// If the scalar function is fallible, we cannot push it down since it may fail over a
7582
// value that isn't referenced by any code.
7683
if !array.all_values_referenced && sig.is_fallible() {

vortex-duckdb/src/scan.rs

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ use vortex::error::vortex_bail;
4040
use vortex::error::vortex_err;
4141
use vortex::expr::Expression;
4242
use vortex::expr::Pack;
43-
use vortex::expr::and;
4443
use vortex::expr::and_collect;
4544
use vortex::expr::col;
46-
use vortex::expr::lit;
4745
use vortex::expr::root;
4846
use vortex::expr::select;
4947
use vortex::file::OpenOptionsSessionExt;
@@ -53,6 +51,7 @@ use vortex::io::runtime::BlockingRuntime;
5351
use vortex::io::runtime::current::ThreadSafeIterator;
5452
use vortex::layout::layouts::USE_VORTEX_OPERATORS;
5553
use vortex::session::VortexSession;
54+
use vortex_utils::aliases::hash_set::HashSet;
5655

5756
use crate::RUNTIME;
5857
use crate::SESSION;
@@ -179,38 +178,32 @@ fn extract_table_filter_expr(
179178
init: &TableInitInput<VortexTableFunction>,
180179
column_ids: &[u64],
181180
) -> VortexResult<Option<Expression>> {
182-
let table_filter_expr = init
183-
.table_filter_set()
184-
.and_then(|filter| {
185-
filter
186-
.into_iter()
187-
.map(|(idx, ex)| {
188-
let idx_u: usize = idx.as_();
189-
let col_idx: usize = column_ids[idx_u].as_();
190-
let name = init
191-
.bind_data()
192-
.column_names
193-
.get(col_idx)
194-
.vortex_expect("exists");
195-
try_from_table_filter(
196-
&ex,
197-
&col(name.as_str()),
198-
init.bind_data().first_file.dtype(),
199-
)
200-
})
201-
.reduce(|l, r| l?.zip(r?).map(|(l, r)| Ok(and(l, r))).transpose())
202-
})
203-
.transpose()?
204-
.flatten();
205-
206-
let complex_filter_expr = and_collect(init.bind_data().filter_exprs.clone());
207-
let filter_expr = complex_filter_expr
208-
.into_iter()
209-
.chain(table_filter_expr)
210-
.reduce(and)
211-
.unwrap_or_else(|| lit(true));
181+
let mut table_filter_exprs: HashSet<Expression> = if let Some(filter) = init.table_filter_set()
182+
{
183+
filter
184+
.into_iter()
185+
.map(|(idx, ex)| {
186+
let idx_u: usize = idx.as_();
187+
let col_idx: usize = column_ids[idx_u].as_();
188+
let name = init
189+
.bind_data()
190+
.column_names
191+
.get(col_idx)
192+
.vortex_expect("exists");
193+
try_from_table_filter(
194+
&ex,
195+
&col(name.as_str()),
196+
init.bind_data().first_file.dtype(),
197+
)
198+
})
199+
.collect::<VortexResult<Option<HashSet<_>>>>()?
200+
.unwrap_or_else(HashSet::new)
201+
} else {
202+
HashSet::new()
203+
};
212204

213-
Ok(Some(filter_expr))
205+
table_filter_exprs.extend(init.bind_data().filter_exprs.clone());
206+
Ok(and_collect(table_filter_exprs.into_iter().collect_vec()))
214207
}
215208

216209
/// Helper function to open a Vortex file from either a local or S3 URL

0 commit comments

Comments
 (0)