@Description("the constant Pi") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double pi() { return Math.PI; }
@Description("encodes the string to UTF-8") @ScalarFunction @LiteralParameters("x") @SqlType(StandardTypes.VARBINARY) public static Slice toUtf8(@SqlType("varchar(x)") Slice slice) { return slice; }
@Description("remove the longest string containing only given characters from the beginning and end of a string") @ScalarFunction("trim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice trim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.trim(slice, codePointsToTrim); }
@Description("round to nearest integer") @ScalarFunction @SqlType(StandardTypes.BIGINT) public static long round(@SqlType(StandardTypes.BIGINT) long num) { return num; }
@Description("string(s) extracted using the given pattern") @ScalarFunction @LiteralParameters("x") @SqlType("array(varchar(x))") public static Block regexpExtractAll(@SqlType("varchar(x)") Slice source, @SqlType(JoniRegexpType.NAME) Regex pattern) { return regexpExtractAll(source, pattern, 0); }
@Description("absolute value") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double abs(@SqlType(StandardTypes.DOUBLE) double num) { return Math.abs(num); }
@Description("removes substrings matching a regular expression") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") public static Slice regexpReplace(@SqlType("varchar(x)") Slice source, @SqlType(Re2JRegexpType.NAME) Re2JRegexp pattern) { return regexpReplace(source, pattern, Slices.EMPTY_SLICE); }
@Description("arc tangent") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double atan(@SqlType(StandardTypes.DOUBLE) double num) { return Math.atan(num); }
@Description("count of code points of the given string") @ScalarFunction @LiteralParameters("x") @SqlType(StandardTypes.BIGINT) public static long length(@SqlType("varchar(x)") Slice slice) { return countCodePoints(slice); }
@Description("tangent") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double tan(@SqlType(StandardTypes.DOUBLE) double num) { return Math.tan(num); }
@Description("suffix starting at given index") @ScalarFunction("substr") @LiteralParameters("x") @SqlType("char(x)") public static Slice charSubstr(@SqlType("char(x)") Slice utf8, @SqlType(StandardTypes.BIGINT) long start) { return substr(utf8, start); }
@Description("round to nearest integer") @ScalarFunction("round") @SqlType(StandardTypes.TINYINT) public static long roundTinyint(@SqlType(StandardTypes.TINYINT) long num, @SqlType(StandardTypes.INTEGER) long decimals) { // TODO implement support for `decimals < 0` return num; }
@Description("remove the longest string containing only given characters from the beginning of a string") @ScalarFunction("ltrim") @LiteralParameters("x") @SqlType("varchar(x)") public static Slice leftTrim(@SqlType("varchar(x)") Slice slice, @SqlType(CodePointsType.NAME) int[] codePointsToTrim) { return SliceUtf8.leftTrim(slice, codePointsToTrim); }
@Description("round to nearest integer") @ScalarFunction("round") @SqlType(StandardTypes.INTEGER) public static long roundInteger(@SqlType(StandardTypes.INTEGER) long num, @SqlType(StandardTypes.INTEGER) long decimals) { // TODO implement support for `decimals < 0` return num; }
@Description("converts the string to lower case") @ScalarFunction("lower") @LiteralParameters("x") @SqlType("char(x)") public static Slice charLower(@SqlType("char(x)") Slice slice) { return lower(slice); }
@Description("arc tangent of given fraction") @ScalarFunction @SqlType(StandardTypes.DOUBLE) public static double atan2(@SqlType(StandardTypes.DOUBLE) double num1, @SqlType(StandardTypes.DOUBLE) double num2) { return Math.atan2(num1, num2); }
@Description("converts the string to upper case") @ScalarFunction @LiteralParameters("x") @SqlType("varchar(x)") public static Slice upper(@SqlType("varchar(x)") Slice slice) { return toUpperCase(slice); }
@Description("round to integer by dropping digits after decimal point") @ScalarFunction @SqlType(StandardTypes.REAL) public static long truncate(@SqlType(StandardTypes.REAL) long num) { float numInFloat = intBitsToFloat((int) num); return floatToRawIntBits((float) (Math.signum(numInFloat) * Math.floor(Math.abs(numInFloat)))); }
@Description("converts the string to upper case") @ScalarFunction("upper") @LiteralParameters("x") @SqlType("char(x)") public static Slice charUpper(@SqlType("char(x)") Slice slice) { return upper(slice); }
@Description("pads a varbinary on the left") @ScalarFunction("lpad") @SqlType(StandardTypes.VARBINARY) public static Slice leftPad(@SqlType("varbinary") Slice inputSlice, @SqlType(StandardTypes.BIGINT) long targetLength, @SqlType("varbinary") Slice padBytes) { return pad(inputSlice, targetLength, padBytes, 0); }