Java Code Examples for com.google.api.services.bigquery.model.TableFieldSchema#setDescription()
The following examples show how to use
com.google.api.services.bigquery.model.TableFieldSchema#setDescription() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BigQueryUtils.java From beam with Apache License 2.0 | 5 votes |
private static List<TableFieldSchema> toTableFieldSchema(Schema schema) { List<TableFieldSchema> fields = new ArrayList<>(schema.getFieldCount()); for (Field schemaField : schema.getFields()) { FieldType type = schemaField.getType(); TableFieldSchema field = new TableFieldSchema().setName(schemaField.getName()); if (schemaField.getDescription() != null && !"".equals(schemaField.getDescription())) { field.setDescription(schemaField.getDescription()); } if (!schemaField.getType().getNullable()) { field.setMode(Mode.REQUIRED.toString()); } if (type.getTypeName().isCollectionType()) { type = type.getCollectionElementType(); if (type.getTypeName().isCollectionType() || type.getTypeName().isMapType()) { throw new IllegalArgumentException("Array of collection is not supported in BigQuery."); } field.setMode(Mode.REPEATED.toString()); } if (TypeName.ROW == type.getTypeName()) { Schema subType = type.getRowSchema(); field.setFields(toTableFieldSchema(subType)); } if (TypeName.MAP == type.getTypeName()) { throw new IllegalArgumentException("Maps are not supported in BigQuery."); } field.setType(toStandardSQLTypeName(type).toString()); fields.add(field); } return fields; }
Example 2
Source File: FieldSchemaListBuilder.java From bigquery-etl-dataflow-sample with Apache License 2.0 | 3 votes |
/** * Creates a TableFieldSchema with all of the parameters * @param type - the datatype @see https://cloud.google.com/bigquery/data-types * @param name - the name of the field * @param mode - the mode of the field * @param description - a description of the field to create. * @see https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/java/latest/com/google/api/services/bigquery/model/TableFieldSchema.html * @return */ public TableFieldSchema fieldSchema(String type, String name, String mode, String description) { TableFieldSchema tfs = new TableFieldSchema(); tfs.setType(type); tfs.setName(name); tfs.setMode(mode); tfs.setDescription(description); return tfs; }