SQL Expressions: Add Functions to Allow list (#113291)
Add assorted math, windowing, json, date/time, regex, string, conditional, and aggregation functions to allow list
This commit is contained in:
@@ -183,19 +183,25 @@ func allowedFunction(f *sqlparser.FuncExpr) (b bool) {
|
||||
// Conditional functions
|
||||
case "if", "coalesce", "ifnull", "nullif":
|
||||
return
|
||||
case "least":
|
||||
return
|
||||
|
||||
// Aggregation functions
|
||||
case "sum", "avg", "count", "min", "max":
|
||||
return
|
||||
case "stddev", "std", "stddev_pop":
|
||||
case "stddev", "std", "stddev_pop", "stddev_sample":
|
||||
return
|
||||
case "variance", "var_pop":
|
||||
case "variance", "var_pop", "var_samp":
|
||||
return
|
||||
case "group_concat":
|
||||
return
|
||||
case "row_number", "rank", "dense_rank", "lead", "lag":
|
||||
|
||||
// Window Functions
|
||||
case "row_number", "rank", "dense_rank", "percent_rank":
|
||||
return
|
||||
case "first_value", "last_value":
|
||||
case "first_value", "last_value", "ntile":
|
||||
return
|
||||
case "lead", "lag":
|
||||
return
|
||||
|
||||
// Mathematical functions
|
||||
@@ -205,14 +211,16 @@ func allowedFunction(f *sqlparser.FuncExpr) (b bool) {
|
||||
return
|
||||
case "sqrt", "pow", "power":
|
||||
return
|
||||
case "mod", "log", "log10", "exp":
|
||||
case "mod", "log", "log2", "log10", "exp":
|
||||
return
|
||||
case "sign", "ln", "truncate":
|
||||
return
|
||||
case "sin", "cos", "tan":
|
||||
case "sin", "cos", "tan", "cot":
|
||||
return
|
||||
case "asin", "acos", "atan", "atan2":
|
||||
return
|
||||
case "conv", "degrees", "radians":
|
||||
return
|
||||
case "rand", "pi":
|
||||
return
|
||||
|
||||
@@ -235,23 +243,29 @@ func allowedFunction(f *sqlparser.FuncExpr) (b bool) {
|
||||
return
|
||||
case "ascii", "ord", "char":
|
||||
return
|
||||
case "regexp_substr":
|
||||
case "elt", "quote":
|
||||
return
|
||||
case "from_base64", "format":
|
||||
return
|
||||
case "regexp_substr", "regexp_replace", "regexp_instr", "regexp_like":
|
||||
return
|
||||
|
||||
// Date functions
|
||||
case "str_to_date":
|
||||
return
|
||||
case "date_format":
|
||||
case "date_format", "get_format":
|
||||
return
|
||||
case "date_add", "date_sub":
|
||||
case "date_add", "adddate", "date_sub", "subdate":
|
||||
return
|
||||
case "year", "month", "day", "weekday":
|
||||
case "year", "month", "day", "weekday", "last_day":
|
||||
return
|
||||
case "yearweek", "weekofyear":
|
||||
return
|
||||
case "datediff":
|
||||
return
|
||||
case "unix_timestamp", "from_unixtime":
|
||||
return
|
||||
case "extract", "hour", "minute", "second":
|
||||
case "extract", "hour", "minute", "second", "microsecond":
|
||||
return
|
||||
case "dayname", "monthname", "dayofweek", "dayofmonth", "dayofyear":
|
||||
return
|
||||
@@ -259,20 +273,36 @@ func allowedFunction(f *sqlparser.FuncExpr) (b bool) {
|
||||
return
|
||||
case "timestampdiff", "timestampadd":
|
||||
return
|
||||
case "from_days", "to_days":
|
||||
return
|
||||
case "time_format", "time", "timediff":
|
||||
return
|
||||
|
||||
// Type conversion
|
||||
case "cast", "convert":
|
||||
return
|
||||
|
||||
// JSON functions
|
||||
case "json_extract", "json_object", "json_array", "json_merge_patch", "json_valid":
|
||||
case "json_extract", "json_object", "json_array", "json_valid":
|
||||
return
|
||||
case "json_merge", "json_merge_patch", "json_merge_preserve":
|
||||
return
|
||||
case "json_contains", "json_length", "json_type", "json_keys":
|
||||
return
|
||||
case "json_contains_path", "json_depth":
|
||||
return
|
||||
case "json_search", "json_quote", "json_unquote":
|
||||
return
|
||||
case "json_set", "json_insert", "json_replace", "json_remove":
|
||||
return
|
||||
case "json_array_append", "json_array_insert":
|
||||
return
|
||||
case "json_objectagg", "json_arrayagg":
|
||||
return
|
||||
case "json_overlaps":
|
||||
return
|
||||
case "json_pretty", "json_value":
|
||||
return
|
||||
|
||||
default:
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user