Sign in

    moonrockz/partiql-eval/ops does not have a README file

    OpFailure

    pub(all) suberror OpFailure {
    TypeFailure(String)
    DataFailure(String)
    Unsupported(String)
    } derive(Eq,
    Debug
    )

    Why an operation on values failed. The interpreter adds the span and applies the mode rule (spec M4a §4): a TypeFailure is MISSING in permissive mode and a type error in strict mode; a DataFailure (a bad value of the right type, such as a division by zero) is an error in both. Unsupported marks a valid operation that this version does not evaluate (spec M4d2 §4.1).

    CastTarget

    pub(all) enum CastTarget {
    Any
    Bool
    Integer(IntWidth)
    Decimal(Scale)
    Float(FloatWidth)
    Text(TextKind)
    Clob
    Blob
    Date
    Time(precision~ : Int?, zone~ : Bool)
    Timestamp(precision~ : Int?, zone~ : Bool)
    Interval(
    IntervalQualifier
    )
    List
    Bag
    Tuple
    Map(key~ : CastTarget, key_type~ :
    MapType
    , value~ : CastTarget, value_type~ :
    MapType
    )
    } derive(Eq,
    Debug
    )

    The target of a CAST, resolved by lowering (spec M4d2 §3.1). Map keeps the targets of its keys and values and the declared map types, because a target cannot tell NUMERIC from DECIMAL and a MapType can.

    Clock

    pub(all) struct Clock {
    now : () ->
    ZonedDateTime
    raise
    }

    Where "now" comes from. The library never reads a wall clock: the composition root (the CLI's main) builds the real clock, and tests and embedders pass fixed or fake ones. now may raise; the evaluator turns a raise into a data error.

    Clock::fixed

    A clock that always gives at.

    FieldMatch

    pub(all) enum FieldMatch {
    NoField
    One(
    Value
    )
    Many(
    Value
    , count~ : Int)
    } derive(Eq,
    Debug
    )

    Matches in tuple declaration order; repeated fields never shadow.

    FloatWidth

    pub(all) enum FloatWidth {
    Real
    Double
    } derive(Eq,
    Debug
    )

    REAL (binary32) or DOUBLE PRECISION (binary64).

    IntWidth

    pub(all) enum IntWidth {
    Bits8
    Bits16
    Bits32
    Bits64
    } derive(Eq,
    Debug
    )

    The width of an integer target: TINYINT, SMALLINT, INT, BIGINT.

    Scale

    pub(all) enum Scale {
    Unconstrained
    Fixed(precision~ : Int, scale~ : Int)
    } derive(Eq,
    Debug
    )

    The scale of a DECIMAL target: a bare DECIMAL keeps the scale of the value (rounded to 38 digits); DECIMAL(p, s) has scale s.

    TextKind

    pub(all) enum TextKind {
    Char(Int)
    Varchar(Int)
    String
    } derive(Eq,
    Debug
    )

    A character string target. Lengths are in code points.

    ZoneOffset

    pub struct ZoneOffset {
    minutes : Int
    } derive(Eq,
    Debug
    )

    The session time zone displacement in minutes east of UTC, −18:00 to +18:00 (spec M4d2 §4.4).

    ZoneOffset::from_minutes

    #alias(new, deprecated="Use ZoneOffset::from_minutes instead")
    fn ZoneOffset::from_minutes(minutes : Int) -> ZoneOffset?

    The displacement of minutes east of UTC, or None outside −18:00 to +18:00.

    ZoneOffset::utc

    fn ZoneOffset::utc() -> ZoneOffset

    The zero-minute offset, UTC.

    abs

    ABS(x): +x when x >= 0, else -x, so an integer result outside Int64 is an overflow as for -x. A decimal keeps its exponent; a negative zero becomes positive (partiql-tests ion/abs.ion). An interval gets sign +.

    add

    Add numbers or a supported datetime/interval pair. Unbox Ion and propagate MISSING before NULL. Numeric operands widen to decimal when either is decimal, otherwise to float when either is float. Raise TypeFailure for incompatible operands or DataFailure for overflow.

    all_elements

    [*]: the items of a list or bag.

    all_fields

    .*: the values of a tuple.

    and_

    FALSE if either is FALSE; else NULL if either is unknown; else TRUE.

    any_values

    ANY (and SOME): TRUE when one value is TRUE.

    avg_values

    AVG: the sum divided by the count, as a decimal (38 digits, half even, natural scale).

    bit_length

    BIT_LENGTH(s): 8 times OCTET_LENGTH.

    bool_test

    fn bool_test(v :
    Value
    , wanted : Bool?, negated~ : Bool) -> Bool

    IS [NOT] TRUE | FALSE | UNKNOWN (None): a non-boolean is neither TRUE nor FALSE nor UNKNOWN.

    cardinality

    CARDINALITY(c), the same count as SIZE.

    cast

    CAST(v AS target) (spec M4d2 §4.2): an Ion value is unboxed; NULL and MISSING stay as they are; ANY gives the operand; then the target group decides by the kind of the value. zone is the session time zone.

    char_length

    CHAR_LENGTH(s): the number of code points.

    clock_timestamp

    fn clock_timestamp(seconds : Int64, nanos : Int, zone : ZoneOffset, precision : Int) ->
    Timestamp
    raise OpFailure

    The instant seconds (since 1970-01-01T00:00Z) and nanos seen at zone: a timestamp with the zone's offset and precision fraction digits, cut, never rounded. A date outside 0001-9999 is a datetime field overflow.

    concat

    a || b: the concatenation of two strings.

    count_values

    fn count_values(values : Iter[
    Value
    ], distinct~ : Bool) ->
    Value
    raise OpFailure

    Count present values after unboxing Ion and dropping NULL and MISSING. With distinct, count each grouping-equivalent value once. Empty input gives zero.

    datetime_to_string

    TO_STRING(x, pattern).

    div

    Integer division truncates toward zero; a zero divisor of an integer or decimal is a DataFailure, a float divides as IEEE does.

    equal

    =: NULL if either side is NULL, else MISSING if either is MISSING, else a Bool; it never fails on mixed types (partiql-tests null.ion). A NaN equals nothing. Collections compare their elements with same, so [DATE '2020-01-01'] = [TIMESTAMP '2020-01-01 00:00:00'] as the elements do.

    every_values

    fn every_values(values : Iter[
    Value
    ], distinct~ : Bool) ->
    Value
    raise OpFailure

    EVERY: TRUE when every value is TRUE.

    exists

    EXISTS(c): whether c has an element.

    field

    fn field(v :
    Value
    , name : String, delimited~ : Bool, unique~ : Bool) ->
    Value
    raise OpFailure

    The field name of a tuple. Without delimited the match ignores ASCII case. With unique, repeated matches are a type failure.

    field_match

    fn field_match(t :
    Tuple
    , name : String, delimited~ : Bool) -> FieldMatch

    All fields matching a name, ignoring ASCII case for regular identifiers.

    greater

    The > predicate, with the same absence, NaN and type rules as less.

    greater_eq

    The >= predicate, with the same absence, NaN and type rules as less.

    in_

    x IN c for a list, bag or row c: TRUE if some element = x, else NULL if some comparison is absent, else FALSE.

    index

    The element i of a list or the value for the key i of a map. A NULL or MISSING map key gives NULL or MISSING. A tuple is indexed by a string only when named is true: t[s] is the path t.s for a string literal s (or a CAST to a string), not for any expression.

    interval_qualifier_valid

    Whether an interval qualifier names its fields in order and of one class.

    is_type

    v IS type. A value of another type, also NULL, is FALSE; for a MAP type NULL gives NULL and MISSING gives MISSING (partiql-tests map.ion).

    less

    The < predicate. Unbox Ion; propagate MISSING before NULL. Return false for NaN and raise TypeFailure for incomparable kinds.

    less_eq

    The <= predicate, with the same absence, NaN and type rules as less.

    like

    text LIKE pattern [ESCAPE escape]. MISSING if an operand is MISSING, else NULL if one is NULL, else a type failure unless all are strings.

    lower

    LOWER(s), with the Final_Sigma context: U+03A3 becomes U+03C2 after a cased letter and not before one (case-ignorable characters skipped).

    map_contains_key

    MAP_CONTAINS_KEY(m, k).

    map_entries

    MAP_ENTRIES(m): a bag of {k, v} tuples (partiql-tests map.ion:956).

    map_get

    MAP_GET(m, k): m[k]; an absent key is a TypeFailure (RFC 0104).

    map_keys

    MAP_KEYS(m): a bag of the keys in insertion order.

    map_type_of

    The map type a type name declares, if it is one (RFC 0104).

    map_values

    MAP_VALUES(m): a bag of the values in insertion order.

    max_values

    The greatest present value under PartiQL total ordering, or NULL for empty or entirely absent input. Unbox Ion and ignore NULL and MISSING.

    min_values

    The least present value under PartiQL total ordering, or NULL for empty or entirely absent input. Unbox Ion and ignore NULL and MISSING.

    modulo

    MOD(a, b): the remainder with the sign of the dividend, for integers and scale-0 decimals (SQL 6.28). A zero divisor is a DataFailure.

    mul

    Multiply numbers or a supported interval/number pair. Use add's unboxing, absence, numeric widening and failure rules.

    neg

    -x, and +x when negate is false.

    not_

    SQL NOT: negate a boolean; NULL and MISSING both produce NULL after unboxing Ion. Raise TypeFailure for a present non-boolean operand.

    not_equal

    <>: the negation of =, keeping an absent result.

    octet_length

    OCTET_LENGTH(s): UTF-8 bytes of a string; bytes of a blob or clob.

    or_

    TRUE if either is TRUE; else NULL if either is unknown; else FALSE.

    overlay

    OVERLAY(v PLACING r FROM s [FOR n]) = SUBSTRING(v FROM 1 FOR s - 1) ||r || SUBSTRING(v FROM s + n), n = CHAR_LENGTH(r) by default (SQL:1999 6.18). s < 1 is a substring error (negative length).

    parse_date

    fn parse_date(text : String) ->
    Date
    raise OpFailure

    YYYY-MM-DD.

    parse_decimal

    fn parse_decimal(text : String) ->
    Decimal
    ?

    A decimal from its text, with an optional exponent (2.25e-1); in PartiQL a number with an exponent is a decimal (partiql-tests nary-operators.ion, subtractionOutOfAllowedPrecision, and extended int.ion).

    parse_interval

    fn parse_interval(text : String, negative~ : Bool, qualifier~ :
    IntervalQualifier
    ) ->
    Value
    raise OpFailure

    '3', '1-5', '2 4:5:10.5', ... by the qualifier. negative is the sign before the text; a sign inside the text turns it again.

    parse_time

    fn parse_time(text : String, precision : Int?, with_tz : Bool) ->
    Time
    raise OpFailure

    HH:MM:SS[.f*][(+|-)HH:MM]. Without with_tz the offset is optional. See time_part for the precision.

    parse_timestamp

    fn parse_timestamp(text : String, precision : Int?, with_tz : Bool) ->
    Timestamp
    raise OpFailure

    YYYY-MM-DD HH:MM:SS[.f*][(+|-)HH:MM]; T may stand for the space.

    position

    POSITION(needle IN hay): the 1-based code-point index, 0 when absent, 1 for an empty needle (SQL).

    round_decimal

    Rounds a decimal to 38 significant digits, half to even.

    shift_time

    The time nanos later, around the day.

    shift_timestamp

    The timestamp nanos later.

    sub

    Subtract numbers or a supported datetime/interval pair. Use add's unboxing, absence, numeric widening and failure rules.

    substring

    SUBSTRING(v FROM start [FOR length]).

    sum_values

    SUM: an integer when every value is an integer (the range is checked once, at the end), else a decimal.

    text_replace

    TEXT_REPLACE(v, pattern, replacement): every non-overlapping match from the left; an empty pattern inserts at every code-point boundary (partiql-tests extended text_replace.ion:39).

    text_to_timestamp

    TO_TIMESTAMP(text [, pattern]).

    trim

    TRIM([spec] [chars] FROM v): removes code points of the set chars (default U+0020) from the chosen ends. Arguments in source order: [v] or [chars, v].

    tuple_union

    TUPLEUNION(t1, ..., tn): every field of every argument, in argument order, duplicates kept (spec select.adoc:585-593).