sqltypes

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Date     = decls.NewAbstractType("DATE")
	Time     = decls.NewAbstractType("TIME")
	DateTime = decls.NewAbstractType("DATETIME")
	Interval = decls.NewAbstractType("INTERVAL")
	DatePart = decls.NewAbstractType("date_part")
)
View Source
var SQLTypeDeclarations = cel.Declarations(

	decls.NewConst("MICROSECOND", DatePart, newConstantString("MICROSECOND")),
	decls.NewConst("MILLISECOND", DatePart, newConstantString("MILLISECOND")),
	decls.NewConst("SECOND", DatePart, newConstantString("SECOND")),
	decls.NewConst("MINUTE", DatePart, newConstantString("MINUTE")),
	decls.NewConst("HOUR", DatePart, newConstantString("HOUR")),
	decls.NewConst("DAY", DatePart, newConstantString("DAY")),
	decls.NewConst("DAYOFWEEK", DatePart, newConstantString("DAYOFWEEK")),
	decls.NewConst("WEEK", DatePart, newConstantString("WEEK")),
	decls.NewConst("ISOWEEK", DatePart, newConstantString("ISOWEEK")),
	decls.NewConst("MONTH", DatePart, newConstantString("MONTH")),
	decls.NewConst("QUARTER", DatePart, newConstantString("QUARTER")),
	decls.NewConst("YEAR", DatePart, newConstantString("YEAR")),
	decls.NewConst("ISOYEAR", DatePart, newConstantString("ISOYEAR")),

	decls.NewFunction(overloads.TimeGetFullYear,
		decls.NewInstanceOverload("date_to_year", []*expr.Type{Date}, decls.Int),
		decls.NewInstanceOverload("datetime_to_year", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetMonth,
		decls.NewInstanceOverload("date_to_month", []*expr.Type{Date}, decls.Int),
		decls.NewInstanceOverload("datetime_to_month", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetDate,
		decls.NewInstanceOverload("date_to_date", []*expr.Type{Date}, decls.Int),
		decls.NewInstanceOverload("datetime_to_date", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetHours,
		decls.NewInstanceOverload("time_to_hours", []*expr.Type{Time}, decls.Int),
		decls.NewInstanceOverload("datetime_to_hours", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetMinutes,
		decls.NewInstanceOverload("time_to_minutes", []*expr.Type{Time}, decls.Int),
		decls.NewInstanceOverload("datetime_to_minutes", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetSeconds,
		decls.NewInstanceOverload("time_to_seconds", []*expr.Type{Time}, decls.Int),
		decls.NewInstanceOverload("datetime_to_seconds", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetMilliseconds,
		decls.NewInstanceOverload("time_to_milliseconds", []*expr.Type{Time}, decls.Int),
		decls.NewInstanceOverload("datetime_to_milliseconds", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetDayOfYear,
		decls.NewInstanceOverload("date_to_day_of_year", []*expr.Type{Date}, decls.Int),
		decls.NewInstanceOverload("datetime_to_day_of_year", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetDayOfMonth,
		decls.NewInstanceOverload("date_to_day_of_month", []*expr.Type{Date}, decls.Int),
		decls.NewInstanceOverload("datetime_to_day_of_month", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TimeGetDayOfWeek,
		decls.NewInstanceOverload("date_to_day_of_week", []*expr.Type{Date}, decls.Int),
		decls.NewInstanceOverload("datetime_to_day_of_week", []*expr.Type{DateTime}, decls.Int),
	),
	decls.NewFunction(overloads.TypeConvertBool,
		decls.NewOverload("int_to_bool", []*expr.Type{decls.Int}, decls.Bool),
		decls.NewOverload("uint_to_bool", []*expr.Type{decls.Uint}, decls.Bool),
	),
	decls.NewFunction(overloads.TypeConvertInt,
		decls.NewOverload("bool_to_int", []*expr.Type{decls.Bool}, decls.Int),
	),

	decls.NewFunction(operators.Less,
		decls.NewOverload("less_date", []*expr.Type{Date, Date}, decls.Bool),
		decls.NewOverload("less_time", []*expr.Type{Time, Time}, decls.Bool),
		decls.NewOverload("less_datetime", []*expr.Type{DateTime, DateTime}, decls.Bool),
	),
	decls.NewFunction(operators.LessEquals,
		decls.NewOverload("less_equals_date", []*expr.Type{Date, Date}, decls.Bool),
		decls.NewOverload("less_equals_time", []*expr.Type{Time, Time}, decls.Bool),
		decls.NewOverload("less_equals_datetime", []*expr.Type{DateTime, DateTime}, decls.Bool),
	),
	decls.NewFunction(operators.Greater,
		decls.NewOverload("greater_date", []*expr.Type{Date, Date}, decls.Bool),
		decls.NewOverload("greater_time", []*expr.Type{Time, Time}, decls.Bool),
		decls.NewOverload("greater_datetime", []*expr.Type{DateTime, DateTime}, decls.Bool),
	),
	decls.NewFunction(operators.GreaterEquals,
		decls.NewOverload("greater_equals_date", []*expr.Type{Date, Date}, decls.Bool),
		decls.NewOverload("greater_equals_time", []*expr.Type{Time, Time}, decls.Bool),
		decls.NewOverload("greater_equals_datetime", []*expr.Type{DateTime, DateTime}, decls.Bool),
	),
	decls.NewFunction(operators.Add,
		decls.NewOverload("add_date_int", []*expr.Type{Date, decls.Int}, Date),
		decls.NewOverload("add_int_date", []*expr.Type{decls.Int, Date}, Date),
	),
	decls.NewFunction(operators.Subtract,
		decls.NewOverload("subtract_date_int", []*expr.Type{Date, decls.Int}, Date),
	),
	decls.NewFunction(operators.Add,
		decls.NewOverload("add_date_interval", []*expr.Type{Date, Interval}, Date),
		decls.NewOverload("add_date_duration", []*expr.Type{Date, decls.Duration}, Date),
		decls.NewOverload("add_interval_date", []*expr.Type{Interval, Date}, Date),
		decls.NewOverload("add_duration_date", []*expr.Type{decls.Duration, Date}, Date),
		decls.NewOverload("add_time_interval", []*expr.Type{Time, Interval}, Time),
		decls.NewOverload("add_time_duration", []*expr.Type{Time, decls.Duration}, Time),
		decls.NewOverload("add_interval_time", []*expr.Type{Interval, Time}, Time),
		decls.NewOverload("add_duration_time", []*expr.Type{decls.Duration, Time}, Time),
		decls.NewOverload("add_datetime_interval", []*expr.Type{DateTime, Interval}, DateTime),
		decls.NewOverload("add_datetime_duration", []*expr.Type{DateTime, decls.Duration}, DateTime),
		decls.NewOverload("add_interval_datetime", []*expr.Type{Interval, DateTime}, DateTime),
		decls.NewOverload("add_duration_datetime", []*expr.Type{decls.Duration, DateTime}, DateTime),
		decls.NewOverload("add_timestamp_interval", []*expr.Type{decls.Timestamp, Interval}, decls.Timestamp),
		decls.NewOverload("add_interval_timestamp", []*expr.Type{Interval, decls.Timestamp}, decls.Timestamp),
	),
	decls.NewFunction(operators.Subtract,
		decls.NewOverload("subtract_date_interval", []*expr.Type{Date, Interval}, Date),
		decls.NewOverload("subtract_date_duration", []*expr.Type{Date, decls.Duration}, Date),
		decls.NewOverload("subtract_time_interval", []*expr.Type{Time, Interval}, Time),
		decls.NewOverload("subtract_time_duration", []*expr.Type{Time, decls.Duration}, Time),
		decls.NewOverload("subtract_datetime_interval", []*expr.Type{DateTime, Interval}, DateTime),
		decls.NewOverload("subtract_datetime_duration", []*expr.Type{DateTime, decls.Duration}, DateTime),
		decls.NewOverload("subtract_timestamp_interval", []*expr.Type{decls.Timestamp, Interval}, decls.Timestamp),
	),

	decls.NewFunction("interval",
		decls.NewOverload("interval_construct", []*expr.Type{decls.Int, DatePart}, Interval),
	),

	decls.NewFunction("date",
		decls.NewOverload("date_construct_year_month_day", []*expr.Type{decls.Int, decls.Int, decls.Int}, Date),
		decls.NewOverload("date_construct_string", []*expr.Type{decls.String}, Date),
	),
	decls.NewFunction("current_date",
		decls.NewOverload("current_date", []*expr.Type{}, Date),
		decls.NewOverload("current_date_timezone", []*expr.Type{decls.String}, Date),
	),

	decls.NewFunction("time",
		decls.NewOverload("time_construct_hour_minute_second", []*expr.Type{decls.Int, decls.Int, decls.Int}, Time),
		decls.NewOverload("time_construct_string", []*expr.Type{decls.String}, Time),
		decls.NewOverload("time_construct_datetime", []*expr.Type{DateTime}, Time),
		decls.NewOverload("time_construct_timestamp", []*expr.Type{decls.Timestamp}, Time),
		decls.NewOverload("time_construct_timestamp_timezone", []*expr.Type{decls.Timestamp, decls.String}, Time),
	),
	decls.NewFunction("current_time",
		decls.NewOverload("current_time", []*expr.Type{}, Time),
		decls.NewOverload("current_time_timezone", []*expr.Type{decls.String}, Time),
	),

	decls.NewFunction("datetime",
		decls.NewOverload("datetime_construct_year_month_day_hour_minute_second", []*expr.Type{decls.Int, decls.Int, decls.Int, decls.Int, decls.Int, decls.Int}, DateTime),
		decls.NewOverload("datetime_construct_string", []*expr.Type{decls.String}, DateTime),
		decls.NewOverload("datetime_construct_date", []*expr.Type{Date}, DateTime),
		decls.NewOverload("datetime_construct_date_time", []*expr.Type{Date, Time}, DateTime),
		decls.NewOverload("datetime_construct_timestamp", []*expr.Type{decls.Timestamp}, DateTime),
		decls.NewOverload("datetime_construct_timestamp_timezone", []*expr.Type{decls.Timestamp, decls.String}, DateTime),
	),
	decls.NewFunction("current_datetime",
		decls.NewOverload("current_datetime", []*expr.Type{}, DateTime),
		decls.NewOverload("current_datetime_timezone", []*expr.Type{decls.String}, DateTime),
	),

	decls.NewFunction("timestamp",
		decls.NewOverload("timestamp_construct_string_timezone", []*expr.Type{decls.String, decls.String}, decls.Timestamp),
		decls.NewOverload("timestamp_construct_date", []*expr.Type{Date}, decls.Timestamp),
		decls.NewOverload("timestamp_construct_date_timezone", []*expr.Type{Date, decls.String}, decls.Timestamp),
		decls.NewOverload("timestamp_construct_datetime", []*expr.Type{DateTime}, decls.Timestamp),
		decls.NewOverload("timestamp_construct_datetime_timezone", []*expr.Type{DateTime, decls.String}, decls.Timestamp),
	),
	decls.NewFunction("current_timestamp",
		decls.NewOverload("current_timestamp", []*expr.Type{}, decls.Timestamp),
	),

	decls.NewFunction("ascii",
		decls.NewOverload("string_ascii", []*expr.Type{decls.String}, decls.Int),
	),
	decls.NewFunction("unicode",
		decls.NewOverload("string_unicode", []*expr.Type{decls.String}, decls.Int),
	),
	decls.NewFunction("chr",
		decls.NewOverload("int_chr", []*expr.Type{decls.Int}, decls.String),
	),
	decls.NewFunction("code_points_to_bytes",
		decls.NewOverload("int_code_points_to_bytes", []*expr.Type{decls.NewListType(decls.Int)}, decls.Bytes),
	),
	decls.NewFunction("code_points_to_string",
		decls.NewOverload("int_code_points_to_string", []*expr.Type{decls.NewListType(decls.Int)}, decls.String),
	),
	decls.NewFunction("to_code_points",
		decls.NewOverload("string_to_code_points", []*expr.Type{decls.String}, decls.NewListType(decls.Int)),
		decls.NewOverload("bytes_to_code_points", []*expr.Type{decls.Bytes}, decls.NewListType(decls.Int)),
	),
	decls.NewFunction("from_base32",
		decls.NewOverload("string_from_base32", []*expr.Type{decls.String}, decls.Bytes),
	),
	decls.NewFunction("to_base32",
		decls.NewOverload("bytes_to_base32", []*expr.Type{decls.Bytes}, decls.String),
	),
	decls.NewFunction("from_base64",
		decls.NewOverload("string_from_base64", []*expr.Type{decls.String}, decls.Bytes),
	),
	decls.NewFunction("to_base64",
		decls.NewOverload("bytes_to_base64", []*expr.Type{decls.Bytes}, decls.String),
	),
	decls.NewFunction("from_hex",
		decls.NewOverload("string_from_hex", []*expr.Type{decls.String}, decls.Bytes),
	),
	decls.NewFunction("to_hex",
		decls.NewOverload("bytes_to_hex", []*expr.Type{decls.Bytes}, decls.String),
	),
	decls.NewFunction("split",
		decls.NewOverload("string_split", []*expr.Type{decls.String}, decls.NewListType(decls.String)),
		decls.NewOverload("string_split_delimiters", []*expr.Type{decls.String, decls.String}, decls.NewListType(decls.String)),
		decls.NewOverload("bytes_split_delimiters", []*expr.Type{decls.Bytes, decls.Bytes}, decls.NewListType(decls.Bytes)),
	),
	decls.NewFunction("lower",
		decls.NewOverload("string_lower", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("bytes_lower", []*expr.Type{decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("upper",
		decls.NewOverload("string_upper", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("bytes_upper", []*expr.Type{decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("initcap",
		decls.NewOverload("string_initcap", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("string_initcap_delimiters", []*expr.Type{decls.String, decls.String}, decls.String),
	),
	decls.NewFunction("instr",
		decls.NewOverload("string_instr", []*expr.Type{decls.String, decls.String}, decls.Int),
		decls.NewOverload("string_instr_position", []*expr.Type{decls.String, decls.String, decls.Int}, decls.Int),
		decls.NewOverload("string_instr_position_occurrence", []*expr.Type{decls.String, decls.String, decls.Int, decls.Int}, decls.Int),
		decls.NewOverload("bytes_instr", []*expr.Type{decls.Bytes, decls.Bytes}, decls.Int),
		decls.NewOverload("bytes_instr_position", []*expr.Type{decls.Bytes, decls.Bytes, decls.Int}, decls.Int),
		decls.NewOverload("bytes_instr_position_occurrence", []*expr.Type{decls.Bytes, decls.Bytes, decls.Int, decls.Int}, decls.Int),
	),
	decls.NewFunction("strpos",
		decls.NewOverload("string_strpos", []*expr.Type{decls.String, decls.String}, decls.Int),
		decls.NewOverload("bytes_strpos", []*expr.Type{decls.Bytes, decls.Bytes}, decls.Int),
	),
	decls.NewFunction("left",
		decls.NewOverload("string_left", []*expr.Type{decls.String, decls.Int}, decls.String),
		decls.NewOverload("bytes_left", []*expr.Type{decls.Bytes, decls.Int}, decls.Bytes),
	),
	decls.NewFunction("right",
		decls.NewOverload("string_right", []*expr.Type{decls.String, decls.Int}, decls.String),
		decls.NewOverload("bytes_right", []*expr.Type{decls.Bytes, decls.Int}, decls.Bytes),
	),
	decls.NewFunction("substr",
		decls.NewOverload("string_substr", []*expr.Type{decls.String, decls.Int}, decls.String),
		decls.NewOverload("string_substr_length", []*expr.Type{decls.String, decls.Int, decls.Int}, decls.String),
		decls.NewOverload("bytes_substr", []*expr.Type{decls.Bytes, decls.Int}, decls.Bytes),
		decls.NewOverload("bytes_substr_length", []*expr.Type{decls.Bytes, decls.Int, decls.Int}, decls.Bytes),
	),
	decls.NewFunction("lpad",
		decls.NewOverload("string_lpad", []*expr.Type{decls.String, decls.Int}, decls.String),
		decls.NewOverload("string_lpad_pattern", []*expr.Type{decls.String, decls.Int, decls.String}, decls.String),
		decls.NewOverload("bytes_lpad", []*expr.Type{decls.Bytes, decls.Int}, decls.Bytes),
		decls.NewOverload("bytes_lpad_pattern", []*expr.Type{decls.Bytes, decls.Int, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("rpad",
		decls.NewOverload("string_rpad", []*expr.Type{decls.String, decls.Int}, decls.String),
		decls.NewOverload("string_rpad_pattern", []*expr.Type{decls.String, decls.Int, decls.String}, decls.String),
		decls.NewOverload("bytes_rpad", []*expr.Type{decls.Bytes, decls.Int}, decls.Bytes),
		decls.NewOverload("bytes_rpad_pattern", []*expr.Type{decls.Bytes, decls.Int, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("ltrim",
		decls.NewOverload("string_ltrim", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("string_ltrim_pattern", []*expr.Type{decls.String, decls.String}, decls.String),
		decls.NewOverload("bytes_ltrim_pattern", []*expr.Type{decls.Bytes, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("rtrim",
		decls.NewOverload("string_rtrim", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("string_rtrim_pattern", []*expr.Type{decls.String, decls.String}, decls.String),
		decls.NewOverload("bytes_rtrim_pattern", []*expr.Type{decls.Bytes, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("trim",
		decls.NewOverload("string_trim", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("string_trim_pattern", []*expr.Type{decls.String, decls.String}, decls.String),
		decls.NewOverload("bytes_trim_pattern", []*expr.Type{decls.Bytes, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("regexp_extract",
		decls.NewOverload("string_regexp_extract", []*expr.Type{decls.String, decls.String}, decls.String),
		decls.NewOverload("string_regexp_extract_position", []*expr.Type{decls.String, decls.String, decls.Int}, decls.String),
		decls.NewOverload("string_regexp_extract_position_occurrence", []*expr.Type{decls.String, decls.String, decls.Int, decls.Int}, decls.String),
	),
	decls.NewFunction("regexp_extract_all",
		decls.NewOverload("string_regexp_extract_all", []*expr.Type{decls.String, decls.String}, decls.NewListType(decls.String)),
	),
	decls.NewFunction("regexp_instr",
		decls.NewOverload("string_regexp_instr", []*expr.Type{decls.String, decls.String}, decls.Int),
		decls.NewOverload("string_regexp_instr_position", []*expr.Type{decls.String, decls.String, decls.Int}, decls.Int),
		decls.NewOverload("string_regexp_instr_position_occurrence", []*expr.Type{decls.String, decls.String, decls.Int, decls.Int}, decls.Int),
		decls.NewOverload("string_regexp_instr_position_occurrence_occurrence_position", []*expr.Type{decls.String, decls.String, decls.Int, decls.Int, decls.Int}, decls.Int),
	),
	decls.NewFunction("regexp_replace",
		decls.NewOverload("string_regexp_replace", []*expr.Type{decls.String, decls.String, decls.String}, decls.String),
	),
	decls.NewFunction("replace",
		decls.NewOverload("string_replace", []*expr.Type{decls.String, decls.String, decls.String}, decls.String),
		decls.NewOverload("bytes_replace", []*expr.Type{decls.Bytes, decls.Bytes, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("translate",
		decls.NewOverload("string_translate", []*expr.Type{decls.String, decls.String, decls.String}, decls.String),
		decls.NewOverload("bytes_translate", []*expr.Type{decls.Bytes, decls.Bytes, decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("repeat",
		decls.NewOverload("string_repeat", []*expr.Type{decls.String, decls.Int}, decls.String),
		decls.NewOverload("bytes_repeat", []*expr.Type{decls.Bytes, decls.Int}, decls.Bytes),
	),
	decls.NewFunction("reverse",
		decls.NewOverload("string_reverse", []*expr.Type{decls.String}, decls.String),
		decls.NewOverload("bytes_reverse", []*expr.Type{decls.Bytes}, decls.Bytes),
	),
	decls.NewFunction("safe_convert_bytes_to_string",
		decls.NewOverload("bytes_safe_convert_bytes_to_string", []*expr.Type{decls.Bytes}, decls.String),
	),
	decls.NewFunction("soundex",
		decls.NewOverload("bytes_soundex", []*expr.Type{decls.String}, decls.String),
	),
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL