Skip to content

TO_TIMESTAMP returns null #6

@bisrael8191

Description

@bisrael8191

I'm having an issue trying to use the time range filters in Apache Superset because it auto generates the following query for charts:

SELECT DATE_TRUNC('hour', timestamp) AS timestamp,
       id AS id,
       max(my_metric) AS "MAX(my_metric)"
FROM my_data
WHERE timestamp >= TO_TIMESTAMP('2023-06-18T00:00:00.000000', 'yyyy-MM-ddTHH:mm:ss.SSSUUUZ')
  AND timestamp < TO_TIMESTAMP('2023-06-19T00:00:00.000000', 'yyyy-MM-ddTHH:mm:ss.SSSUUUZ')
GROUP BY DATE_TRUNC('hour', timestamp),
         id
ORDER BY MAX(my_metric) DESC
LIMIT 10000;

TO_TIMESTAMP('2023-06-18T00:00:00.000000', 'yyyy-MM-ddTHH:mm:ss.SSSUUUZ') returns null because of the extra Z on the end of the format, but both TO_TIMESTAMP('2023-06-18T00:00:00.000000', 'yyyy-MM-ddTHH:mm:ss.SSSUUU') and TO_TIMESTAMP('2023-06-18T00:00:00.000000Z', 'yyyy-MM-ddTHH:mm:ss.SSSUUUZ') work as expected. Same behavior seen when using the quest console to manually run queries.

I believe this would be a small change to this line: https://github.com/questdb/questdb-connect/blob/main/src/qdb_superset/db_engine_specs/questdb.py#L218
Either append a Z to the isoformatted string or remove the Z from the TO_TIMESTAMP function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions