public interface SqlType<T> extends Serializable
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.
Implements
SerializableType Parameter |
|
---|---|
Name | Description |
T |
Static Methods
<Elem>arrayOf(SqlType<Elem> elemType)
public static SqlType.Array<Elem> <Elem>arrayOf(SqlType<Elem> elemType)
returns a SqlType for an ARRAY
with elements of type elemType
Parameter | |
---|---|
Name | Description |
elemType |
SqlType<Elem> |
Returns | |
---|---|
Type | Description |
Array<Elem> |
<K,V>mapOf(SqlType<K> keyType, SqlType<V> valType)
public static SqlType.Map<K,V> <K,V>mapOf(SqlType<K> keyType, SqlType<V> valType)
returns a SqlType for a @code MAP} with keys of type keyType
and values of type
valType
Parameters | |
---|---|
Name | Description |
keyType |
SqlType<K> |
valType |
SqlType<V> |
Returns | |
---|---|
Type | Description |
Map<K,V> |
bool()
public static SqlType<Boolean> bool()
returns a SqlType for the BOOL
type.
Returns | |
---|---|
Type | Description |
SqlType<Boolean> |
bytes()
public static SqlType<ByteString> bytes()
returns a SqlType for the BYTES
type.
Returns | |
---|---|
Type | Description |
SqlType<ByteString> |
date()
public static SqlType<Date> date()
returns a SqlType for the DATE
type.
Returns | |
---|---|
Type | Description |
SqlType<com.google.cloud.Date> |
float32()
public static SqlType<Float> float32()
returns a SqlType for the FLOAT32
type.
Returns | |
---|---|
Type | Description |
SqlType<Float> |
float64()
public static SqlType<Double> float64()
returns a SqlType for the FLOAT64
type.
Returns | |
---|---|
Type | Description |
SqlType<Double> |
fromProto(Type proto)
public static SqlType<?> fromProto(Type proto)
Creates a SqlType from the protobuf representation of Types.
This is considered an internal implementation detail and not meant to be used by applications.
Parameter | |
---|---|
Name | Description |
proto |
com.google.bigtable.v2.Type |
Returns | |
---|---|
Type | Description |
SqlType<?> |
historicalMap()
public static SqlType.Map<ByteString,List<Struct>> historicalMap()
returns the SqlType for the type returned for column families in with_history
queries. This is equivalent to SqlType.mapOf(SqlType.bytes(),
SqlType.arrayOf(SqlType.struct()))
Returns | |
---|---|
Type | Description |
Map<ByteString,List<Struct>> |
int64()
public static SqlType<Long> int64()
returns a SqlType for the INT64
type.
Returns | |
---|---|
Type | Description |
SqlType<Long> |
string()
public static SqlType<String> string()
returns a SqlType for the STRING
type.
Returns | |
---|---|
Type | Description |
SqlType<String> |
struct()
public static SqlType.Struct struct()
returns a fake 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()));
Returns | |
---|---|
Type | Description |
SqlType.Struct |
timestamp()
public static SqlType<Instant> timestamp()
returns a SqlType for the TIMESTAMP
type.
Returns | |
---|---|
Type | Description |
SqlType<Instant> |
typesMatch(SqlType<?> left, SqlType<?> right)
public static boolean typesMatch(SqlType<?> left, SqlType<?> right)
This can be used to check whether com.google.cloud.bigtable.data.v2.models.sql.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.
Parameters | |
---|---|
Name | Description |
left |
SqlType<?> |
right |
SqlType<?> |
Returns | |
---|---|
Type | Description |
boolean |
Methods
getCode()
public abstract SqlType.Code getCode()
Returns | |
---|---|
Type | Description |
SqlType.Code |
Code enum for this type |