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

Support formatting PROTO/ENUM values #116

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Conversation

apstndb
Copy link
Owner

@apstndb apstndb commented Jan 21, 2025

This PR adds support of PROTO/ENUM value formatting.

spanner> SELECT p, p.*
         FROM (
           SELECT AS VALUE NEW examples.spanner.music.SingerInfo{singer_id: 1, birth_date: "1970-01-01", nationality: "Japan", genre: "POP"}
         ) AS p;
+----------------------------------+-----------+------------+-------------+-------+
| p                                | singer_id | birth_date | nationality | genre |
| PROTO                            | INT64     | STRING     | STRING      | ENUM  |
+----------------------------------+-----------+------------+-------------+-------+
| CAESCjE5NzAtMDEtMDEaBUphcGFuIAA= | 1         | 1970-01-01 | Japan       | 0     |
+----------------------------------+-----------+------------+-------------+-------+
1 rows in set (0.15 msecs)
timestamp:            2025-01-22T01:11:22.810217+09:00
cpu time:             0.13 msecs
rows scanned:         0 rows
deleted rows scanned: 0 rows
optimizer version:    7
optimizer statistics: auto_20250120_18_51_29UTC

spanner> SET CLI_PROTO_DESCRIPTOR_FILE += "testdata/protos/singer.proto";
Empty set (0.00 sec)

spanner> SHOW LOCAL PROTO;
+-----------------------------------------+-------+------------------------+------------------------------+
| full_name                               | kind  | package                | file                         |
+-----------------------------------------+-------+------------------------+------------------------------+
| examples.spanner.music.SingerInfo       | PROTO | examples.spanner.music | testdata/protos/singer.proto |
| examples.spanner.music.CustomSingerInfo | PROTO | examples.spanner.music | testdata/protos/singer.proto |
| examples.spanner.music.Genre            | ENUM  | examples.spanner.music | testdata/protos/singer.proto |
| examples.spanner.music.CustomGenre      | ENUM  | examples.spanner.music | testdata/protos/singer.proto |
+-----------------------------------------+-------+------------------------+------------------------------+
4 rows in set (0.00 sec)

spanner> SELECT p, p.*
         FROM (
           SELECT AS VALUE NEW examples.spanner.music.SingerInfo{singer_id: 1, birth_date: "1970-01-01", nationality: "Japan", genre: "POP"}
         ) AS p;
+-------------------------------------------------------------------+-----------+------------+-------------+-------+
| p                                                                 | singer_id | birth_date | nationality | genre |
| PROTO                                                             | INT64     | STRING     | STRING      | ENUM  |
+-------------------------------------------------------------------+-----------+------------+-------------+-------+
| singer_id:1 birth_date:"1970-01-01" nationality:"Japan" genre:POP | 1         | 1970-01-01 | Japan       | POP   |
+-------------------------------------------------------------------+-----------+------------+-------------+-------+
1 rows in set (0.25 msecs)
timestamp:            2025-01-22T01:11:36.680126+09:00
cpu time:             0.2 msecs
rows scanned:         0 rows
deleted rows scanned: 0 rows
optimizer version:    7
optimizer statistics: auto_20250120_18_51_29UTC

@apstndb apstndb added the enhancement New feature or request label Jan 21, 2025
@apstndb apstndb merged commit 03605af into main Jan 21, 2025
2 checks passed
@apstndb apstndb deleted the feature/protobuf-decoding branch January 21, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant