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

[Python] Allow some config options to be set when creating context #204

Merged
merged 1 commit into from
Sep 13, 2022
Merged
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
10 changes: 9 additions & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import pyarrow
f = ballista.functions

# create a context
ctx = ballista.SessionContext()
ctx = ballista.BallistaContext("localhost", 50050)

# create a RecordBatch and a new DataFrame from it
batch = pyarrow.RecordBatch.from_arrays(
Expand All @@ -65,6 +65,14 @@ assert result.column(0) == pyarrow.array([5, 7, 9])
assert result.column(1) == pyarrow.array([-3, -3, -3])
```

### Specifying Configuration Options

Configuration settings can be specified when creating the context.

```python
ctx = ballista.BallistaContext("localhost", 50050, shuffle_partitions = 200, batch_size = 16384)
```

### UDFs

```python
Expand Down
16 changes: 13 additions & 3 deletions python/src/ballista_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ pub(crate) struct PyBallistaContext {
#[pymethods]
impl PyBallistaContext {
#[new]
#[args(port = "50050")]
fn new(py: Python, host: &str, port: u16) -> PyResult<Self> {
#[args(port = "50050", shuffle_partitions = 4, batch_size = 8192)]
fn new(
py: Python,
host: &str,
port: u16,
shuffle_partitions: usize,
batch_size: usize,
) -> PyResult<Self> {
let config = BallistaConfig::builder()
.set("ballista.shuffle.partitions", "4")
.set(
"ballista.shuffle.partitions",
&format!("{}", shuffle_partitions),
)
.set("ballista.batch.size", &format!("{}", batch_size))
.set("ballista.with_information_schema", "true")
.build()
.map_err(BallistaError::from)?;
Expand Down