Skip to content

Conversation

@anhqle
Copy link
Contributor

@anhqle anhqle commented Oct 7, 2021

This PR implements the ability to create STRUCT with optional field names, i.e. STRUCT(expr1 [AS field_name] [, ... ]). Does not implement typed STRUCT, e.g. STRUCT<INT64>
. Partially resolve #591.

Examples (included as unit tests):

Query.from_(Table('abc')).select(Struct(1, "a", ["b", 2, 3]))
>>> SELECT STRUCT(1,'a',['b',2,3]) FROM "abc"

Query.from_(Table('abc')).select(Struct(1, "a", ["b", 2, 3], field_names=["col1", "col2", "col3"]))
>>> SELECT STRUCT(1 AS col1,'a' AS col2,['b',2,3] AS col3) FROM "abc"

Discussion points:

  1. Do you suggest a different API to specify field_names? Perhaps next to the value itself?
  2. Even though Support BigQuery dialect #591 mentions BigQuery, but I think STRUCT is ANSI SQL. I'm open to moving STRUCT to inside BigQuery dialect.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 98.409% when pulling 60c8d08 on anhqle:implement-struct2 into a7b01da on kayak:master.

@anhqle anhqle marked this pull request as ready for review October 7, 2021 04:24
@anhqle anhqle requested a review from a team as a code owner October 7, 2021 04:24
@anhqle anhqle mentioned this pull request Oct 7, 2021
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

Successfully merging this pull request may close these issues.

Support BigQuery dialect

2 participants