Skip to content

Commit

Permalink
Set public as the default database for the catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs committed Nov 2, 2021
1 parent b804772 commit 35ad333
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions python/datafusion/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def test_basic(ctx, database):
default = ctx.catalog()
assert default.names() == ["public"]

database = default.database("public")
assert database.names() == {"csv1", "csv", "csv2"}
for database in [default.database("public"), default.database()]:
assert database.names() == {"csv1", "csv", "csv2"}

table = database.table("csv")
assert table.kind == "physical"
Expand Down
7 changes: 4 additions & 3 deletions python/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ use datafusion::{
datasource::{TableProvider, TableType},
};

#[pyclass(name = "Catalog", subclass)]
#[pyclass(name = "Catalog", module = "datafusion", subclass)]
pub(crate) struct PyCatalog {
catalog: Arc<dyn CatalogProvider>,
}

#[pyclass(name = "Database", subclass)]
#[pyclass(name = "Database", module = "datafusion", subclass)]
pub(crate) struct PyDatabase {
database: Arc<dyn SchemaProvider>,
}

#[pyclass(name = "Table", subclass)]
#[pyclass(name = "Table", module = "datafusion", subclass)]
pub(crate) struct PyTable {
table: Arc<dyn TableProvider>,
}
Expand Down Expand Up @@ -66,6 +66,7 @@ impl PyCatalog {
self.catalog.schema_names()
}

#[args(name = "\"public\"")]
fn database(&self, name: &str) -> PyResult<PyDatabase> {
match self.catalog.schema(name) {
Some(database) => Ok(PyDatabase::new(database)),
Expand Down
6 changes: 2 additions & 4 deletions python/src/udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use datafusion::arrow::datatypes::DataType;
use datafusion::arrow::pyarrow::PyArrowConvert;
use datafusion::error::{DataFusionError, Result};
use datafusion::logical_plan;
use datafusion::physical_plan::aggregates::AccumulatorFunctionImplementation;
use datafusion::physical_plan::udaf::AggregateUDF;
use datafusion::physical_plan::Accumulator;
use datafusion::physical_plan::aggregates::AccumulatorFunctionImplementation;
use datafusion::scalar::ScalarValue;

use crate::expression::PyExpr;
Expand Down Expand Up @@ -103,9 +103,7 @@ impl Accumulator for RustAccumulator {
}
}

pub fn to_rust_accumulator(
accum: PyObject,
) -> AccumulatorFunctionImplementation {
pub fn to_rust_accumulator(accum: PyObject) -> AccumulatorFunctionImplementation {
Arc::new(move || -> Result<Box<dyn Accumulator>> {
let accum = Python::with_gil(|py| {
accum
Expand Down

0 comments on commit 35ad333

Please sign in to comment.