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

Format of STRUCT is ambiguous #104

Open
apstndb opened this issue Jan 18, 2021 · 3 comments
Open

Format of STRUCT is ambiguous #104

apstndb opened this issue Jan 18, 2021 · 3 comments

Comments

@apstndb
Copy link
Collaborator

apstndb commented Jan 18, 2021

Currently, spanner-cli formats of STRUCT values as [...].
I think it is ambiguous with format of ARRAY values.
(We know nested ARRAY and top-level STRUCT is forbid so strictly ambiguous.)

$ spanner-cli -e 'SELECT ARRAY(SELECT AS STRUCT 1, 2)'
[[1, 2]]
$ spanner-cli -e 'SELECT SAMPLE_LOCK_REQUESTS FROM SPANNER_SYS.LOCK_STATS_TOP_HOUR' -t
...
[[tbl._exists, Exclusive], [tbl._exists, Exclusive], [tbl._exists, Exclusive], [tbl._exists, Exclusive]]
...

How about does STRUCT use (...) like native notation?

@yfuruyama
Copy link
Collaborator

It makes sense, but at the same time it is important to have a consistency with gcloud and Cloud Console.

For example, this is the result of gcloud spanner databases execute-sql.

$ gcloud spanner databases execute-sql --instance=${INSTANCE} --sql="SELECT ARRAY(SELECT AS STRUCT 1, 2);" ${DB}
(Unspecified)
[['1', '2']]

And this is the result by Cloud Console.
image

@apstndb
Copy link
Collaborator Author

apstndb commented Jan 18, 2021

Yeah, it seems there are only bad precedents.
In BigQuery, STRUCT(record) values are expanded and FORMAT("%T", ARRAY(SELECT AS STRUCT 1, 2)) prints [(1, 2)] but it isn't yet be supported in Cloud Spanner.

@yfuruyama
Copy link
Collaborator

Yeah BigQuery's support for STRUCT data type is mature as it supports STRUCT data type for table schema and top-level query result.

How about discussing this again once we hear another user's voice or STRUCT data type gets frequently used in Cloud Spanner?

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