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

BigQuery ARRAY subquery #512

Closed
markaddleman opened this issue Oct 28, 2023 · 3 comments
Closed

BigQuery ARRAY subquery #512

markaddleman opened this issue Oct 28, 2023 · 3 comments
Assignees

Comments

@markaddleman
Copy link

https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions#array

@markaddleman
Copy link
Author

Obviously keyword :array conflicts with the existing HoneySQL use of :array. FWIW, in my custom formatters, I prefix BQ special syntax with :bq/ ...

@seancorfield
Copy link
Owner

The current :array takes an expression so I could make it accept a statement as well and generate this syntax.

Looks like we'd need support for select as struct as well so I'll have to give that some thought.

@seancorfield
Copy link
Owner

PostgreSQL also supports ARRAY(subquery) and the docs have an example showing how to do that:

user=> (sql/format {:select [[[:'ARRAY {:select :oid :from :pg_proc :where [:like :proname [:inline "bytea%"]]}]]]})
["SELECT ARRAY (SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%')"]

So, you have a way to do it right now but it would make sense for me to adjust how :array works with subqueries so the workaround with ' isn't needed for PostgreSQL either.

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

No branches or pull requests

2 participants