The PartiQL data model for MoonBit, with a PartiQL-encoded Ion codec.
Dependencies
| Package | Alias | Content |
|---|---|---|
| moonrockz/partiql-value | @value | Value, Tuple, Bag, MapValue (RFC 0104), GraphValue (RFC 0025), Date, Time, Timestamp, IntervalYM, IntervalDT, and the relations ==, sql_equals, eqg, compare |
| moonrockz/partiql-value/ion | @partiql_ion | from_ion, to_ion (PartiQL-encoded Ion, as in partiql-tests); from_ion_data, to_ion_data (Ion-preserving: Ion data passes through exactly) |
| moonrockz/partiql-value/arbitrary | @arbitrary | quickcheck generators for property-based tests |
let bag = @value.Value::Bag(@value.Bag::new([@value.Value::Int(1L), @value.Value::Int(2L)]))
let same = @value.Value::Bag(@value.Bag::new([@value.Value::Int(2L), @value.Value::Int(1L)]))
@value.sql_equals(bag, same) // Bool(true): bags compare as multisets
// A tuple never holds MISSING: the constructor drops the pair.
let t = @value.Tuple::new([("a", @value.Value::Missing), ("b", @value.Value::Null)])
t.length() // 1
// Boxed Ion values compare by their lowered value: an Ion symbol equals a string.
let symbol = @value.Value::Ion(@ion_core.IonValue::symbol("hello"))
@value.sql_equals(symbol, @value.Value::String("hello")) // Bool(true)
// PartiQL-encoded Ion.
@partiql_ion.to_ion(bag) // $bag::[1, 2]| Relation | Use |
|---|---|
| == (Eq) | Structural identity: same case and contents; bags and tuples as multisets; decimal scale counts |
| sql_equals | The PartiQL = operator: MISSING beats NULL; numbers compare by value across types |
| eqg | Grouping equivalence: NULL eqg NULL, MISSING eqg MISSING, NaN eqg NaN |
| compare | The ORDER BY total order, with NullsFirst or NullsLast |
pub(all) enum Ends {
Directed(from~ : String, to~ : String)
Undirected(String, String)
} derive(Debug)impl Eq for GraphValuefn GraphValue::new(nodes : Array[GraphNode], edges : Array[GraphEdge]) -> GraphValue raise GraphErrorimpl Eq for IntervalDTfn IntervalDT::from_parts(negative~ : Bool, days~ : Int64, hours~ : Int64, minutes~ : Int64, seconds~ : Int64, nanos~ : Int64) -> IntervalDT raise IntervalErrorimpl Eq for IntervalYMfn IntervalYM::from_parts(negative~ : Bool, years~ : Int64, months~ : Int64) -> IntervalYM raise IntervalErrorpub struct Time {
hour : Int
minute : Int
second : Int
nanos : Int
precision : Int
offset : Int?
} derive(Debug)fn Time::new(hour~ : Int, minute~ : Int, second~ : Int, nanos? : Int, precision? : Int, offset? : Int?) -> Time raise DateTimeErrorpub(all) enum Value {
Null
Missing
Bool(Bool)
Int(Int64)
BigInt(BigInt)
Float(Double)
Decimal(Decimal)
String(String)
Clob(Bytes)
Blob(Bytes)
Date(Date)
Time(Time)
Timestamp(Timestamp)
IntervalYM(IntervalYM)
IntervalDT(IntervalDT)
List(Array[Value])
Bag(Bag)
Tuple(Tuple)
Map(MapValue)
Graph(GraphValue)
Ion(IonValue)
} derive(Debug)Install
Download zipThe PartiQL data model for MoonBit, with a PartiQL-encoded Ion codec.
Dependencies