Functions

    Aggregate functions perform a calculation on a set of values and return a single value. Aggregate functions can be used as expressions only in the following:

    • The select list of a SELECT statement (either a subquery or an outer query).
    • A HAVING clause.
    • Get an array of column of the current window. Assume the column a is of int type, the result will be like: [{"r1":[32, 45]}]
    • Get the whole array of the current window. The result will be like: [{"r1":{"a":32, "b":"hello"}, {"a":45, "b":"world"}}]

    • Get the whole array of the current window which is deduplicated by column a. The result will be like: [{"r1":{"a":32, "b":"hello"}, {"a":45, "b":"world"}}]
    • Get the column value which is not duplicate during the last hour. The result will be like: [{"r1":32}], [{"r1":45}] and [{}] if a duplicate value arrives. Use the omitIfEmpty sink property to filter out those empty results.

    Mathematical Functions

    Function Example Description
    abs abs(col1) The absolute value of a value
    acos acos(col1) The inverse cosine of a number in radians
    asin asin(col1) The inverse sine of a number in radians
    atan atan(col1) The inverse tangent of a number in radians
    atan2 atan2(col1, col2) The angle, in radians, between the positive x-axis and the (x, y) point defined in the two arguments
    bitand bitand(col1, col2) Performs a bitwise AND on the bit representations of the two Int(-converted) arguments
    bitor bitor(col1, col2) Performs a bitwise OR of the bit representations of the two arguments
    bitxor bitxor(col1, col2) Performs a bitwise XOR on the bit representations of the two Int(-converted) arguments
    bitnot bitnot(col1) Performs a bitwise NOT on the bit representations of the Int(-converted) argument
    ceil ceil(col1) Round a value up to the nearest BIGINT value.
    cos cos(col1) Returns the cosine of a number in radians.
    cosh cosh(col1) Returns the hyperbolic cosine of a number in radians.
    exp exp(col1) Returns e raised to the Decimal argument.
    ln ln(col1) Returns the natural logarithm of the argument.
    log log(col1) Returns the base 10 logarithm of the argument.
    mod mod(col1, col2) Returns the remainder of the division of the first argument by the second argument.
    power power(x, y) Pow returns x**y, the base-x exponential of y.
    rand rand() Returns a pseudorandom, uniformly distributed double between 0.0 and 1.0.
    round round(col1) Round a value to the nearest BIGINT value.
    sign sign(col1) Returns the sign of the given number. When the sign of the argument is positive, 1 is returned. When the sign of the argument is negative, -1 is returned. If the argument is 0, 0 is returned.
    sin sin(col1) Returns the sine of a number in radians.
    sinh sinh(col1) Returns the hyperbolic sine of a number in radians.
    sqrt sqrt(col1) Returns the square root of a number.
    tan tan(col1) Returns the tangent of a number in radians.
    tanh tanh(col1) Returns the hyperbolic tangent of a number in radians.

    A pattern is used to create a format string. Patterns are based on a simple sequence of letters and symbols which is common in many languages like Java etc. The supported symbols in Kuiepr are

    Symbol Meaning Example

    / G / era / G(AD) / / Y / year/ YYYY(2004), YY(04) / / M / month / M(1), MM(01), MMM(Jan), MMMM(January) / / d / day of month / d(2), dd(02) / / E / day of week / EEE(Mon), EEEE(Monday) / / H / hour in 24 hours format / HH(15) / / h / hour in 12 hours format / h(2), hh(03) / / a / AM or PM / a(PM) / / m / minute / m(4), mm(04) / / s / second / s(5), ss(05) / / S / fraction of second / S(.0), SS(.00), SSS(.000) / / z / time zone name / z(MST) / / Z / 4 digits time zone offset / Z(-0700) / / X / time zone offset / X(-07), XX(-0700), XXX(-07:00) /

    • YYYY-MM-dd T HH:mm:ss -> 2006-01-02 T 15:04:05
    • YYYY/MM/dd HH:mm:ssSSS XXX -> 2006/01/02 15:04:05.000 -07:00

    Conversion Functions

    When casting to datetime type, the supported column type and casting rule are:

    1. If column is datatime type, just return the value.
    2. If column is bigint or float type, the number will be treated as the milliseconds elapsed since January 1, 1970 00:00:00 UTC and converted.
    3. If column is string, it will be parsed to datetime with the default format: "2006-01-02T15:04:05.000Z07:00".
    Function Example Description
    md5 md5(col1) Hashed value of the argument
    sha1 sha1(col1) Hashed value of the argument
    sha256 sha256(col1) Hashed value of the argument
    sha384 sha384(col1) Hashed value of the argument
    sha512 sha512(col1) Hashed value of the argument

    JSON Functions

    Please refer to for how to compose a json path.

    Function Example Description
    isNull isNull(col1) Returns true if the argument is the Null value.
    cardinality cardinality(col1) The number of members in the group. The null value is 0.
    newuuid newuuid() Returns a random 16-byte UUID.
    tstamp tstamp() Returns the current timestamp in milliseconds from 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970
    mqtt mqtt(topic) Returns the MQTT meta-data of specified key. The current supported keys
    - topic: return the topic of message. If there are multiple stream source, then specify the source name in parameter. Such as mqtt(src1.topic)
    - messageid: return the message id of message. If there are multiple stream source, then specify the source name in parameter. Such as mqtt(src2.messageid)
    meta meta(topic) Returns the meta-data of specified key. The key could be:
    - a standalone key if there is only one source in the from clause, such as meta(device)
    - A qualified key to specify the stream, such as meta(src1.device)
    - A key with arrow for multi level meta data, such as This assumes reading is a map structure meta data.
    window_start window_start() Return the window start timestamp in int64 format. If there is no time window, it returns 0. The window time is aligned with the timestamp notion of the rule. If the rule is using processing time, then the window start timestamp is the processing timestamp. If the rule is using event time, then the window start timestamp is the event timestamp.
    window_end window_end() Return the window end timestamp in int64 format. If there is no time window, it returns 0. The window time is aligned with the timestamp notion of the rule. If the rule is using processing time, then the window start timestamp is the processing timestamp. If the rule is using event time, then the window start timestamp is the event timestamp.