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

Support for parsing timestamp with/without time zone[] and time with/without time zone[] with postgres #2034

Closed
cpcloud opened this issue Aug 11, 2023 · 4 comments
Assignees

Comments

@cpcloud
Copy link
Contributor

cpcloud commented Aug 11, 2023

Is your feature request related to a problem? Please describe.

Not related to a problem.

Describe the solution you'd like

I'd like sqlglot to support parsing the timestamp without time zone[] and time without time zone[] types for the postgres dialect.

Describe alternatives you've considered

I haven't considered any alternatives

Additional context

Proof that this is a thing :)

ibis_testing> create table t (x timestamp without time zone []);
CREATE TABLE
Time: 0.009s
@cpcloud cpcloud changed the title Support for parsing timestamp without time zone[] with postgres Support for parsing timestamp without time zone[] and time without time zone[] with postgres Aug 11, 2023
@cpcloud cpcloud changed the title Support for parsing timestamp without time zone[] and time without time zone[] with postgres Support for parsing timestamp with/without time zone[] and time with/without time zone[] with postgres Aug 11, 2023
@tobymao
Copy link
Owner

tobymao commented Aug 11, 2023

can you share the docs for this @cpcloud

@tobymao
Copy link
Owner

tobymao commented Aug 11, 2023

select cast('2022-01-01' as timestamp without time zone []) this is a syntax error

@cpcloud
Copy link
Contributor Author

cpcloud commented Aug 11, 2023

ibis_testing> select cast(array['2022-01-01'] as timestamp without time zone[]);
+-------------------------+
| array                   |
|-------------------------|
| ['2022-01-01 00:00:00'] |
+-------------------------+

You need to wrap it in the array constructor :)

@cpcloud
Copy link
Contributor Author

cpcloud commented Aug 11, 2023

The arrays docs say

PostgreSQL allows columns of a table to be defined as variable-length multidimensional arrays. Arrays of any built-in or user-defined base type, enum type, composite type, range type, or domain can be created.

Since timestamp without time zone is a built in type, it would follow that timestamp without time zone[] is a valid array type.

After the first example there's:

As shown, an array data type is named by appending square brackets ([]) to the data type name of the array elements.

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

No branches or pull requests

2 participants