Commit 6a82d7b
authored
feat(go/adbc/driver/bigquery): add
## Motivation
The `Type` metadata key has two limitations which stems from BigQuery's
API:
1. it says fields of type `ARRAY<T>` are just `T` with `Repeated=true`
2. it says `STRUCT<...>` fields are simply `RECORD`, and erases any
information about the inner fields.
These limitations can cause problems when trying to parse the `Type` key
or when using it verbatim against the warehouse in a statement, e.g a
`CREATE TABLE` statement or a `AS T` cast.
## Summary
This PR adds a new `BIGQUERY:type` key that formats the original SQL
string as [specified by
BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#declaring_a_struct_type).
Most types remain unchanged as they come from `gobigquery`, and in those
cases this key will contain the same value as `Type`.
However, arrays and structs get transformed to match the richer type
string.
## Testing
I ran a `CREATE TABLE AS` query against BigQuery. Here's the result for
fields of different types
[1] Regular non-nested types are simply copied over from the value of
`Type`
<details>
<summary>1</summary>
<img width="331" height="1071" alt="image"
src="https://github.com/user-attachments/assets/ccd2ce17-37d8-4630-bef5-a503ed450c2a"
/>
</details>
[2] An array of integers becomes `ARRAY<INTEGER>`, while `Type` remains
`INTEGER`
<details>
<summary>2</summary>
<img width="319" height="369" alt="image"
src="https://github.com/user-attachments/assets/e588d7ac-c7ca-40fb-ab51-9795e566d240"
/>
</details>
[3] An array of structs becomes `ARRAY<STRUCT<...>>`
<details>
<summary>3</summary>
<img width="551" height="816" alt="image"
src="https://github.com/user-attachments/assets/bb946ebc-747a-4529-88a8-68636f94e44e"
/>
</details>
[4] A struct of arrays' inner types are `ARRAY<...>`
<details>
<summary>4</summary>
<img width="610" height="922" alt="image"
src="https://github.com/user-attachments/assets/932a3554-ea56-4b1f-8642-801ee91c4f63"
/>
</details>
[5] A deeply nested struct also has the correct inner types
<details>
<summary>5</summary>
<img width="1327" height="1307" alt="image"
src="https://github.com/user-attachments/assets/3185651b-8809-42b0-adc4-ec956eaf9e87"
/>
</details>
## Related issues
- #3449BIGQUERY:type field metadata (#3604)1 parent f6f8e49 commit 6a82d7b
1 file changed
+13
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
| 798 | + | |
| 799 | + | |
798 | 800 | | |
799 | 801 | | |
800 | 802 | | |
| |||
823 | 825 | | |
824 | 826 | | |
825 | 827 | | |
| 828 | + | |
826 | 829 | | |
827 | 830 | | |
828 | 831 | | |
829 | 832 | | |
830 | 833 | | |
831 | 834 | | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
832 | 840 | | |
833 | 841 | | |
| 842 | + | |
834 | 843 | | |
835 | 844 | | |
836 | 845 | | |
| |||
888 | 897 | | |
889 | 898 | | |
890 | 899 | | |
| 900 | + | |
891 | 901 | | |
892 | 902 | | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
893 | 906 | | |
894 | 907 | | |
895 | 908 | | |
| |||
0 commit comments