Skip to content

Commit

Permalink
use warnings.warn
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-ho committed Nov 13, 2023
1 parent c038678 commit 2e8683d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions daft/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# in order to support runtime typechecking across different Python versions.
# For technical details, see https://github.com/Eventual-Inc/Daft/pull/630

import logging
import pathlib
from dataclasses import dataclass
from functools import reduce
Expand All @@ -21,6 +20,7 @@
TypeVar,
Union,
)
import warnings

from daft.api_annotations import DataframePublicAPI
from daft.context import get_context
Expand All @@ -47,8 +47,6 @@

from daft.logical.schema import Schema

logger = logging.getLogger(__name__)

UDFReturnType = TypeVar("UDFReturnType", covariant=True)

ColumnInputType = Union[Expression, str]
Expand Down Expand Up @@ -854,7 +852,7 @@ def sum(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated sums. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing sum on all columns. Specify columns using df.sum('col1', 'col2', ...)."
)
cols = tuple(self.columns)
Expand All @@ -870,7 +868,7 @@ def mean(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated mean. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing mean on all columns. Specify columns using df.mean('col1', 'col2', ...)."
)
cols = tuple(self.columns)
Expand All @@ -886,7 +884,7 @@ def min(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated min. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing min on all columns. Specify columns using df.min('col1', 'col2', ...)."
)
cols = tuple(self.columns)
Expand All @@ -902,7 +900,7 @@ def max(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated max. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing max on all columns. Specify columns using df.max('col1', 'col2', ...)."
)
cols = tuple(self.columns)
Expand All @@ -918,7 +916,7 @@ def count(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated count. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing count on all columns. Specify columns using df.count('col1', 'col2', ...) or use df.count_rows() for row counts."
)
cols = tuple(self.columns)
Expand All @@ -934,7 +932,7 @@ def agg_list(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated list. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing agg_list on all columns. Specify columns using df.agg_list('col1', 'col2', ...)."
)
cols = tuple(self.columns)
Expand All @@ -950,7 +948,7 @@ def agg_concat(self, *cols: ColumnInputType) -> "DataFrame":
DataFrame: Globally aggregated list. Should be a single row.
"""
if len(cols) == 0:
logger.warning(
warnings.warn(
"No columns specified; performing agg_concat on all columns. Specify columns using df.agg_concat('col1', 'col2', ...)."
)
cols = tuple(self.columns)
Expand Down

0 comments on commit 2e8683d

Please sign in to comment.