Skip to content

Remove support for array function and only support array[] style postgres syntax #3115

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In apache/datafusion-sqlparser-rs#566, @MazterQyou is adding some more sophisticated support for array parsing in SQL and it turns out that postgres treats the the array keyword specially so it can't be a function

Datafusion already has support for the equivalent array creation using the postgres syntax array[] (note the brackets):

select array[1,2];
+-------------+
| List([1,2]) |
+-------------+
| [1, 2]      |
+-------------+
1 row in set. Query took 0.053 seconds.
❯ select array(1,2);
+--------------------------+
| array(Int64(1),Int64(2)) |
+--------------------------+
| [1, 2]                   |
+--------------------------+
1 row in set. Query took 0.016 seconds.

Describe the solution you'd like
I propose removing support for select array(1,2) syntax to conform with posgres:

alamb=# select array[1,2];
 array 
-------
 {1,2}
(1 row)

alamb=# select array(1,2);
ERROR:  syntax error at or near "1"
LINE 1: select array(1,2);
                     ^

Describe alternatives you've considered
Do something special with parser

Additional context

This change will likely be required when we update to the next change of sqlparser: apache/datafusion-sqlparser-rs#566

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions