-
Notifications
You must be signed in to change notification settings - Fork 199
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: Update python files #1141
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# %% | ||
|
||
from ballista import BallistaBuilder | ||
from datafusion.context import SessionContext | ||
|
||
ctx: SessionContext = BallistaBuilder()\ | ||
.config("ballista.job.name", "Readme Examples")\ | ||
.config("datafusion.execution.target_partitions", "4")\ | ||
.standalone() | ||
ctx.sql("create external table t stored as parquet location '../testdata/test.parquet'") | ||
|
||
# %% | ||
df = ctx.sql("select * from t limit 5") | ||
pyarrow_batches = df.collect() | ||
pyarrow_batches[0].to_pandas() | ||
# %% | ||
df = ctx.read_parquet('../testdata/test.parquet').limit(5) | ||
pyarrow_batches = df.collect() | ||
pyarrow_batches[0].to_pandas() | ||
# %% |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,15 @@ | |
# under the License. | ||
|
||
[build-system] | ||
requires = ["maturin>=0.15,<0.16"] | ||
requires = ["maturin>=1.5.1,<1.6.0"] | ||
build-backend = "maturin" | ||
|
||
[project] | ||
name = "ballista" | ||
description = "Python client for Apache Arrow Ballista Distributed SQL Query Engine" | ||
readme = "README.md" | ||
license = {file = "LICENSE.txt"} | ||
requires-python = ">=3.6" | ||
requires-python = ">=3.7" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would conclict with #1136 so I will change it really quick and repush my branch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated #1136 to require python 3.7 or greater There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Datafusion python has python > 3.7 |
||
keywords = ["ballista", "sql", "rust", "distributed"] | ||
classifier = [ | ||
"Development Status :: 2 - Pre-Alpha", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
datafusion==35.0.0 | ||
datafusion==42.0.0 | ||
maturin==1.5.1 | ||
pyarrow | ||
pytest |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,9 @@ use datafusion::execution::SessionStateBuilder; | |
use datafusion::prelude::*; | ||
use datafusion_python::context::PySessionContext; | ||
use datafusion_python::utils::wait_for_future; | ||
|
||
use std::collections::HashMap; | ||
|
||
use pyo3::prelude::*; | ||
use std::collections::HashMap; | ||
mod utils; | ||
use utils::to_pyerr; | ||
|
||
#[pymodule] | ||
fn ballista_internal(_py: Python, m: Bound<'_, PyModule>) -> PyResult<()> { | ||
|
@@ -66,7 +63,11 @@ impl PyBallistaBuilder { | |
/// Construct the standalone instance from the SessionContext | ||
pub fn standalone(&self, py: Python) -> PyResult<PySessionContext> { | ||
// Build the config | ||
let config: SessionConfig = SessionConfig::from_string_hash_map(&self.conf)?; | ||
let mut config: SessionConfig = SessionConfig::new_with_ballista(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you update something in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed nothing |
||
for (key, value) in &self.conf { | ||
let _ = config.options_mut().set(&key, value); | ||
} | ||
|
||
// Build the state | ||
let state = SessionStateBuilder::new() | ||
.with_config(config) | ||
|
@@ -85,7 +86,10 @@ impl PyBallistaBuilder { | |
/// Construct the remote instance from the SessionContext | ||
pub fn remote(&self, url: &str, py: Python) -> PyResult<PySessionContext> { | ||
// Build the config | ||
let config: SessionConfig = SessionConfig::from_string_hash_map(&self.conf)?; | ||
let mut config: SessionConfig = SessionConfig::new_with_ballista(); | ||
for (key, value) in &self.conf { | ||
let _ = config.options_mut().set(&key, value); | ||
} | ||
// Build the state | ||
let state = SessionStateBuilder::new() | ||
.with_config(config) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was initially used when awaiting the old BallistaContext. I think we could remove if needed. I left it in because I was unsure if we would need it again, but at this point I think we could just delete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know if we wanted to show an example of connecting to a remote instance, but it is covered in the other docs anyway, so good call removing.