Java Code Examples for com.google.cloud.bigquery.LegacySQLTypeName#TIMESTAMP
The following examples show how to use
com.google.cloud.bigquery.LegacySQLTypeName#TIMESTAMP .
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 nifi with Apache License 2.0 | 6 votes |
public static Field mapToField(Map fMap) { String typeStr = fMap.get("type").toString(); String nameStr = fMap.get("name").toString(); String modeStr = fMap.get("mode").toString(); LegacySQLTypeName type = null; if (typeStr.equals("BOOLEAN")) { type = LegacySQLTypeName.BOOLEAN; } else if (typeStr.equals("STRING")) { type = LegacySQLTypeName.STRING; } else if (typeStr.equals("BYTES")) { type = LegacySQLTypeName.BYTES; } else if (typeStr.equals("INTEGER")) { type = LegacySQLTypeName.INTEGER; } else if (typeStr.equals("FLOAT")) { type = LegacySQLTypeName.FLOAT; } else if (typeStr.equals("TIMESTAMP") || typeStr.equals("DATE") || typeStr.equals("TIME") || typeStr.equals("DATETIME")) { type = LegacySQLTypeName.TIMESTAMP; } else if (typeStr.equals("RECORD")) { type = LegacySQLTypeName.RECORD; } return Field.newBuilder(nameStr, type).setMode(Field.Mode.valueOf(modeStr)).build(); }
Example 2
Source File: BigQueryExample.java From google-cloud-java with Apache License 2.0 | 5 votes |
static Schema parseSchema(String[] args, int start, int end) { List<Field> schemaFields = new ArrayList<>(); for (int i = start; i < end; i++) { String[] fieldsArray = args[i].split(":"); if (fieldsArray.length != 2) { throw new IllegalArgumentException("Unrecognized field definition '" + args[i] + "'."); } String fieldName = fieldsArray[0]; String typeString = fieldsArray[1].toLowerCase(); LegacySQLTypeName fieldType; switch (typeString) { case "string": fieldType = LegacySQLTypeName.STRING; break; case "integer": fieldType = LegacySQLTypeName.INTEGER; break; case "timestamp": fieldType = LegacySQLTypeName.TIMESTAMP; break; case "float": fieldType = LegacySQLTypeName.FLOAT; break; case "boolean": fieldType = LegacySQLTypeName.BOOLEAN; break; case "bytes": fieldType = LegacySQLTypeName.BYTES; break; default: throw new IllegalArgumentException("Unrecognized field type '" + typeString + "'."); } schemaFields.add(Field.of(fieldName, fieldType)); } return Schema.of(schemaFields); }
Example 3
Source File: BQTableDefinition.java From beast with Apache License 2.0 | 4 votes |
private boolean isTimePartitionedField(Field partitionField) { return partitionField.getType() == LegacySQLTypeName.TIMESTAMP || partitionField.getType() == LegacySQLTypeName.DATE; }