Skip to content

Commit

Permalink
update matches
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Jan 24, 2024
1 parent a98b9dc commit aca985e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/polars-sql/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ impl SQLFunctionVisitor<'_> {
},
true))
}),
_ => polars_bail!(InvalidOperation:"Invalid number of arguments for RegexpLike: {}",function.args.len()),
_ => polars_bail!(InvalidOperation: "invalid number of arguments for RegexpLike: {}",function.args.len()),
},
Replace => match function.args.len() {
3 => self.try_visit_ternary(|e, old, new| {
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/sql/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_round_ndigits_errors() -> None:
df = pl.DataFrame({"n": [99.999]})
with pl.SQLContext(df=df, eager_execution=True) as ctx:
with pytest.raises(
InvalidOperationError, match="Invalid 'decimals' for Round: ??"
InvalidOperationError, match="invalid 'decimals' for Round: ??"
):
ctx.execute("SELECT ROUND(n,'??') AS n FROM df")
with pytest.raises(
Expand Down
10 changes: 5 additions & 5 deletions py-polars/tests/unit/sql/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ def test_regex_operators_error() -> None:
df = pl.LazyFrame({"sval": ["ABC", "abc", "000", "A0C", "a0c"]})
with pl.SQLContext(df=df, eager_execution=True) as ctx:
with pytest.raises(
ComputeError, match="Invalid pattern for '~' operator: 12345"
ComputeError, match="invalid pattern for '~' operator: 12345"
):
ctx.execute("SELECT * FROM df WHERE sval ~ 12345")
with pytest.raises(
ComputeError,
match=r"""Invalid pattern for '!~\*' operator: col\("abcde"\)""",
match=r"""invalid pattern for '!~\*' operator: col\("abcde"\)""",
):
ctx.execute("SELECT * FROM df WHERE sval !~* abcde")

Expand Down Expand Up @@ -127,18 +127,18 @@ def test_regexp_like_errors() -> None:
with pl.SQLContext(df=pl.DataFrame({"scol": ["xyz"]})) as ctx:
with pytest.raises(
InvalidOperationError,
match="Invalid/empty 'flags' for RegexpLike",
match="invalid/empty 'flags' for RegexpLike",
):
ctx.execute("SELECT * FROM df WHERE REGEXP_LIKE(scol,'[x-z]+','')")

with pytest.raises(
InvalidOperationError,
match="Invalid arguments for RegexpLike",
match="invalid arguments for RegexpLike",
):
ctx.execute("SELECT * FROM df WHERE REGEXP_LIKE(scol,999,999)")

with pytest.raises(
InvalidOperationError,
match="Invalid number of arguments for RegexpLike",
match="invalid number of arguments for RegexpLike",
):
ctx.execute("SELECT * FROM df WHERE REGEXP_LIKE(scol)")
6 changes: 3 additions & 3 deletions py-polars/tests/unit/sql/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_string_concat() -> None:
)
def test_string_concat_errors(invalid_concat: str) -> None:
lf = pl.LazyFrame({"x": ["a", "b", "c"]})
with pytest.raises(InvalidOperationError, match="Invalid number of arguments"):
with pytest.raises(InvalidOperationError, match="invalid number of arguments"):
pl.SQLContext(data=lf).execute(f"SELECT {invalid_concat} FROM data")


Expand All @@ -101,7 +101,7 @@ def test_string_left_right_reverse() -> None:
for func, invalid in (("LEFT", "'xyz'"), ("RIGHT", "6.66")):
with pytest.raises(
InvalidOperationError,
match=f"Invalid 'n_chars' for {func.capitalize()}: {invalid}",
match=f"invalid 'n_chars' for {func.capitalize()}: {invalid}",
):
ctx.execute(f"""SELECT {func}(txt,{invalid}) FROM df""").collect()

Expand Down Expand Up @@ -317,7 +317,7 @@ def test_string_replace() -> None:
res = out["words"].to_list()
assert res == ["English breakfast tea is the best tea", "", None]

with pytest.raises(InvalidOperationError, match="Invalid number of arguments"):
with pytest.raises(InvalidOperationError, match="invalid number of arguments"):
ctx.execute("SELECT REPLACE(words,'coffee') FROM df")


Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/sql/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ def test_timestamp_time_unit_errors() -> None:
with pl.SQLContext(frame_data=df, eager_execution=True) as ctx:
for prec in (0, 4, 15):
with pytest.raises(
ComputeError, match=f"Unsupported timestamp precision; .* prec={prec}"
ComputeError, match=f"unsupported `timestamp` precision; .* prec={prec}"
):
ctx.execute(f"SELECT ts::timestamp({prec}) FROM frame_data")

0 comments on commit aca985e

Please sign in to comment.