DATE() SQL function always returns Date type, even with DateTime strftime format string
Closed this issue · 2 comments
jqnatividad commented
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",
d-reynol commented
jqnatividad commented
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?