Package com.google.cloud.bigquery
Class QueryParameterValue
- java.lang.Object
-
- com.google.cloud.bigquery.QueryParameterValue
-
- All Implemented Interfaces:
Serializable
public abstract class QueryParameterValue extends Object implements Serializable
A value for a QueryParameter along with its type.A static factory method is provided for each of the possible types (e.g.
int64(Long)
for StandardSQLTypeName.INT64). Alternatively, an instance can be constructed by callingof(Object, Class)
with the value and a Class object, which will use these mappings:- Boolean: StandardSQLTypeName.BOOL
- String: StandardSQLTypeName.STRING
- Integer: StandardSQLTypeName.INT64
- Long: StandardSQLTypeName.INT64
- Double: StandardSQLTypeName.FLOAT64
- Float: StandardSQLTypeName.FLOAT64
- BigDecimal: StandardSQLTypeName.NUMERIC
- BigNumeric: StandardSQLTypeName.BIGNUMERIC
- JSON: StandardSQLTypeName.JSON
- INTERVAL: StandardSQLTypeName.INTERVAL
No other types are supported through that entry point. The other types can be created by calling
of(Object, StandardSQLTypeName)
with the value and a particular StandardSQLTypeName enum value.Struct parameters are currently not supported.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QueryParameterValue.Builder
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <T> QueryParameterValue
array(T[] array, StandardSQLTypeName type)
Creates aQueryParameterValue
object with a type of ARRAY the given array element type.static <T> QueryParameterValue
array(T[] array, Class<T> clazz)
Creates aQueryParameterValue
object with a type of ARRAY, and an array element type based on the given class.static QueryParameterValue
bigNumeric(BigDecimal value)
Creates aQueryParameterValue
object with a type of BIGNUMERIC.static QueryParameterValue
bool(Boolean value)
Creates aQueryParameterValue
object with a type of BOOL.static QueryParameterValue
bytes(byte[] value)
Creates aQueryParameterValue
object with a type of BYTES.static QueryParameterValue
date(String value)
Creates aQueryParameterValue
object with a type of DATE.static QueryParameterValue
dateTime(String value)
Creates aQueryParameterValue
object with a type of DATETIME.static QueryParameterValue
float64(Double value)
Creates aQueryParameterValue
object with a type of FLOAT64.static QueryParameterValue
float64(Float value)
Creates aQueryParameterValue
object with a type of FLOAT64.static QueryParameterValue
geography(String value)
Creates aQueryParameterValue
object with a type of GEOGRAPHY.abstract StandardSQLTypeName
getArrayType()
Returns the data type of the array elements.List<QueryParameterValue>
getArrayValues()
Returns the array values of this parameter.Map<String,QueryParameterValue>
getStructTypes()
Returns the data type of the struct elements.Map<String,QueryParameterValue>
getStructValues()
Returns the struct values of this parameter.abstract StandardSQLTypeName
getType()
Returns the data type of this parameter.abstract String
getValue()
Returns the value of this parameter.static QueryParameterValue
int64(Integer value)
Creates aQueryParameterValue
object with a type of INT64.static QueryParameterValue
int64(Long value)
Creates aQueryParameterValue
object with a type of INT64.static QueryParameterValue
interval(String value)
Creates aQueryParameterValue
object with a type of INTERVAL.static QueryParameterValue
interval(org.threeten.extra.PeriodDuration value)
Creates aQueryParameterValue
object with a type of INTERVAL.static QueryParameterValue
json(com.google.gson.JsonObject value)
Creates aQueryParameterValue
object with a type of JSON.static QueryParameterValue
json(String value)
Creates aQueryParameterValue
object with a type of JSON.static QueryParameterValue.Builder
newBuilder()
Returns a builder for theQueryParameterValue
object.static QueryParameterValue
numeric(BigDecimal value)
Creates aQueryParameterValue
object with a type of NUMERIC.static <T> QueryParameterValue
of(T value, StandardSQLTypeName type)
Creates aQueryParameterValue
object with the given value and type.static <T> QueryParameterValue
of(T value, Class<T> type)
Creates aQueryParameterValue
object with the given value and type.static QueryParameterValue
string(String value)
Creates aQueryParameterValue
object with a type of STRING.static QueryParameterValue
struct(Map<String,QueryParameterValue> struct)
Creates a map withQueryParameterValue
object and a type of STRUCT the given struct element type.static QueryParameterValue
time(String value)
Creates aQueryParameterValue
object with a type of TIME.static QueryParameterValue
timestamp(Long value)
Creates aQueryParameterValue
object with a type of TIMESTAMP.static QueryParameterValue
timestamp(String value)
Creates aQueryParameterValue
object with a type of TIMESTAMP.abstract QueryParameterValue.Builder
toBuilder()
Returns a builder for a QueryParameterValue object with given value.
-
-
-
Method Detail
-
getArrayValues
@Nullable public List<QueryParameterValue> getArrayValues()
Returns the array values of this parameter. The returned list, if not null, is immutable.
-
getStructValues
@Nullable public Map<String,QueryParameterValue> getStructValues()
Returns the struct values of this parameter. The returned map, if not null, is immutable.
-
getType
public abstract StandardSQLTypeName getType()
Returns the data type of this parameter.
-
getArrayType
@Nullable public abstract StandardSQLTypeName getArrayType()
Returns the data type of the array elements.
-
getStructTypes
@Nullable public Map<String,QueryParameterValue> getStructTypes()
Returns the data type of the struct elements.
-
of
public static <T> QueryParameterValue of(T value, Class<T> type)
Creates aQueryParameterValue
object with the given value and type. Note: this does not support BigNumeric
-
of
public static <T> QueryParameterValue of(T value, StandardSQLTypeName type)
Creates aQueryParameterValue
object with the given value and type.
-
bool
public static QueryParameterValue bool(Boolean value)
Creates aQueryParameterValue
object with a type of BOOL.
-
int64
public static QueryParameterValue int64(Long value)
Creates aQueryParameterValue
object with a type of INT64.
-
int64
public static QueryParameterValue int64(Integer value)
Creates aQueryParameterValue
object with a type of INT64.
-
float64
public static QueryParameterValue float64(Double value)
Creates aQueryParameterValue
object with a type of FLOAT64.
-
float64
public static QueryParameterValue float64(Float value)
Creates aQueryParameterValue
object with a type of FLOAT64.
-
numeric
public static QueryParameterValue numeric(BigDecimal value)
Creates aQueryParameterValue
object with a type of NUMERIC.
-
bigNumeric
public static QueryParameterValue bigNumeric(BigDecimal value)
Creates aQueryParameterValue
object with a type of BIGNUMERIC.
-
string
public static QueryParameterValue string(String value)
Creates aQueryParameterValue
object with a type of STRING.
-
geography
public static QueryParameterValue geography(String value)
Creates aQueryParameterValue
object with a type of GEOGRAPHY.
-
json
public static QueryParameterValue json(String value)
Creates aQueryParameterValue
object with a type of JSON. Currently, this is only supported in INSERT, not in query as a filter
-
json
public static QueryParameterValue json(com.google.gson.JsonObject value)
Creates aQueryParameterValue
object with a type of JSON. Currently, this is only supported in INSERT, not in query as a filter
-
bytes
public static QueryParameterValue bytes(byte[] value)
Creates aQueryParameterValue
object with a type of BYTES.
-
timestamp
public static QueryParameterValue timestamp(Long value)
Creates aQueryParameterValue
object with a type of TIMESTAMP.
-
timestamp
public static QueryParameterValue timestamp(String value)
Creates aQueryParameterValue
object with a type of TIMESTAMP. Must be in the format "yyyy-MM-dd HH:mm:ss.SSSSSSZZ", e.g. "2014-08-19 12:41:35.220000+00:00".
-
date
public static QueryParameterValue date(String value)
Creates aQueryParameterValue
object with a type of DATE. Must be in the format "yyyy-MM-dd", e.g. "2014-08-19".
-
time
public static QueryParameterValue time(String value)
Creates aQueryParameterValue
object with a type of TIME. Must be in the format "HH:mm:ss.SSSSSS", e.g. "12:41:35.220000".
-
dateTime
public static QueryParameterValue dateTime(String value)
Creates aQueryParameterValue
object with a type of DATETIME. Must be in the format "yyyy-MM-dd HH:mm:ss.SSSSSS", e.g. "2014-08-19 12:41:35.220000".
-
interval
public static QueryParameterValue interval(String value)
Creates aQueryParameterValue
object with a type of INTERVAL. Must be in the canonical format "[sign]Y-M [sign]D [sign]H:M:S[.F]", e.g. "123-7 -19 0:24:12.000006" or ISO 8601 duration format, e.g. "P123Y7M-19DT0H24M12.000006S"
-
interval
public static QueryParameterValue interval(org.threeten.extra.PeriodDuration value)
Creates aQueryParameterValue
object with a type of INTERVAL.
-
array
public static <T> QueryParameterValue array(T[] array, Class<T> clazz)
Creates aQueryParameterValue
object with a type of ARRAY, and an array element type based on the given class.
-
array
public static <T> QueryParameterValue array(T[] array, StandardSQLTypeName type)
Creates aQueryParameterValue
object with a type of ARRAY the given array element type.
-
struct
public static QueryParameterValue struct(Map<String,QueryParameterValue> struct)
Creates a map withQueryParameterValue
object and a type of STRUCT the given struct element type.
-
toBuilder
public abstract QueryParameterValue.Builder toBuilder()
Returns a builder for a QueryParameterValue object with given value.
-
newBuilder
public static QueryParameterValue.Builder newBuilder()
Returns a builder for theQueryParameterValue
object.
-
-