Skip to content

Commit

Permalink
(feat): bigquery non-nullable schema support for embedded fields in s…
Browse files Browse the repository at this point in the history
…truct
  • Loading branch information
ssabdb committed Sep 20, 2024
1 parent c62efce commit 14309e6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ibis/backends/sql/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,23 @@ def _from_ibis_GeoSpatial(cls, dtype: dt.GeoSpatial) -> sge.DataType:
f"Current geotype: {dtype.geotype}, Current srid: {dtype.srid}"
)

@classmethod
def _from_ibis_Struct(cls, dtype: dt.Struct) -> sge.DataType:
fields = [
sge.ColumnDef(
# always quote struct fields to allow reserved words as field names
this=sg.to_identifier(name, quoted=True),
# Bigquery supports embeddable nulls
kind=cls.from_ibis(field),
constraints=(
None
if field.nullable
else [sge.ColumnConstraint(kind=sge.NotNullColumnConstraint())]
)
)
for name, field in dtype.items()
]
return sge.DataType(this=typecode.STRUCT, expressions=fields, nested=True)

class BigQueryUDFType(BigQueryType):
@classmethod
Expand Down

0 comments on commit 14309e6

Please sign in to comment.