@@ -778,12 +778,21 @@ func (c *connectionImpl) getTableSchemaWithFilter(ctx context.Context, catalog *
778778
779779func buildField (schema * bigquery.FieldSchema , level uint ) (arrow.Field , error ) {
780780 field := arrow.Field {Name : schema .Name }
781+ field .Nullable = ! schema .Required
782+
781783 metadata := make (map [string ]string )
784+
782785 metadata ["Description" ] = schema .Description
786+ metadata ["BIGQUERY:description" ] = schema .Description
787+
783788 metadata ["Repeated" ] = strconv .FormatBool (schema .Repeated )
789+ metadata ["BIGQUERY:repeated" ] = strconv .FormatBool (schema .Repeated )
790+
784791 metadata ["Required" ] = strconv .FormatBool (schema .Required )
785- field .Nullable = ! schema .Required
792+ metadata ["BIGQUERY:required" ] = strconv .FormatBool (schema .Required )
793+
786794 metadata ["Type" ] = string (schema .Type )
795+ metadata ["BIGQUERY:raw_type" ] = string (schema .Type )
787796
788797 richSqlType := string (schema .Type )
789798
@@ -793,16 +802,22 @@ func buildField(schema *bigquery.FieldSchema, level uint) (arrow.Field, error) {
793802 return arrow.Field {}, err
794803 }
795804 metadata ["PolicyTags" ] = string (policyTagList )
805+ metadata ["BIGQUERY:policy_tags" ] = string (policyTagList )
796806 }
797807
798808 // https://cloud.google.com/bigquery/docs/reference/storage#arrow_schema_details
799809 switch schema .Type {
800810 case bigquery .StringFieldType :
801811 metadata ["MaxLength" ] = strconv .FormatInt (schema .MaxLength , 10 )
812+ metadata ["BIGQUERY:max_length" ] = strconv .FormatInt (schema .MaxLength , 10 )
813+
802814 metadata ["Collation" ] = schema .Collation
815+ metadata ["BIGQUERY:collation" ] = schema .Collation
816+
803817 field .Type = arrow .BinaryTypes .String
804818 case bigquery .BytesFieldType :
805819 metadata ["MaxLength" ] = strconv .FormatInt (schema .MaxLength , 10 )
820+ metadata ["BIGQUERY:max_length" ] = strconv .FormatInt (schema .MaxLength , 10 )
806821 field .Type = arrow .BinaryTypes .Binary
807822 case bigquery .IntegerFieldType :
808823 field .Type = arrow .PrimitiveTypes .Int64
@@ -895,6 +910,7 @@ func buildField(schema *bigquery.FieldSchema, level uint) (arrow.Field, error) {
895910
896911 if level == 0 {
897912 metadata ["DefaultValueExpression" ] = schema .DefaultValueExpression
913+ metadata ["BIGQUERY:default_value_expression" ] = schema .DefaultValueExpression
898914 }
899915 field .Metadata = arrow .MetadataFrom (metadata )
900916 return field , nil
0 commit comments