Skip to content

Commit

Permalink
fix: Finish adding typed_lit to help schema determination in SQL "e…
Browse files Browse the repository at this point in the history
…xtract" func (#15955)
  • Loading branch information
alexander-beedie committed Apr 30, 2024
1 parent f0dbb6a commit 9c96dca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/polars-sql/src/sql_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,11 @@ fn parse_extract(expr: Expr, field: &DateTimeField) -> PolarsResult<Expr> {
DateTimeField::Minute => expr.dt().minute(),
DateTimeField::Second => expr.dt().second(),
DateTimeField::Millisecond | DateTimeField::Milliseconds => {
(expr.clone().dt().second() * lit(1_000))
(expr.clone().dt().second() * typed_lit(1_000f64))
+ expr.dt().nanosecond().div(typed_lit(1_000_000f64))
},
DateTimeField::Microsecond | DateTimeField::Microseconds => {
(expr.clone().dt().second() * lit(1_000_000))
(expr.clone().dt().second() * typed_lit(1_000_000f64))
+ expr.dt().nanosecond().div(typed_lit(1_000f64))
},
DateTimeField::Nanosecond | DateTimeField::Nanoseconds => {
Expand Down
1 change: 0 additions & 1 deletion py-polars/tests/unit/sql/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def test_datetime_to_time(time_unit: Literal["ns", "us", "ms"]) -> None:
),
],
)
@pytest.mark.skip(reason="don't understand; will ask @alex")
def test_extract(part: str, dtype: pl.DataType, expected: list[Any]) -> None:
df = pl.DataFrame(
{
Expand Down

0 comments on commit 9c96dca

Please sign in to comment.