Skip to main content

Data Types

Fluss TypeRust TypeGetterSetter
BOOLEANboolget_boolean()set_field(idx, bool)
TINYINTi8get_byte()set_field(idx, i8)
SMALLINTi16get_short()set_field(idx, i16)
INTi32get_int()set_field(idx, i32)
BIGINTi64get_long()set_field(idx, i64)
FLOATf32get_float()set_field(idx, f32)
DOUBLEf64get_double()set_field(idx, f64)
CHAR&strget_char(idx, length)set_field(idx, &str)
STRING&strget_string()set_field(idx, &str)
DECIMALDecimalget_decimal(idx, precision, scale)set_field(idx, Decimal)
DATEDateget_date()set_field(idx, Date)
TIMETimeget_time()set_field(idx, Time)
TIMESTAMPTimestampNtzget_timestamp_ntz(idx, precision)set_field(idx, TimestampNtz)
TIMESTAMP_LTZTimestampLtzget_timestamp_ltz(idx, precision)set_field(idx, TimestampLtz)
BYTES&[u8]get_bytes()set_field(idx, &[u8])
BINARY(n)&[u8]get_binary(idx, length)set_field(idx, &[u8])

Constructing Special Types

Primitive types (bool, i8, i16, i32, i64, f32, f64, &str, &[u8]) can be passed directly to set_field. The following types require explicit construction:

use fluss::row::{Date, Time, TimestampNtz, TimestampLtz, Decimal};

// Date: days since Unix epoch
let date = Date::new(19738);

// Time: milliseconds since midnight
let time = Time::new(43200000);

// Timestamp without timezone: milliseconds since epoch
// DataTypes::timestamp() defaults to precision 6 (microseconds).
// Use DataTypes::timestamp_with_precision(p) for a different precision (0–9).
let ts = TimestampNtz::new(1704067200000);

// Timestamp with local timezone: milliseconds since epoch
// DataTypes::timestamp_ltz() also defaults to precision 6.
let ts_ltz = TimestampLtz::new(1704067200000);

// Decimal: from an unscaled long value with precision and scale
let decimal = Decimal::from_unscaled_long(12345, 10, 2)?; // represents 123.45

Creating Rows from Data

GenericRow::from_data accepts a Vec<Datum>. Because multiple crates implement From<&str>, Rust cannot infer the target type from .into() alone. Annotate the vector type explicitly:

use fluss::row::{Datum, GenericRow};

let data: Vec<Datum> = vec![1i32.into(), "hello".into(), Datum::Null];
let row = GenericRow::from_data(data);

Reading Row Data

use fluss::row::InternalRow;

for record in scan_records {
let row = record.row();

if row.is_null_at(0)? {
// field is null
}
let id: i32 = row.get_int(0)?;
let name: &str = row.get_string(1)?;
let score: f32 = row.get_float(2)?;
let date: Date = row.get_date(3)?;
let ts: TimestampNtz = row.get_timestamp_ntz(4, 6)?;
let decimal: Decimal = row.get_decimal(5, 10, 2)?;
}