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

Add 64 bit version of parseDateTime (parseDateTime64) #63417

Open
mlazowik opened this issue May 6, 2024 · 4 comments
Open

Add 64 bit version of parseDateTime (parseDateTime64) #63417

mlazowik opened this issue May 6, 2024 · 4 comments
Labels

Comments

@mlazowik
Copy link

mlazowik commented May 6, 2024

In #46815 parseDateTime was added, but there's on 64 bit version of that function. It would be useful for the same reasons as parseDateTime, but with extended supported dates range.

Describe alternatives you've considered

Reshaping the known format in sql so that toDateTime64 can be used.

@wekt0r
Copy link

wekt0r commented May 6, 2024

For more context: parseDateTime64BestEffort is not a great way to deal with arbitrary strings with known format, e.g.:

select parseDateTimeOrNull('01/13/2024', '%d/%m/%Y') -- null, as expected
select parseDateTime64BestEffortOrNull('01/12/2024') -- 2024-12-01, as expected
select parseDateTime64BestEffortOrNull('01/13/2024') -- 2024-01-13, welp

And toDateTime64 seems to be a bad choice, since it behaves more like a cast, not an actual parser. For example:

select toDateTime64('2024-13-01', 3) -- 1900-01-01 ?
select toDateTime64('2024-ab-cd ::::::::', 3) -- 1900-01-05 15:51:50.000 ?

@den-crane
Copy link
Contributor

den-crane commented May 6, 2024

There is parseDateTime64BestEffort and parseDateTime64BestEffortUS

SELECT parseDateTime64BestEffortUSOrNull('01/13/2024')

   ┌─parseDateTime64BestEffortUSOrNull('01/13/2024')─┐
1. │                         2024-01-13 00:00:00.000 │
   └─────────────────────────────────────────────────┘

@wekt0r
Copy link

wekt0r commented May 6, 2024

Hi @den-crane, thanks for the response! I'm not sure we're on the same page, so let me clarify - in cases like '01/13/2024', functions parseDateTime64BestEffortOrNull('01/13/2024') and parseDateTime64BestEffortUSOrNull('01/13/2024') behave the same, as the US only modifies the order of the formats, and uses non-US version as a fallback. We actually want the parser with US format to never execute, and return null on the us-like dates (or ideally - return null on any formats other than '%d/%m/%Y') .

@den-crane
Copy link
Contributor

den-crane commented May 6, 2024

So you need f('01/13/2024') -> null (DateTime64) because it's the incorrect date, because of your internal requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants