Polyglot SQL API Documentation - v0.1.0
    Preparing search index...

    Function getExprType

    AST Module

    This module provides types, type guards, helpers, and visitor utilities for working with SQL AST nodes.

    Query builders are in src/builders.ts (WASM-backed).

    • Get the type tag (variant key) of an Expression at runtime.

      Parameters

      Returns
          | "boolean"
          | "function"
          | "column"
          | "date"
          | "time"
          | "timestamp"
          | "interval"
          | "uuid"
          | "array"
          | "list"
          | "struct"
          | "map"
          | "set"
          | "union"
          | "byte_string"
          | "datetime"
          | "literal"
          | "null"
          | "identifier"
          | "table"
          | "star"
          | "braced_wildcard"
          | "select"
          | "intersect"
          | "except"
          | "subquery"
          | "pivot"
          | "pivot_alias"
          | "unpivot"
          | "values"
          | "pre_where"
          | "stream"
          | "using_data"
          | "xml_namespace"
          | "insert"
          | "update"
          | "delete"
          | "copy"
          | "put"
          | "stage_reference"
          | "alias"
          | "cast"
          | "collation"
          | "case"
          | "and"
          | "or"
          | "add"
          | "sub"
          | "mul"
          | "div"
          | "mod"
          | "eq"
          | "neq"
          | "lt"
          | "lte"
          | "gt"
          | "gte"
          | "like"
          | "i_like"
          | "match"
          | "bitwise_and"
          | "bitwise_or"
          | "bitwise_xor"
          | "concat"
          | "adjacent"
          | "ts_match"
          | "property_e_q"
          | "array_contains_all"
          | "array_contained_by"
          | "array_overlaps"
          | "j_s_o_n_b_contains_all_top_keys"
          | "j_s_o_n_b_contains_any_top_keys"
          | "j_s_o_n_b_delete_at_path"
          | "extends_left"
          | "extends_right"
          | "not"
          | "neg"
          | "bitwise_not"
          | "in"
          | "between"
          | "is_null"
          | "is_true"
          | "is_false"
          | "is_json"
          | "is"
          | "exists"
          | "member_of"
          | "aggregate_function"
          | "window_function"
          | "from"
          | "join"
          | "joined_table"
          | "where"
          | "group_by"
          | "having"
          | "order_by"
          | "limit"
          | "offset"
          | "qualify"
          | "with"
          | "cte"
          | "distribute_by"
          | "cluster_by"
          | "sort_by"
          | "lateral_view"
          | "hint"
          | "pseudocolumn"
          | "connect"
          | "prior"
          | "connect_by_root"
          | "match_recognize"
          | "ordered"
          | "window"
          | "over"
          | "within_group"
          | "data_type"
          | "tuple"
          | "concat_ws"
          | "substring"
          | "upper"
          | "lower"
          | "length"
          | "trim"
          | "l_trim"
          | "r_trim"
          | "replace"
          | "reverse"
          | "left"
          | "right"
          | "repeat"
          | "lpad"
          | "rpad"
          | "split"
          | "regexp_like"
          | "regexp_replace"
          | "regexp_extract"
          | "overlay"
          | "abs"
          | "round"
          | "floor"
          | "ceil"
          | "power"
          | "sqrt"
          | "cbrt"
          | "ln"
          | "log"
          | "exp"
          | "sign"
          | "greatest"
          | "least"
          | "current_date"
          | "current_time"
          | "current_timestamp"
          | "current_timestamp_l_t_z"
          | "at_time_zone"
          | "date_add"
          | "date_sub"
          | "date_diff"
          | "date_trunc"
          | "extract"
          | "to_date"
          | "to_timestamp"
          | "date_from_unix_date"
          | "unix_date"
          | "unix_seconds"
          | "unix_millis"
          | "unix_micros"
          | "unix_to_time_str"
          | "time_str_to_date"
          | "date_to_di"
          | "di_to_date"
          | "ts_or_di_to_di"
          | "ts_or_ds_to_datetime"
          | "ts_or_ds_to_timestamp"
          | "year_of_week"
          | "year_of_week_iso"
          | "coalesce"
          | "null_if"
          | "if_func"
          | "if_null"
          | "nvl"
          | "nvl2"
          | "try_cast"
          | "safe_cast"
          | "count"
          | "sum"
          | "avg"
          | "min"
          | "max"
          | "group_concat"
          | "string_agg"
          | "list_agg"
          | "array_agg"
          | "count_if"
          | "sum_if"
          | "stddev"
          | "stddev_pop"
          | "stddev_samp"
          | "variance"
          | "var_pop"
          | "var_samp"
          | "median"
          | "mode"
          | "first"
          | "last"
          | "any_value"
          | "approx_distinct"
          | "approx_count_distinct"
          | "approx_percentile"
          | "percentile"
          | "logical_and"
          | "logical_or"
          | "skewness"
          | "bitwise_count"
          | "array_concat_agg"
          | "array_unique_agg"
          | "bool_xor_agg"
          | "row_number"
          | "rank"
          | "dense_rank"
          | "n_tile"
          | "lead"
          | "lag"
          | "first_value"
          | "last_value"
          | "nth_value"
          | "percent_rank"
          | "cume_dist"
          | "percentile_cont"
          | "percentile_disc"
          | "contains"
          | "starts_with"
          | "ends_with"
          | "position"
          | "initcap"
          | "ascii"
          | "chr"
          | "char_func"
          | "soundex"
          | "levenshtein"
          | "byte_length"
          | "hex"
          | "lower_hex"
          | "unicode"
          | "mod_func"
          | "random"
          | "rand"
          | "trunc_func"
          | "pi"
          | "radians"
          | "degrees"
          | "sin"
          | "cos"
          | "tan"
          | "asin"
          | "acos"
          | "atan"
          | "atan2"
          | "is_nan"
          | "is_inf"
          | "int_div"
          | "decode"
          | "date_format"
          | "format_date"
          | "year"
          | "month"
          | "day"
          | "hour"
          | "minute"
          | "second"
          | "day_of_week"
          | "day_of_week_iso"
          | "day_of_month"
          | "day_of_year"
          | "week_of_year"
          | "quarter"
          | "add_months"
          | "months_between"
          | "last_day"
          | "next_day"
          | "epoch"
          | "epoch_ms"
          | "from_unixtime"
          | "unix_timestamp"
          | "make_date"
          | "make_timestamp"
          | "timestamp_trunc"
          | "time_str_to_unix"
          | "session_user"
          | "s_h_a"
          | "s_h_a1_digest"
          | "time_to_unix"
          | "array_func"
          | "array_length"
          | "array_size"
          | "cardinality"
          | "array_contains"
          | "array_position"
          | "array_append"
          | "array_prepend"
          | "array_concat"
          | "array_sort"
          | "array_reverse"
          | "array_distinct"
          | "array_join"
          | "array_to_string"
          | "unnest"
          | "explode"
          | "explode_outer"
          | "array_filter"
          | "array_transform"
          | "array_flatten"
          | "array_compact"
          | "array_intersect"
          | "array_union"
          | "array_except"
          | "array_remove"
          | "array_zip"
          | "sequence"
          | "generate"
          | "exploding_generate_series"
          | "to_array"
          | "star_map"
          | "struct_func"
          | "struct_extract"
          | "named_struct"
          | "map_func"
          | "map_from_entries"
          | "map_from_arrays"
          | "map_keys"
          | "map_values"
          | "map_contains_key"
          | "map_concat"
          | "element_at"
          | "transform_keys"
          | "transform_values"
          | "json_extract"
          | "json_extract_scalar"
          | "json_extract_path"
          | "json_array"
          | "json_object"
          | "json_query"
          | "json_value"
          | "json_array_length"
          | "json_keys"
          | "json_type"
          | "parse_json"
          | "to_json"
          | "json_set"
          | "json_insert"
          | "json_remove"
          | "json_merge_patch"
          | "json_array_agg"
          | "json_object_agg"
          | "convert"
          | "typeof"
          | "lambda"
          | "parameter"
          | "placeholder"
          | "named_argument"
          | "table_argument"
          | "sql_comment"
          | "null_safe_eq"
          | "null_safe_neq"
          | "glob"
          | "similar_to"
          | "any"
          | "all"
          | "overlaps"
          | "bitwise_left_shift"
          | "bitwise_right_shift"
          | "bitwise_and_agg"
          | "bitwise_or_agg"
          | "bitwise_xor_agg"
          | "subscript"
          | "dot"
          | "method_call"
          | "array_slice"
          | "create_table"
          | "drop_table"
          | "alter_table"
          | "create_index"
          | "drop_index"
          | "create_view"
          | "drop_view"
          | "alter_view"
          | "alter_index"
          | "truncate"
          | "use"
          | "cache"
          | "uncache"
          | "load_data"
          | "pragma"
          | "grant"
          | "revoke"
          | "comment"
          | "set_statement"
          | "create_schema"
          | "drop_schema"
          | "drop_namespace"
          | "create_database"
          | "drop_database"
          | "create_function"
          | "drop_function"
          | "create_procedure"
          | "drop_procedure"
          | "create_sequence"
          | "drop_sequence"
          | "alter_sequence"
          | "create_trigger"
          | "drop_trigger"
          | "create_type"
          | "drop_type"
          | "describe"
          | "show"
          | "command"
          | "kill"
          | "execute"
          | "raw"
          | "paren"
          | "annotated"
          | "refresh"
          | "locking_statement"
          | "sequence_properties"
          | "truncate_table"
          | "clone"
          | "attach"
          | "detach"
          | "install"
          | "summarize"
          | "declare"
          | "declare_item"
          | "heredoc"
          | "set_item"
          | "query_band"
          | "user_defined_function"
          | "recursive_with_search"
          | "projection_def"
          | "table_alias"
          | "hex_string_expr"
          | "unicode_string"
          | "column_position"
          | "column_def"
          | "alter_column"
          | "alter_sort_key"
          | "alter_set"
          | "rename_column"
          | "comprehension"
          | "merge_tree_t_t_l_action"
          | "merge_tree_t_t_l"
          | "index_constraint_option"
          | "column_constraint"
          | "period_for_system_time_constraint"
          | "case_specific_column_constraint"
          | "character_set_column_constraint"
          | "check_column_constraint"
          | "compress_column_constraint"
          | "date_format_column_constraint"
          | "ephemeral_column_constraint"
          | "with_operator"
          | "generated_as_identity_column_constraint"
          | "auto_increment_column_constraint"
          | "comment_column_constraint"
          | "generated_as_row_column_constraint"
          | "index_column_constraint"
          | "masking_policy_column_constraint"
          | "not_null_column_constraint"
          | "primary_key_column_constraint"
          | "unique_column_constraint"
          | "watermark_column_constraint"
          | "computed_column_constraint"
          | "in_out_column_constraint"
          | "default_column_constraint"
          | "path_column_constraint"
          | "constraint"
          | "export"
          | "filter"
          | "changes"
          | "copy_parameter"
          | "credentials"
          | "directory"
          | "foreign_key"
          | "column_prefix"
          | "primary_key"
          | "into_clause"
          | "join_hint"
          | "opclass"
          | "index"
          | "index_parameters"
          | "conditional_insert"
          | "multitable_inserts"
          | "on_conflict"
          | "on_condition"
          | "returning"
          | "introducer"
          | "partition_range"
          | "fetch"
          | "group"
          | "cube"
          | "rollup"
          | "grouping_sets"
          | "limit_options"
          | "lateral"
          | "table_from_rows"
          | "rows_from"
          | "match_recognize_measure"
          | "with_fill"
          | "property"
          | "grant_privilege"
          | "grant_principal"
          | "allowed_values_property"
          | "algorithm_property"
          | "auto_increment_property"
          | "auto_refresh_property"
          | "backup_property"
          | "build_property"
          | "block_compression_property"
          | "character_set_property"
          | "checksum_property"
          | "collate_property"
          | "data_blocksize_property"
          | "data_deletion_property"
          | "definer_property"
          | "dist_key_property"
          | "distributed_by_property"
          | "dist_style_property"
          | "duplicate_key_property"
          | "engine_property"
          | "to_table_property"
          | "execute_as_property"
          | "external_property"
          | "fallback_property"
          | "file_format_property"
          | "credentials_property"
          | "freespace_property"
          | "inherits_property"
          | "input_model_property"
          | "output_model_property"
          | "isolated_loading_property"
          | "journal_property"
          | "language_property"
          | "enviroment_property"
          | "clustered_by_property"
          | "dict_property"
          | "dict_range"
          | "on_cluster"
          | "like_property"
          | "location_property"
          | "lock_property"
          | "locking_property"
          | "log_property"
          | "materialized_property"
          | "merge_block_ratio_property"
          | "on_property"
          | "on_commit_property"
          | "partitioned_by_property"
          | "partitioned_by_bucket"
          | "partition_by_truncate"
          | "partition_by_range_property"
          | "partition_by_range_property_dynamic"
          | "partition_by_list_property"
          | "partition_list"
          | "partition"
          | "refresh_trigger_property"
          | "unique_key_property"
          | "rollup_property"
          | "partition_bound_spec"
          | "partitioned_of_property"
          | "remote_with_connection_model_property"
          | "returns_property"
          | "row_format_property"
          | "row_format_delimited_property"
          | "row_format_serde_property"
          | "query_transform"
          | "sample_property"
          | "security_property"
          | "schema_comment_property"
          | "semantic_view"
          | "serde_properties"
          | "set_property"
          | "sharing_property"
          | "set_config_property"
          | "settings_property"
          | "sort_key_property"
          | "sql_read_write_property"
          | "sql_security_property"
          | "stability_property"
          | "storage_handler_property"
          | "temporary_property"
          | "tags"
          | "transform_model_property"
          | "transient_property"
          | "using_template_property"
          | "view_attribute_property"
          | "volatile_property"
          | "with_data_property"
          | "with_journal_table_property"
          | "with_schema_binding_property"
          | "with_system_versioning_property"
          | "with_procedure_options"
          | "encode_property"
          | "include_property"
          | "properties"
          | "input_output_format"
          | "reference"
          | "query_option"
          | "with_table_hint"
          | "index_table_hint"
          | "historical_data"
          | "get"
          | "set_operation"
          | "var"
          | "version"
          | "schema"
          | "lock"
          | "table_sample"
          | "tag"
          | "unpivot_columns"
          | "window_spec"
          | "session_parameter"
          | "pseudo_type"
          | "object_identifier"
          | "transaction"
          | "commit"
          | "rollback"
          | "alter_session"
          | "analyze"
          | "analyze_statistics"
          | "analyze_histogram"
          | "analyze_sample"
          | "analyze_list_chained_rows"
          | "analyze_delete"
          | "analyze_with"
          | "analyze_validate"
          | "add_partition"
          | "attach_option"
          | "drop_partition"
          | "replace_partition"
          | "d_pipe"
          | "operator"
          | "pivot_any"
          | "aliases"
          | "at_index"
          | "from_time_zone"
          | "format_phrase"
          | "for_in"
          | "time_unit"
          | "interval_op"
          | "interval_span"
          | "having_max"
          | "cosine_distance"
          | "dot_product"
          | "euclidean_distance"
          | "manhattan_distance"
          | "jarowinkler_similarity"
          | "booland"
          | "boolor"
          | "parameterized_agg"
          | "arg_max"
          | "arg_min"
          | "approx_top_k"
          | "approx_top_k_accumulate"
          | "approx_top_k_combine"
          | "approx_top_k_estimate"
          | "approx_top_sum"
          | "approx_quantiles"
          | "minhash"
          | "farm_fingerprint"
          | "float64"
          | "transform"
          | "translate"
          | "grouping"
          | "grouping_id"
          | "anonymous"
          | "anonymous_agg_func"
          | "combined_agg_func"
          | "combined_parameterized_agg"
          | "hash_agg"
          | "hll"
          | "apply"
          | "to_boolean"
          | "to_map"
          | "pad"
          | "to_char"
          | "to_number"
          | "to_double"
          | "int64"
          | "string_func"
          | "to_decfloat"
          | "try_to_decfloat"
          | "to_file"
          | "columns"
          | "convert_to_charset"
          | "convert_timezone"
          | "generate_series"
          | "a_i_agg"
          | "a_i_classify"
          | "array_all"
          | "array_any"
          | "array_construct_compact"
          | "st_point"
          | "st_distance"
          | "string_to_array"
          | "array_sum"
          | "object_agg"
          | "cast_to_str_type"
          | "check_json"
          | "check_xml"
          | "translate_characters"
          | "current_schemas"
          | "current_datetime"
          | "localtime"
          | "localtimestamp"
          | "systimestamp"
          | "current_schema"
          | "current_user"
          | "utc_time"
          | "utc_timestamp"
          | "date_bin"
          | "datetime_add"
          | "datetime_sub"
          | "datetime_diff"
          | "datetime_trunc"
          | "dayname"
          | "make_interval"
          | "previous_day"
          | "elt"
          | "timestamp_add"
          | "timestamp_sub"
          | "timestamp_diff"
          | "time_slice"
          | "time_add"
          | "time_sub"
          | "time_diff"
          | "time_trunc"
          | "date_from_parts"
          | "time_from_parts"
          | "decode_case"
          | "decrypt"
          | "decrypt_raw"
          | "encode"
          | "encrypt"
          | "encrypt_raw"
          | "equal_null"
          | "to_binary"
          | "base64_decode_binary"
          | "base64_decode_string"
          | "base64_encode"
          | "try_base64_decode_binary"
          | "try_base64_decode_string"
          | "gap_fill"
          | "generate_date_array"
          | "generate_timestamp_array"
          | "get_extract"
          | "getbit"
          | "overflow_truncate_behavior"
          | "hex_encode"
          | "compress"
          | "decompress_binary"
          | "decompress_string"
          | "xor"
          | "nullif"
          | "j_s_o_n"
          | "j_s_o_n_path"
          | "j_s_o_n_path_filter"
          | "j_s_o_n_path_key"
          | "j_s_o_n_path_recursive"
          | "j_s_o_n_path_script"
          | "j_s_o_n_path_slice"
          | "j_s_o_n_path_selector"
          | "j_s_o_n_path_subscript"
          | "j_s_o_n_path_union"
          | "format"
          | "j_s_o_n_keys"
          | "j_s_o_n_key_value"
          | "j_s_o_n_keys_at_depth"
          | "j_s_o_n_object"
          | "j_s_o_n_object_agg"
          | "j_s_o_n_b_object_agg"
          | "j_s_o_n_array"
          | "j_s_o_n_array_agg"
          | "j_s_o_n_exists"
          | "j_s_o_n_column_def"
          | "j_s_o_n_schema"
          | "j_s_o_n_set"
          | "j_s_o_n_strip_nulls"
          | "j_s_o_n_value"
          | "j_s_o_n_value_array"
          | "j_s_o_n_remove"
          | "j_s_o_n_table"
          | "j_s_o_n_type"
          | "object_insert"
          | "open_j_s_o_n_column_def"
          | "open_j_s_o_n"
          | "j_s_o_n_b_exists"
          | "j_s_o_n_b_contains"
          | "j_s_o_n_b_extract"
          | "j_s_o_n_cast"
          | "j_s_o_n_extract"
          | "j_s_o_n_extract_quote"
          | "j_s_o_n_extract_array"
          | "j_s_o_n_extract_scalar"
          | "j_s_o_n_b_extract_scalar"
          | "j_s_o_n_format"
          | "j_s_o_n_bool"
          | "j_s_o_n_path_root"
          | "j_s_o_n_array_append"
          | "j_s_o_n_array_contains"
          | "j_s_o_n_array_insert"
          | "parse_j_s_o_n"
          | "parse_url"
          | "parse_ip"
          | "parse_time"
          | "parse_datetime"
          | "map_cat"
          | "map_delete"
          | "map_insert"
          | "map_pick"
          | "scope_resolution"
          | "slice"
          | "var_map"
          | "match_against"
          | "m_d5_digest"
          | "m_d5_number_lower64"
          | "m_d5_number_upper64"
          | "monthname"
          | "ntile"
          | "normalize"
          | "normal"
          | "predict"
          | "m_l_translate"
          | "features_at_time"
          | "generate_embedding"
          | "m_l_forecast"
          | "model_attribute"
          | "vector_search"
          | "quantile"
          | "approx_quantile"
          | "approx_percentile_estimate"
          | "randn"
          | "randstr"
          | "range_n"
          | "range_bucket"
          | "read_c_s_v"
          | "read_parquet"
          | "reduce"
          | "regexp_extract_all"
          | "regexp_i_like"
          | "regexp_full_match"
          | "regexp_instr"
          | "regexp_split"
          | "regexp_count"
          | "regr_valx"
          | "regr_valy"
          | "regr_avgy"
          | "regr_avgx"
          | "regr_count"
          | "regr_intercept"
          | "regr_r2"
          | "regr_sxx"
          | "regr_sxy"
          | "regr_syy"
          | "regr_slope"
          | "safe_add"
          | "safe_divide"
          | "safe_multiply"
          | "safe_subtract"
          | "s_h_a2"
          | "s_h_a2_digest"
          | "sort_array"
          | "split_part"
          | "substring_index"
          | "standard_hash"
          | "str_position"
          | "search"
          | "search_ip"
          | "str_to_date"
          | "date_str_to_date"
          | "date_to_date_str"
          | "str_to_time"
          | "str_to_unix"
          | "str_to_map"
          | "number_to_str"
          | "from_base"
          | "stuff"
          | "time_to_str"
          | "time_str_to_time"
          | "ts_or_ds_add"
          | "ts_or_ds_diff"
          | "ts_or_ds_to_date"
          | "ts_or_ds_to_time"
          | "unhex"
          | "uniform"
          | "unix_to_str"
          | "unix_to_time"
          | "timestamp_from_parts"
          | "timestamp_tz_from_parts"
          | "corr"
          | "width_bucket"
          | "covar_samp"
          | "covar_pop"
          | "week"
          | "x_m_l_element"
          | "x_m_l_get"
          | "x_m_l_table"
          | "x_m_l_key_value_option"
          | "zipf"
          | "merge"
          | "when"
          | "whens"
          | "next_value_for"
          | "return_stmt"

      const expr = parse("SELECT 1")[0];
      getExprType(expr) // => "select"