Skip to content

Commit 00ac681

Browse files
committed
Fix claude's attempt to cheat with sql
1 parent b517838 commit 00ac681

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

python/datafusion/functions.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,13 +1450,18 @@ def date_bin(stride: Expr, source: Expr, origin: Expr) -> Expr:
14501450
Examples:
14511451
---------
14521452
>>> ctx = dfn.SessionContext()
1453-
>>> result = ctx.sql(
1454-
... "SELECT date_bin(interval '1 day',"
1455-
... " timestamp '2021-07-15 12:34:56',"
1456-
... " timestamp '2021-01-01') as b"
1453+
>>> df = ctx.from_pydict({"timestamp": ['2021-07-15 12:34:56', '2021-01-01']})
1454+
>>> result = df.select(
1455+
... dfn.functions.date_bin(
1456+
... dfn.string_literal("15 minutes"),
1457+
... dfn.col("timestamp"),
1458+
... dfn.string_literal("2001-01-01 00:00:00")
1459+
... ).alias("b")
14571460
... )
14581461
>>> str(result.collect_column("b")[0].as_py())
1459-
'2021-07-15 00:00:00'
1462+
'2021-07-15 12:30:00'
1463+
>>> str(result.collect_column("b")[1].as_py())
1464+
'2021-01-01 00:00:00'
14601465
"""
14611466
return Expr(f.date_bin(stride.expr, source.expr, origin.expr))
14621467

0 commit comments

Comments
 (0)