Если вы получаете экземпляр com.google.cloud.bigquery.BigQuery
, вы можете получить типы ваших столбцов.Например, чтобы получить тип первого столбца:
BigQuery bigQuery = BigQueryOptions.newBuilder()
.setProjectId(projectId)
.setCredentials(...)
.build()
.getService();
bigQuery.getTable(id).getDefinition().getSchema().getFields().get(0).getType()
Это даст вам LegacySQLTypeName
.Согласно исходному коду, это то, что вы можете ожидать:
/** Variable-length binary data. */
public static final LegacySQLTypeName BYTES = type.createAndRegister("BYTES").setStandardType(StandardSQLTypeName.BYTES);
/** Variable-length character (Unicode) data. */
public static final LegacySQLTypeName STRING = type.createAndRegister("STRING").setStandardType(StandardSQLTypeName.STRING);
/** A 64-bit signed integer value. */
public static final LegacySQLTypeName INTEGER = type.createAndRegister("INTEGER").setStandardType(StandardSQLTypeName.INT64);
/** A 64-bit IEEE binary floating-point value. */
public static final LegacySQLTypeName FLOAT = type.createAndRegister("FLOAT").setStandardType(StandardSQLTypeName.FLOAT64);
/** A Boolean value (true or false). */
public static final LegacySQLTypeName BOOLEAN = type.createAndRegister("BOOLEAN").setStandardType(StandardSQLTypeName.BOOL);
/** Represents an absolute point in time, with microsecond precision. */
public static final LegacySQLTypeName TIMESTAMP = type.createAndRegister("TIMESTAMP").setStandardType(StandardSQLTypeName.TIMESTAMP);
/** Represents a logical calendar date. Note, support for this type is limited in legacy SQL. */
public static final LegacySQLTypeName DATE = type.createAndRegister("DATE").setStandardType(StandardSQLTypeName.DATE);
/**
* Represents a time, independent of a specific date, to microsecond precision. Note, support for
* this type is limited in legacy SQL.
*/
public static final LegacySQLTypeName TIME = type.createAndRegister("TIME").setStandardType(StandardSQLTypeName.TIME);
/**
* Represents a year, month, day, hour, minute, second, and subsecond (microsecond precision).
* Note, support for this type is limited in legacy SQL.
*/
public static final LegacySQLTypeName DATETIME = type.createAndRegister("DATETIME").setStandardType(StandardSQLTypeName.DATETIME);
/** A record type with a nested schema. */
public static final LegacySQLTypeName RECORD = type.createAndRegister("RECORD").setStandardType(StandardSQLTypeName.STRUCT);