Interface SqlType<T>
- Type Parameters:
T- the corresponding java type
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
SqlType.Array<Elem>,SqlType.Map<K,,V> SqlType.Struct
- All Known Implementing Classes:
Type.Array,Type.Bool,Type.Bytes,Type.Date,Type.Float32,Type.Float64,Type.Int64,Type.Map,Type.SchemalessStruct,Type.String,Type.StructWithSchema,Type.Timestamp
Represents a data type in a SQL query.
Complex types (SqlType.Map, SqlType.Array, & SqlType.Struct provide
additional information about the schema of the type.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents an array type in SQL.static enumstatic interfaceRepresents a map type in SQL.static interfaceRepresents a struct type in SQL. -
Method Summary
Modifier and TypeMethodDescriptionstatic <Elem> SqlType.Array<Elem>bool()returns aSqlTypefor theBOOLtype.static SqlType<com.google.protobuf.ByteString>bytes()returns aSqlTypefor theBYTEStype.static SqlType<com.google.cloud.Date>date()returns aSqlTypefor theDATEtype.float32()returns aSqlTypefor theFLOAT32type.float64()returns aSqlTypefor theFLOAT64type.static SqlType<?>Creates aSqlTypefrom the protobuf representation of Types.getCode()static SqlType.Map<com.google.protobuf.ByteString,List<Struct>> returns theSqlTypefor the type returned for column families inwith_historyqueries.int64()returns aSqlTypefor theINT64type.static <K,V> SqlType.Map<K, V> string()returns aSqlTypefor theSTRINGtype.static SqlType.Structstruct()returns a fakeSTRUCT typefor use on inStructReadermethods that require aSqlTypeto validate against.returns aSqlTypefor theTIMESTAMPtype.static booleantypesMatch(SqlType<?> left, SqlType<?> right) This can be used to check whetherStructReaderget calls are being called for the correct type when compared to the schema.
-
Method Details
-
getCode
SqlType.Code getCode()- Returns:
SqlType.Codeenum for this type
-
bytes
returns aSqlTypefor theBYTEStype. -
string
returns aSqlTypefor theSTRINGtype. -
int64
returns aSqlTypefor theINT64type. -
float64
returns aSqlTypefor theFLOAT64type. -
float32
returns aSqlTypefor theFLOAT32type. -
bool
returns aSqlTypefor theBOOLtype. -
timestamp
returns aSqlTypefor theTIMESTAMPtype. -
date
returns aSqlTypefor theDATEtype. -
struct
returns a fakeSTRUCT typefor use on inStructReadermethods that require aSqlTypeto 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())); -
arrayOf
-
mapOf
-
historicalMap
returns theSqlTypefor the type returned for column families inwith_historyqueries. This is equivalent toSqlType.mapOf(SqlType.bytes(), SqlType.arrayOf(SqlType.struct())) -
fromProto
Creates aSqlTypefrom the protobuf representation of Types.This is considered an internal implementation detail and not meant to be used by applications.
-
typesMatch
This can be used to check whetherStructReaderget 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.
-