Package com.google.cloud.bigquery
Class Field.Builder
java.lang.Object
com.google.cloud.bigquery.Field.Builder
- Enclosing class:
- Field
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates aField
object.setCollation
(String collation) Optional.setDefaultValueExpression
(String defaultValueExpression) DefaultValueExpression is used to specify the default value of a field using a SQL expression.setDescription
(String description) Sets the field description.setMaxLength
(Long maxLength) Sets the maximum length of the field for STRING or BYTES type.setMode
(Field.Mode mode) Sets the mode of the field.Sets the field name.setPolicyTags
(PolicyTags policyTags) Sets the policy tags for the field.setPrecision
(Long precision) Precision can be used to constrain the maximum number of total digits allowed for NUMERIC or BIGNUMERIC types.Scale can be used to constrain the maximum number of digits in the fractional part of a NUMERIC or BIGNUMERIC type.setType
(LegacySQLTypeName type, Field... subFields) Sets the type of the field.setType
(LegacySQLTypeName type, FieldList subFields) Sets the type of the field.setType
(StandardSQLTypeName type, Field... subFields) Sets the type of the field.setType
(StandardSQLTypeName type, FieldList subFields) Sets the type of the field.
-
Method Details
-
setName
Sets the field name. The name must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_), and must start with a letter or underscore. The maximum length is 128 characters. -
setType
Sets the type of the field.- Parameters:
type
- BigQuery data typesubFields
- nested schema fields in case iftype
isLegacySQLTypeName.RECORD
, empty otherwise- Throws:
IllegalArgumentException
- iftype == LegacySQLTypeName.RECORD && subFields.length == 0
or iftype != LegacySQLTypeName.RECORD && subFields.length != 0
- See Also:
-
setType
Sets the type of the field.- Parameters:
type
- BigQuery data typesubFields
- nested schema fields in case iftype
isStandardSQLTypeName.STRUCT
, empty otherwise- Throws:
IllegalArgumentException
- iftype == StandardSQLTypeName.STRUCT && subFields.length == 0
or iftype != StandardSQLTypeName.STRUCT && subFields.length != 0
- See Also:
-
setType
Sets the type of the field.- Parameters:
type
- BigQuery data typesubFields
- nested schema fields, in case iftype
isLegacySQLTypeName.RECORD
,null
otherwise.- Throws:
IllegalArgumentException
- iftype == LegacySQLTypeName.RECORD && (subFields == null || subFields.isEmpty())
or iftype != LegacySQLTypeName.RECORD && subFields != null
- See Also:
-
setType
Sets the type of the field.- Parameters:
type
- BigQuery data typesubFields
- nested schema fields in case iftype
isStandardSQLTypeName.STRUCT
, empty otherwise- Throws:
IllegalArgumentException
- iftype == StandardSQLTypeName.STRUCT && subFields.length == 0
or iftype != StandardSQLTypeName.STRUCT && subFields.length != 0
- See Also:
-
setMode
Sets the mode of the field. When not specifiedField.Mode.NULLABLE
is used. -
setDescription
Sets the field description. The maximum length is 16K characters. -
setPolicyTags
Sets the policy tags for the field. -
setMaxLength
Sets the maximum length of the field for STRING or BYTES type.It is invalid to set value for types other than STRING or BYTES.
For STRING type, this represents the maximum UTF-8 length of strings allowed in the field. For BYTES type, this represents the maximum number of bytes in the field.
-
setScale
Scale can be used to constrain the maximum number of digits in the fractional part of a NUMERIC or BIGNUMERIC type. If the Scale value is set, the Precision value must be set as well. It is invalid to set values for Scale for types other than NUMERIC or BIGNUMERIC. See the Precision field for additional guidance about valid values. -
setPrecision
Precision can be used to constrain the maximum number of total digits allowed for NUMERIC or BIGNUMERIC types. It is invalid to set values for Precision for types other than // NUMERIC or BIGNUMERIC. For NUMERIC type, acceptable values for Precision must be: 1 ≤ (Precision - Scale) ≤ 29. Values for Scale must be: 0 ≤ Scale ≤ 9. For BIGNUMERIC type, acceptable values for Precision must be: 1 ≤ (Precision - Scale) ≤ 38. Values for Scale must be: 0 ≤ Scale ≤ 38. -
setDefaultValueExpression
DefaultValueExpression is used to specify the default value of a field using a SQL expression. It can only be set for top level fields (columns).You can use struct or array expression to specify default value for the entire struct or array. The valid SQL expressions are:
Literals for all data types, including STRUCT and ARRAY. The following functions: - CURRENT_TIMESTAMP - CURRENT_TIME - CURRENT_DATE - CURRENT_DATETIME - GENERATE_UUID - RAND - SESSION_USER - ST_GEOGPOINT Struct or array composed with the above allowed functions, for example: "[CURRENT_DATE(), DATE '2020-01-01']"
-
setCollation
Optional. Field collation can be set only when the type of field is STRING. The following values are supported:* 'und:ci': undetermined locale, case insensitive. * '': empty string. Default to case-sensitive behavior. (-- A wrapper is used here because it is possible to set the value to the empty string. --)
-
build
Creates aField
object.
-