static Field fromPb(TableFieldSchema fieldSchemaPb) { Builder fieldBuilder = new Builder(); fieldBuilder.setName(fieldSchemaPb.getName()); if (fieldSchemaPb.getMode() != null) { fieldBuilder.setMode(Mode.valueOf(fieldSchemaPb.getMode())); } if (fieldSchemaPb.getDescription() != null) { fieldBuilder.setDescription(fieldSchemaPb.getDescription()); } FieldList subFields = fieldSchemaPb.getFields() != null ? FieldList.of(Lists.transform(fieldSchemaPb.getFields(), FROM_PB_FUNCTION)) : null; fieldBuilder.setType(LegacySQLTypeName.valueOf(fieldSchemaPb.getType()), subFields); return fieldBuilder.build(); } }
static Field fromPb(TableFieldSchema fieldSchemaPb) { Builder fieldBuilder = new Builder(); fieldBuilder.setName(fieldSchemaPb.getName()); if (fieldSchemaPb.getMode() != null) { fieldBuilder.setMode(Mode.valueOf(fieldSchemaPb.getMode())); } if (fieldSchemaPb.getDescription() != null) { fieldBuilder.setDescription(fieldSchemaPb.getDescription()); } FieldList subFields = fieldSchemaPb.getFields() != null ? FieldList.of(Lists.transform(fieldSchemaPb.getFields(), FROM_PB_FUNCTION)) : null; fieldBuilder.setType(LegacySQLTypeName.valueOf(fieldSchemaPb.getType()), subFields); return fieldBuilder.build(); } }
/** * Sets the type of the field. * * @param type BigQuery data type * @param subFields nested schema fields in case if {@code type} is {@link * LegacySQLTypeName#RECORD}, empty otherwise * @throws IllegalArgumentException if {@code type == LegacySQLTypeName.RECORD && * subFields.length == 0} or if {@code type != LegacySQLTypeName.RECORD && subFields.length * != 0} * @see <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types">Data * Types</a> */ public Builder setType(LegacySQLTypeName type, Field... subFields) { return setType(type, subFields.length > 0 ? FieldList.of(subFields) : null); }
/** Returns a builder for a Field object with given name and type. */ public static Builder newBuilder(String name, LegacySQLTypeName type, FieldList subFields) { return new Builder().setName(name).setType(type, subFields); }
/** Returns a builder for a Field object with given name and type. */ public static Builder newBuilder(String name, LegacySQLTypeName type, Field... subFields) { return new Builder().setName(name).setType(type, subFields); }
/** * Sets the type of the field. * * @param type BigQuery data type * @param subFields nested schema fields in case if {@code type} is {@link * LegacySQLTypeName#RECORD}, empty otherwise * @throws IllegalArgumentException if {@code type == LegacySQLTypeName.RECORD && * subFields.length == 0} or if {@code type != LegacySQLTypeName.RECORD && subFields.length * != 0} * @see <a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types">Data * Types</a> */ public Builder setType(LegacySQLTypeName type, Field... subFields) { return setType(type, subFields.length > 0 ? FieldList.of(subFields) : null); }
/** Returns a builder for a Field object with given name and type. */ public static Builder newBuilder(String name, LegacySQLTypeName type, Field... subFields) { return new Builder().setName(name).setType(type, subFields); }
/** Returns a builder for a Field object with given name and type. */ public static Builder newBuilder(String name, LegacySQLTypeName type, FieldList subFields) { return new Builder().setName(name).setType(type, subFields); }