1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Is it possible to parse Date-time in BigQuery beyond Microseconds?

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 1, 2024 às 10:22.

  1. Stack

    Stack Membro Participativo

    So, in BigQuery SQL the following Statement Works:

    SELECT TIMESTAMP("2023-07-20T12:32:36.123456Z")


    However, this one doesn't:

    SELECT TIMESTAMP("2023-07-20T12:32:36.123456789Z")


    It produces "Invalid timestamp: '2023-07-20T12:32:36.123456789Z'"

    It appears that the standard BigQuery SQL TIMESTAMP function does not parse date-time beyond microseconds.

    Is there a best practice or other elegant way to deal with that? I can think of writing my own parser, but that seems like an overkill...

    Edit: Using the PARSE_TIMESTAMP function

    SELECT PARSE_TIMESTAMP("%Y-%m-%dT%H:%M:%E6SZ", "2022-09-16T14:07:28.123456Z")


    Also works fine, but

    SELECT PARSE_TIMESTAMP("%Y-%m-%dT%H:%M:%E7SZ", "2022-09-16T14:07:28.1234567Z")


    Does not.

    Edit: Currently it seems like this feature does not exist. Here is a feature request for the same...

    Continue reading...

Compartilhe esta Página