in src/main/java/com/google/cloud/spanner/pgadapter/statements/CopyStatement.java [286:330]
static Type parsePostgreSQLDataType(String columnType) {
if (columnType.endsWith("[]")) {
try {
Type elementType =
parsePostgreSQLDataType(columnType.substring(0, columnType.length() - 2));
return Type.array(elementType);
} catch (IllegalArgumentException ignore) {
throw new IllegalArgumentException(
"Unrecognized or unsupported column data type: " + columnType);
}
}
// Eliminate size modifiers in column type (e.g. character varying(100), etc.)
int index = columnType.indexOf("(");
columnType = (index > 0) ? columnType.substring(0, index) : columnType;
switch (columnType) {
case "boolean":
return Type.bool();
case "bigint":
return Type.int64();
case "float4":
case "real":
return Type.float32();
case "float8":
case "double precision":
return Type.float64();
case "numeric":
return Type.pgNumeric();
case "bytea":
return Type.bytes();
case "character varying":
case "text":
return Type.string();
case "date":
return Type.date();
case "timestamptz":
case "timestamp with time zone":
return Type.timestamp();
case "jsonb":
return Type.pgJsonb();
default:
throw new IllegalArgumentException(
"Unrecognized or unsupported column data type: " + columnType);
}
}