Skip to content

Commit

Permalink
chore(rust): move polars-sql under polars folder (#5176)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 12, 2022
1 parent 67cfeac commit 5925c5c
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = [
"polars/polars-lazy",
"polars/polars-lazy/polars-plan",
"polars/polars-lazy/polars-pipe",
"polars-sql",
"polars/polars-sql",
"examples/read_csv",
"examples/read_parquet",
"examples/python_rust_compiled_function",
Expand Down
2 changes: 2 additions & 0 deletions polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository = "https://github.com/pola-rs/polars"
description = "DataFrame Library based on Apache Arrow"

[features]
sql = ["polars-sql"]
rows = ["polars-core/rows"]
simd = ["polars-core/simd"]
avx512 = ["polars-core/avx512"]
Expand Down Expand Up @@ -280,6 +281,7 @@ polars-core = { version = "0.24.3", path = "./polars-core", features = ["docs",
polars-io = { version = "0.24.3", path = "./polars-io", features = ["private"], default-features = false, optional = true }
polars-lazy = { version = "0.24.3", path = "./polars-lazy", features = ["private"], default-features = false, optional = true }
polars-ops = { version = "0.24.3", path = "./polars-ops" }
polars-sql = { version = "0.1.0", path = "./polars-sql", default-features = false, optional = true }
polars-time = { version = "0.24.3", path = "./polars-time", default-features = false, optional = true }

[dev-dependencies]
Expand Down
16 changes: 4 additions & 12 deletions polars-sql/Cargo.toml → polars/polars-sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,10 @@ binary = ["clap"]

[dependencies]
clap = { version = "3.2.22", features = ["derive"], optional = true }
polars-arrow = { path = "../polars/polars-arrow", features = ["like"] }
polars-lazy = { path = "../polars/polars-lazy", features = ["compile"] }
polars-plan = { path = "../polars/polars-lazy/polars-plan", features = ["compile"] }
polars-arrow = { path = "../polars-arrow", features = ["like"] }
polars-core = { path = "../polars-core", features = [] }
polars-lazy = { path = "../polars-lazy", features = ["compile", "strings", "cross_join"] }
polars-plan = { path = "../polars-lazy/polars-plan", features = ["compile"] }
serde = "1"
serde_json = { version = "1" }
sqlparser = { version = "0.19" }

[dependencies.polars]
path = "../polars"
default-features = false
features = [
"lazy",
"cross_join",
"strings",
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cell::RefCell;

use polars::error::PolarsResult;
use polars::prelude::*;
use polars_core::prelude::*;
use polars_lazy::prelude::*;
use polars_plan::prelude::*;
use polars_plan::utils::expressions_to_schema;
use sqlparser::ast::{
Expand Down
3 changes: 2 additions & 1 deletion polars-sql/src/lib.rs → polars/polars-sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ pub use context::SQLContext;

#[cfg(test)]
mod test {
use polars::prelude::*;
use polars_core::prelude::*;
use polars_lazy::prelude::*;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion polars-sql/src/main.rs → polars/polars-sql/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use polars::prelude::*;
use polars_core::prelude::*;

#[cfg(feature = "binary")]
mod binary {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use polars::error::PolarsError;
use polars::prelude::*;
use polars_core::prelude::*;
use polars_lazy::prelude::*;
use sqlparser::ast::{
BinaryOperator as SQLBinaryOperator, BinaryOperator, DataType as SQLDataType, Expr as SqlExpr,
Function as SQLFunction, JoinConstraint, TrimWhereField, Value as SqlValue, WindowSpec,
Expand Down
3 changes: 3 additions & 0 deletions polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
//! * `lazy` - Lazy API
//! - `lazy_regex` - Use regexes in [column selection](crate::lazy::dsl::col)
//! - `dot_diagram` - Create dot diagrams from lazy logical plans.
//! * `sql` - Pass SQL queries to polars.
//! * `random` - Generate arrays with randomly sampled values
//! * `ndarray`- Convert from `DataFrame` to `ndarray`
//! * `temporal` - Conversions between [Chrono](https://docs.rs/chrono/) and Polars for temporal data types
Expand Down Expand Up @@ -369,6 +370,8 @@
pub mod docs;
pub mod export;
pub mod prelude;
#[cfg(feature = "sql")]
pub mod sql;

pub use polars_core::{
apply_method_all_arrow_series, chunked_array, datatypes, df, doc, error, frame, functions,
Expand Down
1 change: 1 addition & 0 deletions polars/src/sql.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use polars_sql::SQLContext;
4 changes: 2 additions & 2 deletions py-polars/Cargo.lock

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

4 changes: 2 additions & 2 deletions py-polars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ numpy = "0.16"
once_cell = "1"
polars-core = { path = "../polars/polars-core", default-features = false }
polars-lazy = { path = "../polars/polars-lazy", features = ["python"], default-features = false }
polars-sql = { path = "../polars-sql", optional = true }
pyo3 = { version = "0.16", features = ["abi3-py37", "extension-module", "multiple-pymethods"] }
serde_json = { version = "1", optional = true }
thiserror = "^1.0"
Expand Down Expand Up @@ -60,6 +59,7 @@ extract_jsonpath = ["polars/extract_jsonpath"]
pivot = ["polars/pivot"]
top_k = ["polars/top_k"]
propagate_nans = ["polars/propagate_nans"]
sql = ["polars/sql"]

all = [
"json",
Expand Down Expand Up @@ -89,7 +89,7 @@ all = [
"polars/cse",
"propagate_nans",
"polars/groupby_list",
"polars-sql",
"sql",
"polars/dtype-binary",
]

Expand Down
4 changes: 2 additions & 2 deletions py-polars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod prelude;
pub(crate) mod py_modules;
pub mod series;
mod set;
#[cfg(feature = "polars-sql")]
#[cfg(feature = "sql")]
mod sql;
pub mod utils;

Expand Down Expand Up @@ -528,7 +528,7 @@ fn polars(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<PyLazyFrame>().unwrap();
m.add_class::<PyLazyGroupBy>().unwrap();
m.add_class::<dsl::PyExpr>().unwrap();
#[cfg(feature = "polars-sql")]
#[cfg(feature = "sql")]
m.add_class::<sql::PySQLContext>().unwrap();
m.add_wrapped(wrap_pyfunction!(col)).unwrap();
m.add_wrapped(wrap_pyfunction!(count)).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion py-polars/src/sql.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use polars_sql::SQLContext;
use polars::sql::SQLContext;
use pyo3::prelude::*;

use crate::{PyLazyFrame, PyPolarsErr};
Expand Down

0 comments on commit 5925c5c

Please sign in to comment.