Giter VIP home page Giter VIP logo

Comments (4)

den-crane avatar den-crane commented on May 26, 2024 2

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

from clickhouse.

wekt0r avatar wekt0r commented on May 26, 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 ?

from clickhouse.

den-crane avatar den-crane commented on May 26, 2024

There is parseDateTime64BestEffort and parseDateTime64BestEffortUS

SELECT parseDateTime64BestEffortUSOrNull('01/13/2024')

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

from clickhouse.

wekt0r avatar wekt0r commented on May 26, 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') .

from clickhouse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.