Skip to content

Commit 7ff0551

Browse files
committed
Merge branch 'main' into feat/add-missing-array-fns
2 parents db91638 + ff15648 commit 7ff0551

File tree

6 files changed

+614
-53
lines changed

6 files changed

+614
-53
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ jobs:
159159
with:
160160
enable-cache: true
161161

162+
- name: Add extra swap for release build
163+
if: inputs.build_mode == 'release'
164+
run: |
165+
set -euxo pipefail
166+
sudo swapoff -a || true
167+
sudo rm -f /swapfile
168+
sudo fallocate -l 8G /swapfile || sudo dd if=/dev/zero of=/swapfile bs=1M count=8192
169+
sudo chmod 600 /swapfile
170+
sudo mkswap /swapfile
171+
sudo swapon /swapfile
172+
free -h
173+
swapon --show
174+
162175
- name: Build (release mode)
163176
uses: PyO3/maturin-action@v1
164177
if: inputs.build_mode == 'release'
@@ -233,7 +246,7 @@ jobs:
233246
set -euxo pipefail
234247
sudo swapoff -a || true
235248
sudo rm -f /swapfile
236-
sudo fallocate -l 16G /swapfile || sudo dd if=/dev/zero of=/swapfile bs=1M count=16384
249+
sudo fallocate -l 8G /swapfile || sudo dd if=/dev/zero of=/swapfile bs=1M count=8192
237250
sudo chmod 600 /swapfile
238251
sudo mkswap /swapfile
239252
sudo swapon /swapfile

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ pyo3-build-config = "0.28"
6464
datafusion-python-util = { path = "crates/util" }
6565

6666
[profile.release]
67-
lto = true
68-
codegen-units = 1
67+
lto = "thin"
68+
codegen-units = 2
6969

7070
# We cannot publish to crates.io with any patches in the below section. Developers
7171
# must remove any entries in this section before creating a release candidate.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ needing to activate the virtual environment:
275275

276276
```bash
277277
uv run --no-project maturin develop --uv
278-
uv run --no-project pytest .
278+
uv run --no-project pytest
279279
```
280280

281281
To run the FFI tests within the examples folder, after you have built

crates/core/src/functions.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ fn gen_series(start: PyExpr, stop: PyExpr, step: Option<PyExpr>) -> PyExpr {
137137
.into()
138138
}
139139

140+
#[pyfunction]
141+
fn make_map(keys: Vec<PyExpr>, values: Vec<PyExpr>) -> PyExpr {
142+
let keys = keys.into_iter().map(|x| x.into()).collect();
143+
let values = values.into_iter().map(|x| x.into()).collect();
144+
datafusion::functions_nested::map::map(keys, values).into()
145+
}
146+
140147
#[pyfunction]
141148
#[pyo3(signature = (array, element, index=None))]
142149
fn array_position(array: PyExpr, element: PyExpr, index: Option<i64>) -> PyExpr {
@@ -538,6 +545,8 @@ expr_fn!(length, string);
538545
expr_fn!(char_length, string);
539546
expr_fn!(chr, arg, "Returns the character with the given code.");
540547
expr_fn_vec!(coalesce);
548+
expr_fn_vec!(greatest);
549+
expr_fn_vec!(least);
541550
expr_fn!(
542551
contains,
543552
string search_str,
@@ -592,6 +601,11 @@ expr_fn!(
592601
x y,
593602
"Returns x if x is not NULL otherwise returns y."
594603
);
604+
expr_fn!(
605+
nvl2,
606+
x y z,
607+
"Returns y if x is not NULL; otherwise returns z."
608+
);
595609
expr_fn!(nullif, arg_1 arg_2);
596610
expr_fn!(
597611
octet_length,
@@ -719,6 +733,12 @@ array_fn!(cardinality, array);
719733
array_fn!(flatten, array);
720734
array_fn!(range, start stop step);
721735

736+
// Map Functions
737+
array_fn!(map_keys, map);
738+
array_fn!(map_values, map);
739+
array_fn!(map_extract, map key);
740+
array_fn!(map_entries, map);
741+
722742
aggregate_function!(array_agg);
723743
aggregate_function!(max);
724744
aggregate_function!(min);
@@ -1037,13 +1057,15 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
10371057
m.add_wrapped(wrap_pyfunction!(floor))?;
10381058
m.add_wrapped(wrap_pyfunction!(from_unixtime))?;
10391059
m.add_wrapped(wrap_pyfunction!(gcd))?;
1060+
m.add_wrapped(wrap_pyfunction!(greatest))?;
10401061
// m.add_wrapped(wrap_pyfunction!(grouping))?;
10411062
m.add_wrapped(wrap_pyfunction!(in_list))?;
10421063
m.add_wrapped(wrap_pyfunction!(initcap))?;
10431064
m.add_wrapped(wrap_pyfunction!(isnan))?;
10441065
m.add_wrapped(wrap_pyfunction!(iszero))?;
10451066
m.add_wrapped(wrap_pyfunction!(levenshtein))?;
10461067
m.add_wrapped(wrap_pyfunction!(lcm))?;
1068+
m.add_wrapped(wrap_pyfunction!(least))?;
10471069
m.add_wrapped(wrap_pyfunction!(left))?;
10481070
m.add_wrapped(wrap_pyfunction!(length))?;
10491071
m.add_wrapped(wrap_pyfunction!(ln))?;
@@ -1061,6 +1083,7 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
10611083
m.add_wrapped(wrap_pyfunction!(named_struct))?;
10621084
m.add_wrapped(wrap_pyfunction!(nanvl))?;
10631085
m.add_wrapped(wrap_pyfunction!(nvl))?;
1086+
m.add_wrapped(wrap_pyfunction!(nvl2))?;
10641087
m.add_wrapped(wrap_pyfunction!(now))?;
10651088
m.add_wrapped(wrap_pyfunction!(nullif))?;
10661089
m.add_wrapped(wrap_pyfunction!(octet_length))?;
@@ -1188,6 +1211,13 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
11881211
m.add_wrapped(wrap_pyfunction!(flatten))?;
11891212
m.add_wrapped(wrap_pyfunction!(cardinality))?;
11901213

1214+
// Map Functions
1215+
m.add_wrapped(wrap_pyfunction!(make_map))?;
1216+
m.add_wrapped(wrap_pyfunction!(map_keys))?;
1217+
m.add_wrapped(wrap_pyfunction!(map_values))?;
1218+
m.add_wrapped(wrap_pyfunction!(map_extract))?;
1219+
m.add_wrapped(wrap_pyfunction!(map_entries))?;
1220+
11911221
// Window Functions
11921222
m.add_wrapped(wrap_pyfunction!(lead))?;
11931223
m.add_wrapped(wrap_pyfunction!(lag))?;

0 commit comments

Comments
 (0)