public class SqlFunctionUtils extends Object
NOTE: Before you add functions here, check if Calcite provides it in
org.apache.calcite.runtime.SqlFunctions
. Furthermore, make sure
to implement the function efficiently. Sometimes it makes sense to create a
org.apache.flink.table.codegen.calls.CallGenerator
instead to avoid
massive object creation and reuse instances.
Constructor and Description |
---|
SqlFunctionUtils() |
Modifier and Type | Method and Description |
---|---|
static Decimal |
abs(Decimal a) |
static double |
acos(Decimal a) |
static double |
asin(Decimal a) |
static double |
atan(Decimal a) |
static double |
atan2(Decimal y,
Decimal x) |
static Byte |
bitAnd(Byte a,
Byte b) |
static Integer |
bitAnd(Integer a,
Integer b) |
static Long |
bitAnd(Long a,
Long b) |
static Short |
bitAnd(Short a,
Short b) |
static Byte |
bitNot(Byte a) |
static Integer |
bitNot(Integer a) |
static Long |
bitNot(Long a) |
static Short |
bitNot(Short a) |
static Byte |
bitOr(Byte a,
Byte b) |
static Integer |
bitOr(Integer a,
Integer b) |
static Long |
bitOr(Long a,
Long b) |
static Short |
bitOr(Short a,
Short b) |
static Byte |
bitXor(Byte a,
Byte b) |
static Integer |
bitXor(Integer a,
Integer b) |
static Long |
bitXor(Long a,
Long b) |
static Short |
bitXor(Short a,
Short b) |
static Decimal |
ceil(Decimal a) |
static String |
chr(long chr) |
static double |
cos(Decimal a) |
static double |
cosh(Decimal x) |
static double |
cot(Decimal a) |
static double |
degrees(Decimal angrad) |
static int |
divideInt(int a,
int b) |
static double |
exp(Decimal d) |
static Decimal |
floor(Decimal a) |
static BinaryString |
fromBase64(BinaryString bs) |
static String |
hash(String algorithm,
String str)
Calculate the hash value of a given string.
|
static String |
hash(String algorithm,
String str,
String charsetName)
Calculate the hash value of a given string.
|
static Integer |
hashCode(String str) |
static String |
hex(long x)
Returns the hex string of a long argument.
|
static String |
hex(String x)
Returns the hex string of a string argument.
|
static int |
instr(BinaryString str,
BinaryString subString,
int startPosition,
int nthAppearance) |
static boolean |
isAlpha(Object obj) |
static boolean |
isDecimal(Object obj) |
static boolean |
isDigit(Object obj) |
static String |
jsonValue(String jsonString,
String pathString) |
static BinaryString |
keyValue(BinaryString str,
BinaryString pairSeparator,
BinaryString kvSeparator,
BinaryString keyName)
Parse string as key-value string and return the value matches key name.
|
static double |
log(Decimal x) |
static double |
log(Decimal base,
Decimal x) |
static double |
log(Decimal base,
double x) |
static double |
log(double x)
Returns the natural logarithm of "x".
|
static double |
log(double base,
Decimal x) |
static double |
log(double base,
double x)
Returns the logarithm of "x" with base "base".
|
static double |
log10(Decimal x) |
static double |
log10(double x) |
static double |
log2(Decimal x) |
static double |
log2(double x)
Returns the logarithm of "a" with base 2.
|
static String |
lpad(String base,
int len,
String pad)
Returns the string str left-padded with the string pad to a length of len characters.
|
static String |
overlay(String s,
String r,
long start) |
static String |
overlay(String s,
String r,
long start,
long length) |
static String |
parseUrl(String urlStr,
String partToExtract)
Parse url and return various components of the URL.
|
static String |
parseUrl(String urlStr,
String partToExtract,
String key)
Parse url and return various parameter of the URL.
|
static int |
position(BinaryString seek,
BinaryString s) |
static int |
position(BinaryString seek,
BinaryString s,
int from) |
static double |
power(Decimal base,
Decimal exponent) |
static double |
power(Decimal base,
double exponent) |
static double |
power(double base,
Decimal exponent) |
static double |
radians(Decimal angdeg) |
static Boolean |
regExp(String s,
String regex) |
static String |
regexpExtract(String str,
String regex)
Returns the first string extracted with a specified regular expression.
|
static String |
regexpExtract(String str,
String regex,
int extractIndex)
Returns a string extracted with a specified regular expression and a regex match group index.
|
static String |
regexpExtract(String str,
String regex,
long extractIndex) |
static String |
regexpReplace(String str,
String regex,
String replacement)
Returns a string resulting from replacing all substrings
that match the regular expression with replacement.
|
static String |
repeat(String str,
int repeat)
Returns a string that repeats the base string n times.
|
static String |
replace(String str,
String oldStr,
String replacement)
Replaces all the old strings with the replacement string.
|
static String |
rpad(String base,
int len,
String pad)
Returns the string str right-padded with the string pad to a length of len characters.
|
static Decimal |
sign(Decimal b0) |
static double |
sin(Decimal a) |
static double |
sinh(Decimal a) |
static String |
splitIndex(String str,
int character,
int index)
Split target string with custom separator and pick the index-th(start with 0) result.
|
static String |
splitIndex(String str,
String separator,
int index)
Split target string with custom separator and pick the index-th(start with 0) result.
|
static BigDecimal |
sround(BigDecimal b0)
SQL
ROUND operator applied to BigDecimal values. |
static BigDecimal |
sround(BigDecimal b0,
int b1)
SQL
ROUND operator applied to BigDecimal values. |
static Decimal |
sround(Decimal b0)
SQL
ROUND operator applied to Decimal values. |
static Decimal |
sround(Decimal b0,
int b1)
SQL
ROUND operator applied to Decimal values. |
static double |
sround(double b0)
SQL
ROUND operator applied to double values. |
static double |
sround(double b0,
int b1)
SQL
ROUND operator applied to double values. |
static int |
sround(int b0)
SQL
ROUND operator applied to int values. |
static int |
sround(int b0,
int b1)
SQL
ROUND operator applied to int values. |
static long |
sround(long b0)
SQL
ROUND operator applied to long values. |
static long |
sround(long b0,
int b1)
SQL
ROUND operator applied to long values. |
static Map<String,String> |
strToMap(String text)
Creates a map by parsing text.
|
static Map<String,String> |
strToMap(String text,
String listDelimiter,
String keyValueDelimiter)
Creates a map by parsing text.
|
static Decimal |
struncate(Decimal b0)
SQL
TRUNCATE operator applied to BigDecimal values. |
static Decimal |
struncate(Decimal b0,
int b1) |
static float |
struncate(float b0)
SQL
TRUNCATE operator applied to double values. |
static float |
struncate(float b0,
int b1) |
static String |
subString(String str,
long start) |
static String |
subString(String str,
long start,
long len) |
static double |
tan(Decimal a) |
static double |
tanh(Decimal a)
Calculates the hyperbolic tangent of a big decimal number.
|
static String |
toBase64(BinaryString bs) |
static String |
toBase64(byte[] bytes) |
static String |
uuid() |
static String |
uuid(byte[] b) |
public static double exp(Decimal d)
public static double power(double base, Decimal exponent)
public static double power(Decimal base, double exponent)
public static double cosh(Decimal x)
public static double acos(Decimal a)
public static double asin(Decimal a)
public static double atan(Decimal a)
public static double sin(Decimal a)
public static double sinh(Decimal a)
public static double cos(Decimal a)
public static double tan(Decimal a)
public static double tanh(Decimal a)
public static double cot(Decimal a)
public static double degrees(Decimal angrad)
public static double radians(Decimal angdeg)
public static double log(double x)
public static double log(Decimal x)
public static double log(double base, double x)
public static double log(double base, Decimal x)
public static double log(Decimal base, double x)
public static double log2(double x)
public static double log2(Decimal x)
public static double log10(double x)
public static double log10(Decimal x)
public static String lpad(String base, int len, String pad)
public static String rpad(String base, int len, String pad)
public static String repeat(String str, int repeat)
public static String replace(String str, String oldStr, String replacement)
public static String splitIndex(String str, String separator, int index)
str
- target string.separator
- custom separator.index
- index of the result which you want.public static String splitIndex(String str, int character, int index)
str
- target string.character
- int value of the separator characterindex
- index of the result which you want.public static String regexpReplace(String str, String regex, String replacement)
public static String regexpExtract(String str, String regex, int extractIndex)
public static String regexpExtract(String str, String regex)
public static BinaryString keyValue(BinaryString str, BinaryString pairSeparator, BinaryString kvSeparator, BinaryString keyName)
str
- target string.pairSeparator
- separator between key-value tuple.kvSeparator
- separator between key and value.keyName
- name of the key whose value you want return.public static String hash(String algorithm, String str)
algorithm
- message digest algorithm.str
- string to hash.public static String hash(String algorithm, String str, String charsetName)
algorithm
- message digest algorithm.str
- string to hash.charsetName
- charset of string.public static String parseUrl(String urlStr, String partToExtract)
urlStr
- URL string.partToExtract
- determines which components would return.
accept values:
HOST,PATH,QUERY,REF,
PROTOCOL,FILE,AUTHORITY,USERINFOpublic static String parseUrl(String urlStr, String partToExtract, String key)
urlStr
- URL string.partToExtract
- must be QUERY, or return null.key
- parameter name.public static int divideInt(int a, int b)
public static String chr(long chr)
public static int position(BinaryString seek, BinaryString s)
public static int position(BinaryString seek, BinaryString s, int from)
public static int instr(BinaryString str, BinaryString subString, int startPosition, int nthAppearance)
public static String hex(long x)
public static Map<String,String> strToMap(String text)
text
- the input textpublic static Map<String,String> strToMap(String text, String listDelimiter, String keyValueDelimiter)
text
- the input textlistDelimiter
- the delimiter to separates pairskeyValueDelimiter
- the delimiter to separates key and valuepublic static int sround(int b0)
ROUND
operator applied to int values.public static int sround(int b0, int b1)
ROUND
operator applied to int values.public static long sround(long b0)
ROUND
operator applied to long values.public static long sround(long b0, int b1)
ROUND
operator applied to long values.public static BigDecimal sround(BigDecimal b0)
ROUND
operator applied to BigDecimal values.public static BigDecimal sround(BigDecimal b0, int b1)
ROUND
operator applied to BigDecimal values.public static double sround(double b0)
ROUND
operator applied to double values.public static double sround(double b0, int b1)
ROUND
operator applied to double values.public static Decimal sround(Decimal b0, int b1)
ROUND
operator applied to Decimal values.public static boolean isDecimal(Object obj)
public static boolean isDigit(Object obj)
public static boolean isAlpha(Object obj)
public static String toBase64(BinaryString bs)
public static String toBase64(byte[] bytes)
public static BinaryString fromBase64(BinaryString bs)
public static String uuid()
public static String uuid(byte[] b)
public static Decimal struncate(Decimal b0)
TRUNCATE
operator applied to BigDecimal values.public static float struncate(float b0)
TRUNCATE
operator applied to double values.public static float struncate(float b0, int b1)
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.