Skip to content

Commit 4b45a4b

Browse files
committed
fix pyo3 warnings
Implicit defaults for trailing optional arguments have been deprecated in pyo3 v0.22.0 PyO3/pyo3#4078
1 parent f2b3d3b commit 4b45a4b

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

src/common/data_type.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use pyo3::{exceptions::PyValueError, prelude::*};
2424
use crate::errors::py_datafusion_err;
2525

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

693693
/// Represents the possible Python types that can be mapped to the SQL types
694694
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
695-
#[pyclass(name = "PythonType", module = "datafusion.common")]
695+
#[pyclass(eq, eq_int, name = "PythonType", module = "datafusion.common")]
696696
pub enum PythonType {
697697
Array,
698698
Bool,
@@ -712,7 +712,7 @@ pub enum PythonType {
712712
#[allow(non_camel_case_types)]
713713
#[allow(clippy::upper_case_acronyms)]
714714
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
715-
#[pyclass(name = "SqlType", module = "datafusion.common")]
715+
#[pyclass(eq, eq_int, name = "SqlType", module = "datafusion.common")]
716716
pub enum SqlType {
717717
ANY,
718718
ARRAY,
@@ -770,7 +770,7 @@ pub enum SqlType {
770770
#[allow(non_camel_case_types)]
771771
#[allow(clippy::upper_case_acronyms)]
772772
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
773-
#[pyclass(name = "NullTreatment", module = "datafusion.common")]
773+
#[pyclass(eq, eq_int, name = "NullTreatment", module = "datafusion.common")]
774774
pub enum NullTreatment {
775775
IGNORE_NULLS,
776776
RESPECT_NULLS,

src/common/schema.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub struct SqlTable {
6262
#[pymethods]
6363
impl SqlTable {
6464
#[new]
65+
#[pyo3(signature = (table_name, columns, row_count, filepaths=None))]
6566
pub fn new(
6667
table_name: String,
6768
columns: Vec<(String, DataTypeMap)>,

src/context.rs

+8
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ impl PySessionContext {
294294
}
295295

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

378+
#[pyo3(signature = (query, options=None))]
377379
pub fn sql_with_options(
378380
&mut self,
379381
query: &str,
@@ -390,6 +392,7 @@ impl PySessionContext {
390392
Ok(PyDataFrame::new(df))
391393
}
392394

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

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

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

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

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

527534
/// Construct datafusion dataframe from polars
535+
#[pyo3(signature = (data, name=None))]
528536
pub fn from_polars(
529537
&mut self,
530538
data: Bound<'_, PyAny>,

src/dataframe.rs

+1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ impl PyDataFrame {
504504
Ok(table)
505505
}
506506

507+
#[pyo3(signature = (requested_schema=None))]
507508
fn __arrow_c_stream__<'py>(
508509
&'py mut self,
509510
py: Python<'py>,

src/functions.rs

+20
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ fn array_cat(exprs: Vec<PyExpr>) -> PyExpr {
9696
}
9797

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

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

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

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

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

284289
/// Creates a new Window function expression
285290
#[pyfunction]
291+
#[pyo3(signature = (name, args, partition_by=None, order_by=None, window_frame=None, ctx=None))]
286292
fn window(
287293
name: &str,
288294
args: Vec<PyExpr>,
@@ -331,6 +337,7 @@ macro_rules! aggregate_function {
331337
};
332338
($NAME: ident, $($arg:ident)*) => {
333339
#[pyfunction]
340+
#[pyo3(signature = ($($arg),*, distinct=None, filter=None, order_by=None, null_treatment=None))]
334341
fn $NAME(
335342
$($arg: PyExpr),*,
336343
distinct: Option<bool>,
@@ -351,6 +358,7 @@ macro_rules! aggregate_function_vec_args {
351358
};
352359
($NAME: ident, $($arg:ident)*) => {
353360
#[pyfunction]
361+
#[pyo3(signature = ($($arg),*, distinct=None, filter=None, order_by=None, null_treatment=None))]
354362
fn $NAME(
355363
$($arg: PyExpr),*,
356364
distinct: Option<bool>,
@@ -624,6 +632,7 @@ aggregate_function!(approx_median);
624632
// aggregate_function!(grouping);
625633

626634
#[pyfunction]
635+
#[pyo3(signature = (expression, percentile, num_centroids=None, filter=None))]
627636
pub fn approx_percentile_cont(
628637
expression: PyExpr,
629638
percentile: f64,
@@ -642,6 +651,7 @@ pub fn approx_percentile_cont(
642651
}
643652

644653
#[pyfunction]
654+
#[pyo3(signature = (expression, weight, percentile, filter=None))]
645655
pub fn approx_percentile_cont_with_weight(
646656
expression: PyExpr,
647657
weight: PyExpr,
@@ -662,6 +672,7 @@ aggregate_function_vec_args!(last_value);
662672
// We handle first_value explicitly because the signature expects an order_by
663673
// https://github.com/apache/datafusion/issues/12376
664674
#[pyfunction]
675+
#[pyo3(signature = (expr, distinct=None, filter=None, order_by=None, null_treatment=None))]
665676
pub fn first_value(
666677
expr: PyExpr,
667678
distinct: Option<bool>,
@@ -677,6 +688,7 @@ pub fn first_value(
677688

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

692704
// string_agg requires a non-expr argument
693705
#[pyfunction]
706+
#[pyo3(signature = (expr, delimiter, distinct=None, filter=None, order_by=None, null_treatment=None))]
694707
pub fn string_agg(
695708
expr: PyExpr,
696709
delimiter: String,
@@ -730,6 +743,7 @@ fn add_builder_fns_to_window(
730743
}
731744

732745
#[pyfunction]
746+
#[pyo3(signature = (arg, shift_offset, default_value=None, partition_by=None, order_by=None))]
733747
pub fn lead(
734748
arg: PyExpr,
735749
shift_offset: i64,
@@ -743,6 +757,7 @@ pub fn lead(
743757
}
744758

745759
#[pyfunction]
760+
#[pyo3(signature = (arg, shift_offset, default_value=None, partition_by=None, order_by=None))]
746761
pub fn lag(
747762
arg: PyExpr,
748763
shift_offset: i64,
@@ -756,13 +771,15 @@ pub fn lag(
756771
}
757772

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

762778
add_builder_fns_to_window(window_fn, partition_by, order_by)
763779
}
764780

765781
#[pyfunction]
782+
#[pyo3(signature = (partition_by=None, order_by=None))]
766783
pub fn dense_rank(
767784
partition_by: Option<Vec<PyExpr>>,
768785
order_by: Option<Vec<PyExpr>>,
@@ -773,6 +790,7 @@ pub fn dense_rank(
773790
}
774791

775792
#[pyfunction]
793+
#[pyo3(signature = (partition_by=None, order_by=None))]
776794
pub fn percent_rank(
777795
partition_by: Option<Vec<PyExpr>>,
778796
order_by: Option<Vec<PyExpr>>,
@@ -783,6 +801,7 @@ pub fn percent_rank(
783801
}
784802

785803
#[pyfunction]
804+
#[pyo3(signature = (partition_by=None, order_by=None))]
786805
pub fn cume_dist(
787806
partition_by: Option<Vec<PyExpr>>,
788807
order_by: Option<Vec<PyExpr>>,
@@ -793,6 +812,7 @@ pub fn cume_dist(
793812
}
794813

795814
#[pyfunction]
815+
#[pyo3(signature = (arg, partition_by=None, order_by=None))]
796816
pub fn ntile(
797817
arg: PyExpr,
798818
partition_by: Option<Vec<PyExpr>>,

0 commit comments

Comments
 (0)