safe_date_functions = {
    "adddate",
    "addtime",
    "convert_tz",
    "curdate",
    "current_date",
    "current_time",
    "current_timestamp",
    "curtime",
    "date",
    "date_add",
    "date_format",
    "date_sub",
    "datediff",
    "day",
    "dayname",
    "dayofmonth",
    "dayofweek",
    "dayofyear",
    "extract",
    "from_days",
    "from_unixtime",
    "get_format",
    "hour",
    "last_day",
    "localtime",
    "localtimestamp",
    "makedate",
    "maketime",
    "microsecond",
    "minute",
    "month",
    "monthname",
    "now",
    "period_add",
    "period_diff",
    "quarter",
    "sec_to_time",
    "second",
    "str_to_date",
    "subdate",
    "subtime",
    "sysdate",
    "time",
    "time_format",
    "time_to_sec",
    "timediff",
    "timestamp",
    "timestampadd",
    "timestampdiff",
    "to_days",
    "to_seconds",
    "unix_timestamp",
    "utc_date",
    "utc_time",
    "utc_timestamp",
    "week",
    "weekday",
    "weekofyear",
    "year",
    "yearweek",
}

safe_string_functions = {
    "ascii",
    "bin",
    "bit_length",
    "char",
    "char_length",
    "character_length",
    "concat",
    "concat_ws" "elt",
    "export_set",
    "field",
    "find_in_set",
    "format",
    "from_base64",
    "hex",
    "insert",
    "instr",
    "lcase",
    "left",
    "length",
    # this is not safe
    # "load_file",
    "locate",
    "lower",
    "lpad",
    "ltrim",
    "make_set",
    "mid",
    "oct",
    "octet_length",
    "ord",
    "position",
    "quote",
    "regexp_instr",
    "regexp_like",
    "regexp_replace",
    "regexp_substr",
    "repeat",
    "replace",
    "reverse",
    "right",
    "rpad",
    "rtrim",
    "soundex",
    "space",
    "strcmp",
    "substr",
    "substring",
    "substring_index",
    "to_base64",
    "trim",
    "ucase",
    "unhex",
    "upper",
    "weight_string",
}

safe_math_functions = {
    "abs",
    "acos",
    "asin",
    "atan",
    "atan2",
    "ceil",
    "ceiling",
    "conv",
    "cos",
    "cot",
    "crc32",
    "degrees",
    "div",
    "exp",
    "floor",
    "ln",
    "log",
    "log10",
    "log2",
    "mod",
    "pi",
    "pow",
    "power",
    "radians",
    "rand",
    "round",
    "sign",
    "sin",
    "sqrt",
    "tan",
    "truncate",
}


safe_misc_functions = {
    "bit_count",
    "if",
    "ifnull",
    "nullif",
}

safe_json_functions = {
    "json_array",
    "json_array_append",
    "json_array_insert",
    "json_contains",
    "json_contains_path",
    "json_depth",
    "json_extract",
    "json_insert",
    "json_keys",
    "json_length",
    "json_merge",
    "json_merge_patch",
    "json_merge_preserve",
    "json_object",
    "json_overlaps",
    "json_pretty",
    "json_quote",
    "json_remove",
    "json_replace",
    "json_schema_valid",
    "json_schema_validation_report",
    "json_search",
    "json_set",
    "json_type",
    "json_unquote",
    "json_valid",
    "json_value",
}

safe_agg_functions = {
    "avg",
    "bit_and",
    "bit_or",
    "bit_xor",
    "count",
    "group_concat",
    "json_arrayagg",
    "json_objectagg",
    "max",
    "min",
    "std",
    "stddev",
    "stddev_pop",
    "stddev_samp",
    "sum",
    "var_pop",
    "var_samp",
    "variance",
}

safe_functions = (
    safe_date_functions
    | safe_string_functions
    | safe_math_functions
    | safe_misc_functions
    | safe_json_functions
    | safe_agg_functions
)
