Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
25e42c8
update dependencies
emgeee Sep 9, 2024
9cea1fb
update get_logical_plan signature
emgeee Sep 9, 2024
6fca28b
remove row_number() function
emgeee Sep 9, 2024
f2b3d3b
remove unneeded dependency
emgeee Sep 9, 2024
4b45a4b
fix pyo3 warnings
emgeee Sep 10, 2024
6353aa9
update object_store dependency
emgeee Sep 10, 2024
815b6d7
change PyExpr -> PySortExpr
emgeee Sep 10, 2024
92806a8
comment out key.extract::<&PyTuple>() condition statement
emgeee Sep 10, 2024
e2fa24e
change more instances of PyExpr > PySortExpr
emgeee Sep 10, 2024
21013a7
update function signatures to use _bound versions
emgeee Sep 10, 2024
142e4ed
remove clone
emgeee Sep 10, 2024
e971add
Working through some of the sort requirement changes
timsaucer Sep 10, 2024
c89357e
remove unused import
emgeee Sep 10, 2024
8255f09
expr.display_name is deprecated, used format!() + schema_name() instead
emgeee Sep 10, 2024
df46054
expr.canonical_name() is deprecated, use format!() expr instead
emgeee Sep 10, 2024
6c27614
remove comment
emgeee Sep 10, 2024
70546e2
fix tuple extraction in dataframe.__getitem__()
emgeee Sep 10, 2024
836061f
remove unneeded import
emgeee Sep 10, 2024
4945661
Add docstring comments to SortExpr python class
emgeee Sep 10, 2024
cd04c44
change extract() to downcast()
emgeee Sep 10, 2024
afcc9f1
deprecate Expr::display_name
Michael-J-Ward Aug 10, 2024
7f6187a
fix lint errors
emgeee Sep 10, 2024
8aebaea
update datafusion commit hash
emgeee Sep 11, 2024
afa303f
fix type in cargo file for arrow features
emgeee Sep 17, 2024
f4574ec
upgrade to datafusion 42
emgeee Sep 17, 2024
88ccbd8
cleanup
emgeee Sep 17, 2024
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
Prev Previous commit
Next Next commit
fix pyo3 warnings
Implicit defaults for trailing optional arguments have been deprecated
in pyo3 v0.22.0 PyO3/pyo3#4078
  • Loading branch information
emgeee committed Sep 10, 2024
commit 4b45a4b6365a1e61eb317623f07aaf0c1684b7b5
8 changes: 4 additions & 4 deletions src/common/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use pyo3::{exceptions::PyValueError, prelude::*};
use crate::errors::py_datafusion_err;

#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[pyclass(name = "RexType", module = "datafusion.common")]
#[pyclass(eq, eq_int, name = "RexType", module = "datafusion.common")]
pub enum RexType {
Alias,
Literal,
Expand Down Expand Up @@ -692,7 +692,7 @@ impl From<DataType> for PyDataType {

/// Represents the possible Python types that can be mapped to the SQL types
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[pyclass(name = "PythonType", module = "datafusion.common")]
#[pyclass(eq, eq_int, name = "PythonType", module = "datafusion.common")]
pub enum PythonType {
Array,
Bool,
Expand All @@ -712,7 +712,7 @@ pub enum PythonType {
#[allow(non_camel_case_types)]
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[pyclass(name = "SqlType", module = "datafusion.common")]
#[pyclass(eq, eq_int, name = "SqlType", module = "datafusion.common")]
pub enum SqlType {
ANY,
ARRAY,
Expand Down Expand Up @@ -770,7 +770,7 @@ pub enum SqlType {
#[allow(non_camel_case_types)]
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[pyclass(name = "NullTreatment", module = "datafusion.common")]
#[pyclass(eq, eq_int, name = "NullTreatment", module = "datafusion.common")]
pub enum NullTreatment {
IGNORE_NULLS,
RESPECT_NULLS,
Expand Down
1 change: 1 addition & 0 deletions src/common/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub struct SqlTable {
#[pymethods]
impl SqlTable {
#[new]
#[pyo3(signature = (table_name, columns, row_count, filepaths=None))]
pub fn new(
table_name: String,
columns: Vec<(String, DataTypeMap)>,
Expand Down
8 changes: 8 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ impl PySessionContext {
}

/// Register an object store with the given name
#[pyo3(signature = (scheme, store, host=None))]
pub fn register_object_store(
&mut self,
scheme: &str,
Expand Down Expand Up @@ -374,6 +375,7 @@ impl PySessionContext {
Ok(PyDataFrame::new(df))
}

#[pyo3(signature = (query, options=None))]
pub fn sql_with_options(
&mut self,
query: &str,
Expand All @@ -390,6 +392,7 @@ impl PySessionContext {
Ok(PyDataFrame::new(df))
}

#[pyo3(signature = (partitions, name=None, schema=None))]
pub fn create_dataframe(
&mut self,
partitions: PyArrowType<Vec<Vec<RecordBatch>>>,
Expand Down Expand Up @@ -433,6 +436,7 @@ impl PySessionContext {
}

/// Construct datafusion dataframe from Python list
#[pyo3(signature = (data, name=None))]
pub fn from_pylist(
&mut self,
data: Bound<'_, PyList>,
Expand All @@ -452,6 +456,7 @@ impl PySessionContext {
}

/// Construct datafusion dataframe from Python dictionary
#[pyo3(signature = (data, name=None))]
pub fn from_pydict(
&mut self,
data: Bound<'_, PyDict>,
Expand All @@ -471,6 +476,7 @@ impl PySessionContext {
}

/// Construct datafusion dataframe from Arrow Table
#[pyo3(signature = (data, name=None))]
pub fn from_arrow(
&mut self,
data: Bound<'_, PyAny>,
Expand Down Expand Up @@ -506,6 +512,7 @@ impl PySessionContext {

/// Construct datafusion dataframe from pandas
#[allow(clippy::wrong_self_convention)]
#[pyo3(signature = (data, name=None))]
pub fn from_pandas(
&mut self,
data: Bound<'_, PyAny>,
Expand All @@ -525,6 +532,7 @@ impl PySessionContext {
}

/// Construct datafusion dataframe from polars
#[pyo3(signature = (data, name=None))]
pub fn from_polars(
&mut self,
data: Bound<'_, PyAny>,
Expand Down
1 change: 1 addition & 0 deletions src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ impl PyDataFrame {
Ok(table)
}

#[pyo3(signature = (requested_schema=None))]
fn __arrow_c_stream__<'py>(
&'py mut self,
py: Python<'py>,
Expand Down
20 changes: 20 additions & 0 deletions src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fn array_cat(exprs: Vec<PyExpr>) -> PyExpr {
}

#[pyfunction]
#[pyo3(signature = (array, element, index=None))]
fn array_position(array: PyExpr, element: PyExpr, index: Option<i64>) -> PyExpr {
let index = ScalarValue::Int64(index);
let index = Expr::Literal(index);
Expand All @@ -104,6 +105,7 @@ fn array_position(array: PyExpr, element: PyExpr, index: Option<i64>) -> PyExpr
}

#[pyfunction]
#[pyo3(signature = (array, begin, end, stride=None))]
fn array_slice(array: PyExpr, begin: PyExpr, end: PyExpr, stride: Option<PyExpr>) -> PyExpr {
datafusion::functions_nested::expr_fn::array_slice(
array.into(),
Expand Down Expand Up @@ -142,16 +144,19 @@ fn concat_ws(sep: String, args: Vec<PyExpr>) -> PyResult<PyExpr> {
}

#[pyfunction]
#[pyo3(signature = (values, regex, flags=None))]
fn regexp_like(values: PyExpr, regex: PyExpr, flags: Option<PyExpr>) -> PyResult<PyExpr> {
Ok(functions::expr_fn::regexp_like(values.expr, regex.expr, flags.map(|x| x.expr)).into())
}

#[pyfunction]
#[pyo3(signature = (values, regex, flags=None))]
fn regexp_match(values: PyExpr, regex: PyExpr, flags: Option<PyExpr>) -> PyResult<PyExpr> {
Ok(functions::expr_fn::regexp_match(values.expr, regex.expr, flags.map(|x| x.expr)).into())
}

#[pyfunction]
#[pyo3(signature = (string, pattern, replacement, flags=None))]
/// Replaces substring(s) matching a POSIX regular expression.
fn regexp_replace(
string: PyExpr,
Expand Down Expand Up @@ -283,6 +288,7 @@ fn find_window_fn(name: &str, ctx: Option<PySessionContext>) -> PyResult<WindowF

/// Creates a new Window function expression
#[pyfunction]
#[pyo3(signature = (name, args, partition_by=None, order_by=None, window_frame=None, ctx=None))]
fn window(
name: &str,
args: Vec<PyExpr>,
Expand Down Expand Up @@ -331,6 +337,7 @@ macro_rules! aggregate_function {
};
($NAME: ident, $($arg:ident)*) => {
#[pyfunction]
#[pyo3(signature = ($($arg),*, distinct=None, filter=None, order_by=None, null_treatment=None))]
fn $NAME(
$($arg: PyExpr),*,
distinct: Option<bool>,
Expand All @@ -351,6 +358,7 @@ macro_rules! aggregate_function_vec_args {
};
($NAME: ident, $($arg:ident)*) => {
#[pyfunction]
#[pyo3(signature = ($($arg),*, distinct=None, filter=None, order_by=None, null_treatment=None))]
fn $NAME(
$($arg: PyExpr),*,
distinct: Option<bool>,
Expand Down Expand Up @@ -624,6 +632,7 @@ aggregate_function!(approx_median);
// aggregate_function!(grouping);

#[pyfunction]
#[pyo3(signature = (expression, percentile, num_centroids=None, filter=None))]
pub fn approx_percentile_cont(
expression: PyExpr,
percentile: f64,
Expand All @@ -642,6 +651,7 @@ pub fn approx_percentile_cont(
}

#[pyfunction]
#[pyo3(signature = (expression, weight, percentile, filter=None))]
pub fn approx_percentile_cont_with_weight(
expression: PyExpr,
weight: PyExpr,
Expand All @@ -662,6 +672,7 @@ aggregate_function_vec_args!(last_value);
// We handle first_value explicitly because the signature expects an order_by
// https://github.com/apache/datafusion/issues/12376
#[pyfunction]
#[pyo3(signature = (expr, distinct=None, filter=None, order_by=None, null_treatment=None))]
pub fn first_value(
expr: PyExpr,
distinct: Option<bool>,
Expand All @@ -677,6 +688,7 @@ pub fn first_value(

// nth_value requires a non-expr argument
#[pyfunction]
#[pyo3(signature = (expr, n, distinct=None, filter=None, order_by=None, null_treatment=None))]
pub fn nth_value(
expr: PyExpr,
n: i64,
Expand All @@ -691,6 +703,7 @@ pub fn nth_value(

// string_agg requires a non-expr argument
#[pyfunction]
#[pyo3(signature = (expr, delimiter, distinct=None, filter=None, order_by=None, null_treatment=None))]
pub fn string_agg(
expr: PyExpr,
delimiter: String,
Expand Down Expand Up @@ -730,6 +743,7 @@ fn add_builder_fns_to_window(
}

#[pyfunction]
#[pyo3(signature = (arg, shift_offset, default_value=None, partition_by=None, order_by=None))]
pub fn lead(
arg: PyExpr,
shift_offset: i64,
Expand All @@ -743,6 +757,7 @@ pub fn lead(
}

#[pyfunction]
#[pyo3(signature = (arg, shift_offset, default_value=None, partition_by=None, order_by=None))]
pub fn lag(
arg: PyExpr,
shift_offset: i64,
Expand All @@ -756,13 +771,15 @@ pub fn lag(
}

#[pyfunction]
#[pyo3(signature = (partition_by=None, order_by=None))]
pub fn rank(partition_by: Option<Vec<PyExpr>>, order_by: Option<Vec<PyExpr>>) -> PyResult<PyExpr> {
let window_fn = window_function::rank();

add_builder_fns_to_window(window_fn, partition_by, order_by)
}

#[pyfunction]
#[pyo3(signature = (partition_by=None, order_by=None))]
pub fn dense_rank(
partition_by: Option<Vec<PyExpr>>,
order_by: Option<Vec<PyExpr>>,
Expand All @@ -773,6 +790,7 @@ pub fn dense_rank(
}

#[pyfunction]
#[pyo3(signature = (partition_by=None, order_by=None))]
pub fn percent_rank(
partition_by: Option<Vec<PyExpr>>,
order_by: Option<Vec<PyExpr>>,
Expand All @@ -783,6 +801,7 @@ pub fn percent_rank(
}

#[pyfunction]
#[pyo3(signature = (partition_by=None, order_by=None))]
pub fn cume_dist(
partition_by: Option<Vec<PyExpr>>,
order_by: Option<Vec<PyExpr>>,
Expand All @@ -793,6 +812,7 @@ pub fn cume_dist(
}

#[pyfunction]
#[pyo3(signature = (arg, partition_by=None, order_by=None))]
pub fn ntile(
arg: PyExpr,
partition_by: Option<Vec<PyExpr>>,
Expand Down