Skip to content

Commit

Permalink
docs: implement ruff recommendation
Browse files Browse the repository at this point in the history
  • Loading branch information
kosiew committed Dec 3, 2024
1 parent 74cbd3b commit 1c5b91e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions python/datafusion/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,11 @@ def literal(value: Any) -> Expr:
def utf8_literal(value: str) -> Expr:
"""Creates a new expression representing a UTF8 literal value.
It is different from `literal` because it is pa.string() instead of pa.string_view()
This is needed for cases where datafusion is expecting a utf8 instead of utf8view literal like in
It is different from `literal` because it is pa.string() instead of
pa.string_view()
This is needed for cases where DataFusion is expecting a UTF8 instead of
UTF8View literal, like in:
https://github.com/apache/datafusion/blob/86740bfd3d9831d6b7c1d0e1bf4a21d91598a0ac/datafusion/functions/src/core/arrow_cast.rs#L179
"""
if isinstance(value, str):
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,8 @@ def test_temporal_functions(df):

def test_arrow_cast(df):
df = df.select(
# we use `utf8_literal` to returns utf8 instead of `literal` which returns utf8view
# because datafusion.arrow_cast # expects a utf8 instead of utf8view
# we use `utf8_literal` to returns utf8 instead of `literal` which returns
# utf8view # because datafusion.arrow_cast expects a utf8 instead of utf8view
# https://github.com/apache/datafusion/blob/86740bfd3d9831d6b7c1d0e1bf4a21d91598a0ac/datafusion/functions/src/core/arrow_cast.rs#L179
f.arrow_cast(column("b"), utf8_literal("Float64")).alias("b_as_float"),
f.arrow_cast(column("b"), utf8_literal("Int32")).alias("b_as_int"),
Expand Down

0 comments on commit 1c5b91e

Please sign in to comment.