use crate::idents::ident_key;
use sqlparser::ast::ObjectName;
#[rustfmt::skip]
pub const SCALAR: &[&str] = &[
"abs",
"acos",
"array_append",
"array_cat",
"array_length",
"array_ndims",
"array_position",
"array_positions",
"array_prepend",
"array_remove",
"array_replace",
"array_to_string",
"asin",
"atan",
"atan2",
"btrim",
"cardinality",
"ceil",
"ceiling",
"char_length",
"character_length",
"clock_timestamp",
"concat",
"concat_ws",
"cos",
"date_part",
"date_trunc",
"decode",
"encode",
"exp",
"floor",
"format",
"gen_random_uuid",
"json_array_length",
"json_build_array",
"json_build_object",
"json_extract_path",
"json_extract_path_text",
"json_typeof",
"jsonb_array_length",
"jsonb_build_array",
"jsonb_build_object",
"jsonb_extract_path",
"jsonb_extract_path_text",
"jsonb_typeof",
"left",
"length",
"ln",
"log",
"lower",
"lpad",
"ltrim",
"make_interval",
"md5",
"now",
"octet_length",
"pg_backend_pid",
"pg_column_size",
"pg_typeof",
"power",
"quote_ident",
"quote_literal",
"quote_nullable",
"regexp_count",
"regexp_instr",
"regexp_match",
"regexp_replace",
"regexp_substr",
"repeat",
"replace",
"reverse",
"right",
"round",
"rpad",
"rtrim",
"sign",
"sin",
"split_part",
"sqrt",
"starts_with",
"statement_timestamp",
"string_to_array",
"strpos",
"substr",
"substring",
"tan",
"to_char",
"to_date",
"to_json",
"to_jsonb",
"to_number",
"to_timestamp",
"transaction_timestamp",
"translate",
"trunc",
"upper",
"uuid_extract_timestamp",
"uuid_extract_version",
];
#[rustfmt::skip]
const DATETIME_KEYWORDS: &[&str] = &[
"current_date",
"current_time",
"current_timestamp",
"localtime",
"localtimestamp",
];
pub(super) fn is_datetime_keyword(name: &ObjectName) -> bool {
let [sqlparser::ast::ObjectNamePart::Identifier(ident)] = name.0.as_slice() else {
return false;
};
ident.quote_style.is_none() && DATETIME_KEYWORDS.contains(&ident_key(ident).as_str())
}