TRY_TO_TIMESTAMP (Lakehouse v1)
Una variante de TO_TIMESTAMP en PlaidCloud Lakehouse que, aunque realiza la misma conversión de una expresión de entrada a una marca de tiempo, incorpora control de errores: devuelve NULL si la conversión falla, en lugar de generar un error.
Consulte también: TO_TIMESTAMP
Sintaxis de Analyze
Sección titulada «Sintaxis de Analyze»func.try_to_timestamp(<expr>)Ejemplos de Analyze
Sección titulada «Ejemplos de Analyze»func.try_to_timestamp('2022-01-02 02:00:11'), func.try_to_datetime('2022-01-02 02:00:11'), func.try_to_timestamp('plaidcloud')┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ func.try_to_timestamp('2022-01-02 02:00:11') │ func.try_to_datetime('2022-01-02 02:00:11') │ func.try_to_timestamp('plaidcloud') ││ Timestamp │ Timestamp │ │├─────────────────────────────────────────┼──────────────────────────────────────────────────┤─────────────────────────────────────││ 2022-01-02 02:00:11 │ 2022-01-02 02:00:11 │ NULL │└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘Sintaxis SQL
Sección titulada «Sintaxis SQL»-- Convert a string or integer to a timestampTRY_TO_TIMESTAMP(<expr>)
-- Convert a string to a timestamp using the given patternTRY_TO_TIMESTAMP(<expr, expr>)Ejemplos de SQL
Sección titulada «Ejemplos de SQL»SELECT TRY_TO_TIMESTAMP('2022-01-02 02:00:11'), TRY_TO_DATETIME('2022-01-02 02:00:11');
┌──────────────────────────────────────────────────────────────────────────────────┐│ try_to_timestamp('2022-01-02 02:00:11') │ try_to_datetime('2022-01-02 02:00:11') ││ Timestamp │ Timestamp │├─────────────────────────────────────────┼────────────────────────────────────────┤│ 2022-01-02 02:00:11 │ 2022-01-02 02:00:11 │└──────────────────────────────────────────────────────────────────────────────────┘
SELECT TRY_TO_TIMESTAMP('databend'), TRY_TO_DATETIME('databend');
┌────────────────────────────────────────────────────────────┐│ try_to_timestamp('databend') │ try_to_datetime('databend') │├──────────────────────────────┼─────────────────────────────┤│ NULL │ NULL │└────────────────────────────────────────────────────────────┘