Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(query): re enable bendpy #15953

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .github/actions/build_bindings_python/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ runs:
shell: bash
run: |
if [[ -z "${{ inputs.version }}" ]]; then
echo "BUILD_ARGS=--strip --out dist" >> $GITHUB_OUTPUT
echo "BUILD_ARGS=--features abi --strip --out dist" >> $GITHUB_OUTPUT
else
echo "BUILD_ARGS=--release --strip --out dist" >> $GITHUB_OUTPUT
echo "BUILD_ARGS=--features abi --release --strip --out dist" >> $GITHUB_OUTPUT
fi

- name: Cross setup for macOS
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/bindings.python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ name: Bindings Python
on:
## uncomment it when bendpy is enabled
workflow_dispatch:
# pull_request:
# branches:
# - main
# paths:
# - "src/**"
# - ".github/workflows/bindings.python.yml"
# workflow_call:
# inputs:
# tag:
# description: Tag to release
# required: true
# type: string
pull_request:
branches:
- main
paths:
- "src/**"
- ".github/workflows/bindings.python.yml"
workflow_call:
inputs:
tag:
description: Tag to release
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
Expand Down
60 changes: 52 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ members = [
"src/common/license",
"src/common/parquet2",
"src/query/ast",
"src/bendpy",
"src/query/async_functions",
"src/query/codegen",
"src/query/config",
Expand Down
8 changes: 6 additions & 2 deletions src/bendpy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pyo3-build-config = "0.18.3"
name = "databend"
crate-type = ["cdylib"]

[features]
default = []
abi = ["pyo3/extension-module", "pyo3/abi3", "pyo3/abi3-py37"]

[dependencies]
arrow = { workspace = true, features = ["pyarrow"] }
arrow-schema = { workspace = true }
Expand All @@ -28,8 +32,8 @@ databend-common-users = { workspace = true }
databend-query = { workspace = true, features = [
"simd",
"disable_initial_exec_tls",
], default-features = false }
pyo3 = { version = "0.20", features = ["extension-module", "abi3", "abi3-py37"] }
] }
pyo3 = { version = "0.21.2" }
tokio = { workspace = true, features = ["macros", "rt", "rt-multi-thread", "sync"] }
tokio-stream = { workspace = true }
uuid = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions src/bendpy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ pip install "maturin[patchelf]"
Build bindings:

```shell
maturin develop
maturin develop --features abi
```

Run tests:

```shell
maturin develop -E test
maturin develop --features abi -E test
```

Build API docs:

```shell
maturin develop -E docs
maturin develop --features abi -E docs
pdoc databend
```

Expand Down
10 changes: 5 additions & 5 deletions src/bendpy/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl PyDataFrame {
let result = blocks.box_render(num, bs.bs_max_width, bs.bs_max_width);

// Note that println! does not print to the Python debug console and is not visible in notebooks for instance
let print = py.import("builtins")?.getattr("print")?;
let print = py.import_bound("builtins")?.getattr("print")?;
print.call1((result,))?;
Ok(())
}
Expand Down Expand Up @@ -146,8 +146,8 @@ impl PyDataFrame {

Python::with_gil(|py| {
// Instantiate pyarrow Table object and use its from_batches method
let table_class = py.import("pyarrow")?.getattr("Table")?;
let args = PyTuple::new(py, &[batches, schema]);
let table_class = py.import_bound("pyarrow")?.getattr("Table")?;
let args = PyTuple::new_bound(py, &[batches, schema]);
let table: PyObject = table_class.call_method1("from_batches", args)?.into();
Ok(table)
})
Expand All @@ -171,8 +171,8 @@ impl PyDataFrame {
let table = self.to_arrow_table(py)?;

Python::with_gil(|py| {
let dataframe = py.import("polars")?.getattr("DataFrame")?;
let args = PyTuple::new(py, &[table]);
let dataframe = py.import_bound("polars")?.getattr("DataFrame")?;
let args = PyTuple::new_bound(py, &[table]);
let result: PyObject = dataframe.call1(args)?.into();
Ok(result)
})
Expand Down
2 changes: 1 addition & 1 deletion src/bendpy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use utils::RUNTIME;

/// A Python module implemented in Rust.
#[pymodule]
fn databend(_py: Python, m: &PyModule) -> PyResult<()> {
fn databend(m: &Bound<'_, PyModule>) -> PyResult<()> {
let data_path = env::var("DATABEND_DATA_PATH").unwrap_or(".databend/".to_string());
let path = Path::new(&data_path);

Expand Down
Loading