sparkling/types
Types
DateTime64 with configurable precision and timezone.
Precision: 0-9 digits after decimal point (subsecond precision) Timezone: optional timezone identifier (e.g., “UTC”, “America/New_York”) Examples: docs/examples/types_examples.md
pub type DateTime64 {
DateTime64(
value: String,
precision: Int,
timezone: option.Option(String),
)
}
Constructors
-
DateTime64( value: String, precision: Int, timezone: option.Option(String), )Arguments
- value
-
ISO 8601 timestamp or epoch string
- precision
-
Precision (0-9 for subsecond digits)
- timezone
-
Optional timezone identifier
Decimal value with precision and scale preservation.
Stored as string to avoid floating-point precision loss. Use helper functions to convert to/from numeric types when needed. Examples: docs/examples/types_examples.md
pub opaque type Decimal
pub type Enum16 {
Enum16(mappings: List(#(String, Int)))
}
Constructors
-
Enum16(mappings: List(#(String, Int)))
Enum8/Enum16 type mapping
Maps string values to integer codes. Examples: docs/examples/types_examples.md
pub type Enum8 {
Enum8(mappings: List(#(String, Int)))
}
Constructors
-
Enum8(mappings: List(#(String, Int)))
LowCardinality wrapper for values with low cardinality.
This is a performance hint to ClickHouse for storage optimization. In Gleam, we wrap the value with its type information. Examples: docs/examples/types_examples.md
pub opaque type LowCardinality
Values
pub fn datetime64(
value: String,
precision: Int,
timezone: option.Option(String),
) -> Result(DateTime64, String)
Create a DateTime64 from ISO 8601 string
pub fn datetime64_from_epoch(
epoch_seconds: Int,
precision: Int,
timezone: option.Option(String),
) -> Result(DateTime64, String)
Create a DateTime64 from Unix epoch (seconds)
pub fn datetime64_timezone(
dt: DateTime64,
) -> option.Option(String)
Get the timezone of a DateTime64
pub fn datetime64_to_string(dt: DateTime64) -> String
Get the string representation of a DateTime64
pub fn decimal(value: String) -> Result(Decimal, String)
Create a Decimal from a string representation
pub fn decimal_from_float(value: Float) -> Decimal
Create a Decimal from a float (may lose precision)
pub fn decimal_from_int(value: Int) -> Decimal
Create a Decimal from an integer
pub fn decimal_to_string(d: Decimal) -> String
Get the string representation of a Decimal
pub fn enum16_from_string(
mappings: List(#(String, Int)),
value: String,
) -> Result(Int, String)
Create an Enum16 from string value
pub fn enum8_from_string(
mappings: List(#(String, Int)),
value: String,
) -> Result(Int, String)
Create an Enum8 from string value
pub fn low_cardinality_string(value: String) -> LowCardinality
Create a LowCardinality from a string value
pub fn low_cardinality_value(lc: LowCardinality) -> String
Get the value from a LowCardinality wrapper
pub fn uuid(value: String) -> Result(UUID, String)
Create a UUID from string representation