Interface PqVariant
public interface PqVariant
Variant value — the top-level accessor for a Parquet column annotated with
the VARIANT logical type. A Variant carries the canonical two-part binary
encoding (metadata(), value()) plus a type tag (type()), and exposes
tag-specific extraction through the as*() methods.
PqVariant v = row.getVariant("event");
if (v.type() == VariantType.OBJECT) {
PqVariantObject obj = v.asObject();
String userId = obj.getString("user_id");
}
Every nested Variant sub-value (array element, object field value) is itself
a PqVariant, so navigation composes naturally.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionasArray()Unwrap as a Variant array view for indexed element access.byte[]asBinary()Extract opaque binary bytes.booleanExtract a boolean.asDate()Extract a date (days since Unix epoch).Extract a decimal.doubleasDouble()Extract a double.floatasFloat()Extract a float.intasInt()Extract an int.longasLong()Extract a long.asObject()Unwrap as a Variant object view for name-based field navigation.asString()Extract a UTF-8 string.asTime()Extract a time of day.Extract a timestamp.asUuid()Extract a UUID (16 bytes, big-endian).booleanisNull()True ifftype()isVariantType.NULL.byte[]metadata()The canonical Variant metadata bytes.type()The Variant type tag decoded from the value header.byte[]value()The canonical Variant value bytes.
-
Method Details
-
metadata
byte[] metadata()The canonical Variant metadata bytes. -
value
byte[] value()The canonical Variant value bytes. -
type
VariantType type()The Variant type tag decoded from the value header. -
isNull
boolean isNull()True ifftype()isVariantType.NULL. -
asBoolean
boolean asBoolean()Extract a boolean. RequiresVariantType.BOOLEAN_TRUEorVariantType.BOOLEAN_FALSE.- Throws:
VariantTypeException- if the type is not a boolean
-
asInt
int asInt()Extract an int. Narrows INT8/INT16/INT32 values.- Throws:
VariantTypeException- if the type is not INT8/INT16/INT32
-
asLong
long asLong()Extract a long. Accepts INT8/INT16/INT32/INT64.- Throws:
VariantTypeException- if the type is not an integer
-
asFloat
float asFloat()Extract a float.- Throws:
VariantTypeException- if the type is notVariantType.FLOAT
-
asDouble
double asDouble()Extract a double.- Throws:
VariantTypeException- if the type is notVariantType.DOUBLE
-
asString
String asString()Extract a UTF-8 string. Accepts both the short-string encoding and the primitive STRING encoding.- Throws:
VariantTypeException- if the type is not a string
-
asBinary
byte[] asBinary()Extract opaque binary bytes.- Throws:
VariantTypeException- if the type is notVariantType.BINARY
-
asDecimal
BigDecimal asDecimal()Extract a decimal. Accepts DECIMAL4/DECIMAL8/DECIMAL16.- Throws:
VariantTypeException- if the type is not a decimal
-
asDate
LocalDate asDate()Extract a date (days since Unix epoch).- Throws:
VariantTypeException- if the type is notVariantType.DATE
-
asTime
LocalTime asTime()Extract a time of day.- Throws:
VariantTypeException- if the type is notVariantType.TIME_NTZ
-
asTimestamp
Instant asTimestamp()Extract a timestamp. Accepts TIMESTAMP/TIMESTAMP_NTZ (micros) and TIMESTAMP_NANOS/TIMESTAMP_NTZ_NANOS (nanos).- Throws:
VariantTypeException- if the type is not a timestamp
-
asUuid
UUID asUuid()Extract a UUID (16 bytes, big-endian).- Throws:
VariantTypeException- if the type is notVariantType.UUID
-
asObject
PqVariantObject asObject()Unwrap as a Variant object view for name-based field navigation.- Throws:
VariantTypeException- if the type is notVariantType.OBJECT
-
asArray
PqVariantArray asArray()Unwrap as a Variant array view for indexed element access.- Throws:
VariantTypeException- if the type is notVariantType.ARRAY
-