-1

In the following query:

select t, 1 from (select 1 as a, 2 as b) t

It produces a column of struct type: {"a": 1, "b": 2} for the column t. Is this the expected behavior, and if so (and I'm almost 100% sure it is), where is that behavior documented in BigQuery or in the SQL standard?

Another example:

select t as x, t.*, 1 as y from (select 1 as a, 2 as b) t

enter image description here

3
  • I've been reading the SQL:2023 specification for 30 minutes now without finding anything like this. (Very time-consuming document to read.) Anyway, "following" this question. Commented Apr 2, 2024 at 20:45
  • @jarlh -- thanks. Where did you find the standard from? Or did you purchase it from the ISO website? Commented Apr 2, 2024 at 21:26
  • Purchased from ISO. Commented Apr 3, 2024 at 7:52

1 Answer 1

1

This is definitely the expected behavior in BigQuery. While the documentation might not show examples exactly like yours, the underlying concept aligns perfectly. I ran your query using BigQuery's sample structure and got the same results.

Query 1:

WITH t AS (select 1 as a, 2 as b)
SELECT t, 1 FROM t;

Query 2:

WITH t AS (select 1 as a, 2 as b)
SELECT t as x, t.*, 1 as y FROM t;

The same is observed in a couple of related posts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.