Interface SqlType<T> (2.66.0)

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

Serializable

Type 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>

<T>enumOf(Function<Integer,T> method)

public static SqlType.Enum<T> <T>enumOf(Function<Integer,T> method)

Returns a SqlType for a protobuf enum.

Parameter
Name Description
method Function<java.lang.Integer,T>

a function to convert an integer to the enum value. This is usually MyEnum::forNumber

Returns
Type Description
Enum<T>

<T>protoOf(T message)

public static SqlType.Proto<T> <T>protoOf(T message)

Returns a SqlType for a protobuf message.

Parameter
Name Description
message T

an instance of the message. MyMessage.getDefaultInstance() can be used.

Returns
Type Description
Proto<T>

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<?>

getUnqualifiedName(String fullName)

public static String getUnqualifiedName(String fullName)

Extracts the unqualified name from a fully qualified proto message or enum name. For example, "my.package.MyMessage" becomes "MyMessage".

This is considered an internal implementation detail and not meant to be used by applications.

Parameter
Name Description
fullName String
Returns
Type Description
String

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