Skip to content

Commit e579752

Browse files
Rename column arg in relational API functions to expression (#295)
Fixes duckdblabs/duckdb-internal#7150 We rename from `column` to `expression` to make very clear that this string can take an arbitrary expression, and if people want to pass in user-supplied data then they are responsible for validating its content. This is technically a breaking change, because we're changing the name of an arg that is not a positional-only arg (`column`). It's not a keyword-only arg either though, and it's not idiomatic to name non-keyword-only args in calls. A formal deprecation path is also likely to be messy. In this case, just a rename seems justified.
2 parents bf8dfdb + 98ccb24 commit e579752

2 files changed

Lines changed: 115 additions & 99 deletions

File tree

_duckdb-stubs/__init__.pyi

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ class DuckDBPyRelation:
481481
self, aggr_expr: Expression | str | list[Expression], group_expr: Expression | str = ""
482482
) -> DuckDBPyRelation: ...
483483
def any_value(
484-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
484+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
485485
) -> DuckDBPyRelation: ...
486486
def apply(
487487
self,
@@ -503,35 +503,35 @@ class DuckDBPyRelation:
503503
def to_arrow_reader(self, batch_size: pytyping.SupportsInt = 1000000) -> pyarrow.lib.RecordBatchReader: ...
504504
def to_arrow_table(self, batch_size: pytyping.SupportsInt = 1000000) -> pyarrow.lib.Table: ...
505505
def avg(
506-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
506+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
507507
) -> DuckDBPyRelation: ...
508508
def bit_and(
509-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
509+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
510510
) -> DuckDBPyRelation: ...
511511
def bit_or(
512-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
512+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
513513
) -> DuckDBPyRelation: ...
514514
def bit_xor(
515-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
515+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
516516
) -> DuckDBPyRelation: ...
517517
def bitstring_agg(
518518
self,
519-
column: str,
519+
expression: str,
520520
min: int | None = None,
521521
max: int | None = None,
522522
groups: str = "",
523523
window_spec: str = "",
524524
projected_columns: str = "",
525525
) -> DuckDBPyRelation: ...
526526
def bool_and(
527-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
527+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
528528
) -> DuckDBPyRelation: ...
529529
def bool_or(
530-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
530+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
531531
) -> DuckDBPyRelation: ...
532532
def close(self) -> None: ...
533533
def count(
534-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
534+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
535535
) -> DuckDBPyRelation: ...
536536
def create(self, table_name: str) -> None: ...
537537
def create_view(self, view_name: str, replace: bool = True) -> DuckDBPyRelation: ...
@@ -545,7 +545,7 @@ class DuckDBPyRelation:
545545
def execute(self) -> DuckDBPyRelation: ...
546546
def explain(self, type: ExplainType = ExplainType.STANDARD) -> str: ...
547547
def favg(
548-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
548+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
549549
) -> DuckDBPyRelation: ...
550550
def fetch_arrow_reader(self, batch_size: pytyping.SupportsInt = 1000000) -> pyarrow.lib.RecordBatchReader:
551551
"""Deprecated: use to_arrow_reader() instead."""
@@ -565,14 +565,14 @@ class DuckDBPyRelation:
565565
def fetchnumpy(self) -> dict[str, np.typing.NDArray[pytyping.Any] | pandas.Categorical]: ...
566566
def fetchone(self) -> tuple[pytyping.Any, ...] | None: ...
567567
def filter(self, filter_expr: Expression | str) -> DuckDBPyRelation: ...
568-
def first(self, column: str, groups: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
569-
def first_value(self, column: str, window_spec: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
568+
def first(self, expression: str, groups: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
569+
def first_value(self, expression: str, window_spec: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
570570
def fsum(
571-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
571+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
572572
) -> DuckDBPyRelation: ...
573-
def geomean(self, column: str, groups: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
573+
def geomean(self, expression: str, groups: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
574574
def histogram(
575-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
575+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
576576
) -> DuckDBPyRelation: ...
577577
def insert(self, values: pytyping.List[object]) -> None: ...
578578
def insert_into(self, table_name: str) -> None: ...
@@ -582,18 +582,18 @@ class DuckDBPyRelation:
582582
) -> DuckDBPyRelation: ...
583583
def lag(
584584
self,
585-
column: str,
585+
expression: str,
586586
window_spec: str,
587587
offset: pytyping.SupportsInt = 1,
588588
default_value: str = "NULL",
589589
ignore_nulls: bool = False,
590590
projected_columns: str = "",
591591
) -> DuckDBPyRelation: ...
592-
def last(self, column: str, groups: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
593-
def last_value(self, column: str, window_spec: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
592+
def last(self, expression: str, groups: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
593+
def last_value(self, expression: str, window_spec: str = "", projected_columns: str = "") -> DuckDBPyRelation: ...
594594
def lead(
595595
self,
596-
column: str,
596+
expression: str,
597597
window_spec: str,
598598
offset: pytyping.SupportsInt = 1,
599599
default_value: str = "NULL",
@@ -602,32 +602,32 @@ class DuckDBPyRelation:
602602
) -> DuckDBPyRelation: ...
603603
def limit(self, n: pytyping.SupportsInt, offset: pytyping.SupportsInt = 0) -> DuckDBPyRelation: ...
604604
def list(
605-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
605+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
606606
) -> DuckDBPyRelation: ...
607607
def map(
608608
self, map_function: Callable[..., pytyping.Any], *, schema: dict[str, sqltypes.DuckDBPyType] | None = None
609609
) -> DuckDBPyRelation: ...
610610
def max(
611-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
611+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
612612
) -> DuckDBPyRelation: ...
613613
def mean(
614-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
614+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
615615
) -> DuckDBPyRelation: ...
616616
def median(
617-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
617+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
618618
) -> DuckDBPyRelation: ...
619619
def min(
620-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
620+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
621621
) -> DuckDBPyRelation: ...
622622
def mode(
623-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
623+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
624624
) -> DuckDBPyRelation: ...
625625
def n_tile(
626626
self, window_spec: str, num_buckets: pytyping.SupportsInt, projected_columns: str = ""
627627
) -> DuckDBPyRelation: ...
628628
def nth_value(
629629
self,
630-
column: str,
630+
expression: str,
631631
window_spec: str,
632632
offset: pytyping.SupportsInt,
633633
ignore_nulls: bool = False,
@@ -646,28 +646,28 @@ class DuckDBPyRelation:
646646
self, batch_size: pytyping.SupportsInt = 1000000, *, lazy: bool = False
647647
) -> pytyping.Union[polars.DataFrame, polars.LazyFrame]: ...
648648
def product(
649-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
649+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
650650
) -> DuckDBPyRelation: ...
651651
def project(self, *args: str | Expression, groups: str = "") -> DuckDBPyRelation: ...
652652
def quantile(
653653
self,
654-
column: str,
654+
expression: str,
655655
q: float | pytyping.List[float] = 0.5,
656656
groups: str = "",
657657
window_spec: str = "",
658658
projected_columns: str = "",
659659
) -> DuckDBPyRelation: ...
660660
def quantile_cont(
661661
self,
662-
column: str,
662+
expression: str,
663663
q: float | pytyping.List[float] = 0.5,
664664
groups: str = "",
665665
window_spec: str = "",
666666
projected_columns: str = "",
667667
) -> DuckDBPyRelation: ...
668668
def quantile_disc(
669669
self,
670-
column: str,
670+
expression: str,
671671
q: float | pytyping.List[float] = 0.5,
672672
groups: str = "",
673673
window_spec: str = "",
@@ -693,22 +693,22 @@ class DuckDBPyRelation:
693693
def sort(self, *args: Expression) -> DuckDBPyRelation: ...
694694
def sql_query(self) -> str: ...
695695
def std(
696-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
696+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
697697
) -> DuckDBPyRelation: ...
698698
def stddev(
699-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
699+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
700700
) -> DuckDBPyRelation: ...
701701
def stddev_pop(
702-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
702+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
703703
) -> DuckDBPyRelation: ...
704704
def stddev_samp(
705-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
705+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
706706
) -> DuckDBPyRelation: ...
707707
def string_agg(
708-
self, column: str, sep: str = ",", groups: str = "", window_spec: str = "", projected_columns: str = ""
708+
self, expression: str, sep: str = ",", groups: str = "", window_spec: str = "", projected_columns: str = ""
709709
) -> DuckDBPyRelation: ...
710710
def sum(
711-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
711+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
712712
) -> DuckDBPyRelation: ...
713713
def tf(self) -> dict[str, tensorflow.Tensor]: ...
714714
def to_csv(
@@ -755,18 +755,18 @@ class DuckDBPyRelation:
755755
def union(self, union_rel: DuckDBPyRelation) -> DuckDBPyRelation: ...
756756
def unique(self, unique_aggr: str) -> DuckDBPyRelation: ...
757757
def update(self, set: Expression | str, *, condition: Expression | str | None = None) -> None: ...
758-
def value_counts(self, column: str, groups: str = "") -> DuckDBPyRelation: ...
758+
def value_counts(self, expression: str, groups: str = "") -> DuckDBPyRelation: ...
759759
def var(
760-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
760+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
761761
) -> DuckDBPyRelation: ...
762762
def var_pop(
763-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
763+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
764764
) -> DuckDBPyRelation: ...
765765
def var_samp(
766-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
766+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
767767
) -> DuckDBPyRelation: ...
768768
def variance(
769-
self, column: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
769+
self, expression: str, groups: str = "", window_spec: str = "", projected_columns: str = ""
770770
) -> DuckDBPyRelation: ...
771771
def write_csv(
772772
self,

0 commit comments

Comments
 (0)