Skip to content

Commit 31fdc0f

Browse files
committed
Add once_cell dependency and refactor Arrow array stream capsule name handling
1 parent f4b4ed3 commit 31fdc0f

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,34 @@ readme = "README.md"
2626
license = "Apache-2.0"
2727
edition = "2021"
2828
rust-version = "1.78"
29-
include = ["/src", "/datafusion", "/LICENSE.txt", "build.rs", "pyproject.toml", "Cargo.toml", "Cargo.lock"]
29+
include = [
30+
"/src",
31+
"/datafusion",
32+
"/LICENSE.txt",
33+
"build.rs",
34+
"pyproject.toml",
35+
"Cargo.toml",
36+
"Cargo.lock",
37+
]
3038

3139
[features]
3240
default = ["mimalloc"]
33-
protoc = [ "datafusion-substrait/protoc" ]
41+
protoc = ["datafusion-substrait/protoc"]
3442
substrait = ["dep:datafusion-substrait"]
3543

3644
[dependencies]
37-
tokio = { version = "1.45", features = ["macros", "rt", "rt-multi-thread", "sync"] }
38-
pyo3 = { version = "0.24", features = ["extension-module", "abi3", "abi3-py39"] }
39-
pyo3-async-runtimes = { version = "0.24", features = ["tokio-runtime"]}
45+
tokio = { version = "1.45", features = [
46+
"macros",
47+
"rt",
48+
"rt-multi-thread",
49+
"sync",
50+
] }
51+
pyo3 = { version = "0.24", features = [
52+
"extension-module",
53+
"abi3",
54+
"abi3-py39",
55+
] }
56+
pyo3-async-runtimes = { version = "0.24", features = ["tokio-runtime"] }
4057
pyo3-log = "0.12.4"
4158
arrow = { version = "55.1.0", features = ["pyarrow"] }
4259
datafusion = { version = "49.0.2", features = ["avro", "unicode_expressions"] }
@@ -45,15 +62,23 @@ datafusion-proto = { version = "49.0.2" }
4562
datafusion-ffi = { version = "49.0.2" }
4663
prost = "0.13.1" # keep in line with `datafusion-substrait`
4764
uuid = { version = "1.18", features = ["v4"] }
48-
mimalloc = { version = "0.1", optional = true, default-features = false, features = ["local_dynamic_tls"] }
65+
mimalloc = { version = "0.1", optional = true, default-features = false, features = [
66+
"local_dynamic_tls",
67+
] }
4968
async-trait = "0.1.89"
69+
once_cell = "1.18"
5070
futures = "0.3"
51-
object_store = { version = "0.12.3", features = ["aws", "gcp", "azure", "http"] }
71+
object_store = { version = "0.12.3", features = [
72+
"aws",
73+
"gcp",
74+
"azure",
75+
"http",
76+
] }
5277
url = "2"
5378
log = "0.4.27"
5479

5580
[build-dependencies]
56-
prost-types = "0.13.1" # keep in line with `datafusion-substrait`
81+
prost-types = "0.13.1" # keep in line with `datafusion-substrait`
5782
pyo3-build-config = "0.24"
5883

5984
[lib]

src/dataframe.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use once_cell::sync::Lazy;
1819
use std::collections::HashMap;
1920
use std::ffi::CString;
2021
use std::sync::Arc;
@@ -59,6 +60,10 @@ use crate::{
5960
expr::{sort_expr::PySortExpr, PyExpr},
6061
};
6162

63+
/// File-level static CString for the Arrow array stream capsule name.
64+
static ARROW_ARRAY_STREAM_NAME: Lazy<CString> =
65+
Lazy::new(|| CString::new("arrow_array_stream").unwrap());
66+
6267
// https://github.com/apache/datafusion-python/pull/1016#discussion_r1983239116
6368
// - we have not decided on the table_provider approach yet
6469
// this is an interim implementation
@@ -967,8 +972,7 @@ impl PyDataFrame {
967972
// destructor provided by PyO3 will drop the stream unless ownership is
968973
// transferred to PyArrow during import.
969974
let stream = FFI_ArrowArrayStream::new(reader);
970-
let name = CString::new("arrow_array_stream").unwrap();
971-
let capsule = PyCapsule::new(py, stream, Some(name))?;
975+
let capsule = PyCapsule::new(py, stream, Some(ARROW_ARRAY_STREAM_NAME.clone()))?;
972976
Ok(capsule)
973977
}
974978

0 commit comments

Comments
 (0)