Skip to content

Commit 29d53a7

Browse files
committed
fix: update error message to include both alias forms for column and literal helpers
1 parent 5ac0982 commit 29d53a7

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

python/datafusion/expr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141

4242

4343
# Standard error message for invalid expression types
44-
EXPR_TYPE_ERROR = "Use col() or lit() to construct expressions"
44+
# Mention both alias forms of column and literal helpers
45+
EXPR_TYPE_ERROR = "Use col()/column() or lit()/literal() to construct expressions"
4546

4647
# The following are imported from the internal representation. We may choose to
4748
# give these all proper wrappers, or to simply leave as is. These were added

python/tests/test_dataframe.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ def test_with_column(df):
376376

377377

378378
def test_with_column_invalid_expr(df):
379-
with pytest.raises(TypeError, match=r"Use col\(\) or lit\(\)"):
379+
with pytest.raises(
380+
TypeError, match=r"Use col\(\)/column\(\) or lit\(\)/literal\(\)"
381+
):
380382
df.with_column("c", "a")
381383

382384

@@ -412,9 +414,13 @@ def test_with_columns(df):
412414

413415

414416
def test_with_columns_invalid_expr(df):
415-
with pytest.raises(TypeError, match=r"Use col\(\) or lit\(\)"):
417+
with pytest.raises(
418+
TypeError, match=r"Use col\(\)/column\(\) or lit\(\)/literal\(\)"
419+
):
416420
df.with_columns("a")
417-
with pytest.raises(TypeError, match=r"Use col\(\) or lit\(\)"):
421+
with pytest.raises(
422+
TypeError, match=r"Use col\(\)/column\(\) or lit\(\)/literal\(\)"
423+
):
418424
df.with_columns(c="a")
419425

420426

@@ -586,12 +592,16 @@ def test_join_on_invalid_expr():
586592
df = ctx.create_dataframe([[batch]], "l")
587593
df1 = ctx.create_dataframe([[batch]], "r")
588594

589-
with pytest.raises(TypeError, match=r"Use col\(\) or lit\(\)"):
595+
with pytest.raises(
596+
TypeError, match=r"Use col\(\)/column\(\) or lit\(\)/literal\(\)"
597+
):
590598
df.join_on(df1, "a")
591599

592600

593601
def test_aggregate_invalid_aggs(df):
594-
with pytest.raises(TypeError, match=r"Use col\(\) or lit\(\)"):
602+
with pytest.raises(
603+
TypeError, match=r"Use col\(\)/column\(\) or lit\(\)/literal\(\)"
604+
):
595605
df.aggregate([], "a")
596606

597607

0 commit comments

Comments
 (0)