in backend/schema/updater/ddl_type_conversion.cc [299:352]
ddl::ColumnDefinition GoogleSqlTypeToDDLColumnType(
const zetasql::Type* type) {
ddl::ColumnDefinition ddl_column_def;
if (type->IsArray()) {
ddl_column_def.set_type(ddl::ColumnDefinition::ARRAY);
*ddl_column_def.mutable_array_subtype() =
GoogleSqlTypeToDDLColumnType(type->AsArray()->element_type());
return ddl_column_def;
}
if (type->IsStruct()) {
ddl_column_def.set_type(ddl::ColumnDefinition::STRUCT);
*ddl_column_def.mutable_type_definition() = GoogleSqlTypeToDDLType(type);
return ddl_column_def;
}
ddl_column_def.set_type(ddl::ColumnDefinition::NONE);
if (type->IsDouble()) ddl_column_def.set_type(ddl::ColumnDefinition::DOUBLE);
if (type->IsFloat()) ddl_column_def.set_type(ddl::ColumnDefinition::FLOAT);
if (type->IsInt64()) ddl_column_def.set_type(ddl::ColumnDefinition::INT64);
if (type->IsBool()) ddl_column_def.set_type(ddl::ColumnDefinition::BOOL);
if (type->IsString()) ddl_column_def.set_type(ddl::ColumnDefinition::STRING);
if (type->IsBytes()) ddl_column_def.set_type(ddl::ColumnDefinition::BYTES);
if (type->IsTimestamp())
ddl_column_def.set_type(ddl::ColumnDefinition::TIMESTAMP);
if (type->IsDate()) ddl_column_def.set_type(ddl::ColumnDefinition::DATE);
if (type->IsNumericType())
ddl_column_def.set_type(ddl::ColumnDefinition::NUMERIC);
if (type->IsJson()) ddl_column_def.set_type(ddl::ColumnDefinition::JSON);
if (type->IsTokenList())
ddl_column_def.set_type(ddl::ColumnDefinition::TOKENLIST);
if (type->IsInterval())
ddl_column_def.set_type(ddl::ColumnDefinition::INTERVAL);
if (type->IsProto()) {
ddl_column_def.set_type(ddl::ColumnDefinition::NONE);
ddl_column_def.set_proto_type_name(
type->AsProto()->descriptor()->full_name());
}
if (type->IsEnum()) {
ddl_column_def.set_type(ddl::ColumnDefinition::NONE);
ddl_column_def.set_proto_type_name(
type->AsEnum()->enum_descriptor()->full_name());
}
if (type->IsExtendedType()) {
if (type->Equals(postgres_translator::spangres::types::PgNumericMapping()
->mapped_type())) {
ddl_column_def.set_type(ddl::ColumnDefinition::PG_NUMERIC);
} else if (type->Equals(
postgres_translator::spangres::types::PgJsonbMapping()
->mapped_type())) {
ddl_column_def.set_type(ddl::ColumnDefinition::PG_JSONB);
}
}
return ddl_column_def;
}