Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATE() SQL function always returns Date type, even with DateTime strftime format string #17093

Closed
2 tasks done
jqnatividad opened this issue Jun 20, 2024 · 2 comments · Fixed by #17245
Closed
2 tasks done
Assignees
Labels
A-sql Area: Polars SQL functionality bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars

Comments

@jqnatividad
Copy link
Contributor

jqnatividad commented Jun 20, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

$ polars --version
polars-cli 0.8.0

$ polars -c "select DATE('03-15-2021 10:30:20 AM EST', '%m-%d-%Y %I:%M:%S %p %Z') as col1, cast(DATE('2021-03-15 10:30:20', '%Y-%m-%d %H:%M:%S') as datetime) as col2 from read_csv('foods.csv')"
┌────────────┬─────────────────────┐
│ col1       ┆ col2                │
│ ---        ┆ ---                 │
│ date       ┆ datetime[μs]        │
╞════════════╪═════════════════════╡
│ 2021-03-15 ┆ 2021-03-15 00:00:00 │
└────────────┴─────────────────────┘%    

Log output

No response

Issue description

It always returns a Date, not a DateTime, even if the parameters call for a datetime

Expected behavior

returns DateTime when the format string specifies it and the incoming date has the datetime components.

Installed versions

"asof_join",
"avro",
"binary_encoding",
"coalesce",
"cse",
"cross_join",
"dtype-full",
"extract_jsonpath",
"ipc",
"json",
"lazy",
"object",
"parquet",
"performant",
"semi_anti_join",
"serde-lazy",
"sql",
"streaming",
"timezones",

@jqnatividad jqnatividad added bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars labels Jun 20, 2024
@jqnatividad jqnatividad changed the title ATE() SQL function always returns Date type, even with DateTime strftime format string DATE() SQL function always returns Date type, even with DateTime strftime format string Jun 20, 2024
@d-reynol
Copy link

This is consistent with the documentation, which says DATE returns a date type:

image

@jqnatividad
Copy link
Contributor Author

Thanks @d-reynol for the clarification.

In that case, is there a similar SQL function that returns a datetime type? Or lacking that, a SQL recipe to do so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql Area: Polars SQL functionality bug Something isn't working needs triage Awaiting prioritization by a maintainer rust Related to Rust Polars
Projects
None yet
3 participants