T - the corresponding java typepublic interface SqlType<T> extends Serializable
Complex types (SqlType.Map, SqlType.Array, & SqlType.Struct provide
additional information about the schema of the type.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
SqlType.Array<Elem>
Represents an array type in SQL.
|
static class |
SqlType.Code |
static interface |
SqlType.Enum<T extends com.google.protobuf.ProtocolMessageEnum>
Represents a protobuf enum type in SQL.
|
static interface |
SqlType.Map<K,V>
Represents a map type in SQL.
|
static interface |
SqlType.Proto<T extends com.google.protobuf.AbstractMessage>
Represents a protobuf message type in SQL.
|
static interface |
SqlType.Struct
Represents a struct type in SQL.
|
| Modifier and Type | Method and Description |
|---|---|
static <Elem> SqlType.Array<Elem> |
arrayOf(SqlType<Elem> elemType)
|
static SqlType<Boolean> |
bool()
returns a
SqlType for the BOOL type. |
static SqlType<com.google.protobuf.ByteString> |
bytes()
returns a
SqlType for the BYTES type. |
static SqlType<com.google.cloud.Date> |
date()
returns a
SqlType for the DATE type. |
static <T extends com.google.protobuf.ProtocolMessageEnum> |
enumOf(Function<Integer,T> method)
Returns a
SqlType for a protobuf enum. |
static SqlType<Float> |
float32()
returns a
SqlType for the FLOAT32 type. |
static SqlType<Double> |
float64()
returns a
SqlType for the FLOAT64 type. |
static SqlType<?> |
fromProto(Type proto)
Creates a
SqlType from the protobuf representation of Types. |
SqlType.Code |
getCode() |
static String |
getUnqualifiedName(String fullName)
Extracts the unqualified name from a fully qualified proto message or enum name.
|
static SqlType.Map<com.google.protobuf.ByteString,List<Struct>> |
historicalMap()
returns the
SqlType for the type returned for column families in with_history
queries. |
static SqlType<Long> |
int64()
returns a
SqlType for the INT64 type. |
static <K,V> SqlType.Map<K,V> |
mapOf(SqlType<K> keyType,
SqlType<V> valType)
|
static <T extends com.google.protobuf.AbstractMessage> |
protoOf(T message)
Returns a
SqlType for a protobuf message. |
static SqlType<String> |
string()
returns a
SqlType for the STRING type. |
static SqlType.Struct |
struct()
returns a fake
STRUCT type for use on in StructReader methods that require a
SqlType to validate against. |
static SqlType<Instant> |
timestamp()
returns a
SqlType for the TIMESTAMP type. |
static boolean |
typesMatch(SqlType<?> left,
SqlType<?> right)
This can be used to check whether
StructReader get calls are being called for the
correct type when compared to the schema. |
SqlType.Code getCode()
SqlType.Code enum for this typestatic SqlType.Struct struct()
STRUCT type for use on in StructReader methods that require a
SqlType to validate against. This does not specify a schema because the struct schem
will be validated on calls to the structs data accessors.
Attempts to access the schema of a struct created this way will throw exceptions.
Example usage:
List<Struct> structList = resultSet.getList("column", SqlType.arrayOf(SqlType.struct()));
static <Elem> SqlType.Array<Elem> arrayOf(SqlType<Elem> elemType)
static <K,V> SqlType.Map<K,V> mapOf(SqlType<K> keyType, SqlType<V> valType)
static SqlType.Map<com.google.protobuf.ByteString,List<Struct>> historicalMap()
SqlType for the type returned for column families in with_history
queries. This is equivalent to SqlType.mapOf(SqlType.bytes(),
SqlType.arrayOf(SqlType.struct()))@BetaApi(value="This feature is currently experimental and can change in the future") static <T extends com.google.protobuf.AbstractMessage> SqlType.Proto<T> protoOf(T message)
SqlType for a protobuf message.T - the message typemessage - an instance of the message. MyMessage.getDefaultInstance() can be used.@BetaApi(value="This feature is currently experimental and can change in the future") static <T extends com.google.protobuf.ProtocolMessageEnum> SqlType.Enum<T> enumOf(Function<Integer,T> method)
SqlType for a protobuf enum.T - the enum typemethod - a function to convert an integer to the enum value. This is usually MyEnum::forNumber@InternalApi static String getUnqualifiedName(String fullName)
This is considered an internal implementation detail and not meant to be used by applications.
@InternalApi static SqlType<?> fromProto(Type proto)
SqlType from the protobuf representation of Types.
This is considered an internal implementation detail and not meant to be used by applications.
@InternalApi static boolean typesMatch(SqlType<?> left, SqlType<?> right)
StructReader get calls are being called for the
correct type when compared to the schema. This is different that equals because we do not
require users to specify the full struct schema for struct get calls. This is safe because the
struct schema will be validated on calls to the struct.
This is considered an internal implementation detail and not meant to be used by applications.
Copyright © 2026 Google LLC. All rights reserved.