nuno-faria commented on code in PR #1587:
URL:
https://github.com/apache/datafusion-python/pull/1587#discussion_r3388196925
##########
python/tests/test_functions.py:
##########
@@ -2160,16 +2161,51 @@ def test_date_part_native_str(self):
ctx = SessionContext()
df = ctx.from_pydict({"a": ["2021-07-15T00:00:00"]})
df = df.select(f.to_timestamp(column("a")).alias("a"))
- result = df.select(f.date_part("year",
column("a")).alias("y")).collect()
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
+ result = df.select(f.date_part("year",
column("a")).alias("y")).collect()
Review Comment:
Is this necessary?
##########
python/tests/test_functions.py:
##########
@@ -2160,16 +2161,51 @@ def test_date_part_native_str(self):
ctx = SessionContext()
df = ctx.from_pydict({"a": ["2021-07-15T00:00:00"]})
df = df.select(f.to_timestamp(column("a")).alias("a"))
- result = df.select(f.date_part("year",
column("a")).alias("y")).collect()
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
+ result = df.select(f.date_part("year",
column("a")).alias("y")).collect()
assert result[0].column(0)[0].as_py() == 2021
+ @pytest.mark.parametrize(
+ ("func", "name"),
+ [
+ pytest.param(f.date_part, "date_part", id="date_part"),
+ pytest.param(f.datepart, "datepart", id="datepart"),
+ pytest.param(f.extract, "extract", id="extract"),
+ ],
+ )
+ def test_date_part_expr_part_warns_deprecated(self, func, name):
+ with pytest.warns(
+ DeprecationWarning,
+ match=rf"Passing Expr for {name}\(\) argument 'part' is
deprecated",
+ ):
+ expr = func(literal("year"), column("a"))
+ assert expr is not None
+
def test_date_trunc_native_str(self):
ctx = SessionContext()
df = ctx.from_pydict({"a": ["2021-07-15T12:34:56"]})
df = df.select(f.to_timestamp(column("a")).alias("a"))
- result = df.select(f.date_trunc("month",
column("a")).alias("t")).collect()
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", DeprecationWarning)
+ result = df.select(f.date_trunc("month",
column("a")).alias("t")).collect()
Review Comment:
Same here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]