Skip to main content
This feature is currently in alpha. If you want to try it out or have any questions, submit a ticket to the support team.

Built-in Common UDFs

Data Type Conversion Function

The pfSQL cast function is used to convert a value from one data type to another. Currently, it supports 6 data types, including INT32, INT64, FLOAT, DOUBLE, STRING, and BOOLEAN. The syntax of the cast function is:
The cast function takes two parameters, the first one is the field name, and the second one is the target data type. The target data type is specified by the to keyword, and it can be one of the following values:
  • “int32”
  • “int64”
  • “float”
  • “double”
  • “string”
  • “boolean”
The conversion rules to be followed are shown in the following table.

Const Value Function

The pfSQL const function is used to return a constant value. The syntax of the const function is:
The const function takes two parameters, the first one is the constant value, and the second one is the data type of the constant value. The data type is specified by the type keyword, and it can be one of the following values:
  • “int32”
  • “int64”
  • “float”
  • “double”
  • “string”
  • “boolean”
The following example shows how to use the const function:
The above SQL statement returns a constant value of type int32 with value 1.

Built-in Math UDFs

Currently, pfSQL supports the following mathmatical functions. The behavior of these mathmatical functions is identical to the behavior of the corresponding functions in the Java Math standard library. The syntax of the mathmatical functions is:

Limitations

  1. The UDF only support in SELECT statement, we are working on it to extend the UDF to WHERE and other statements.
  2. The UDF only support passing full path of single field in SELECT statement yet.