17 #ifndef QUERYENGINE_CALCITEDESERIALIZERUTILS_H
18 #define QUERYENGINE_CALCITEDESERIALIZERUTILS_H
23 #include "../Shared/sqldefs.h"
24 #include "../Shared/sqltypes.h"
28 if (op_str == std::string(
">")) {
31 if (op_str == std::string(
"IS NOT DISTINCT FROM")) {
34 if (op_str == std::string(
">=")) {
37 if (op_str == std::string(
"<")) {
40 if (op_str == std::string(
"<=")) {
43 if (op_str == std::string(
"=")) {
46 if (op_str == std::string(
"<>")) {
49 if (op_str == std::string(
"+")) {
52 if (op_str == std::string(
"-")) {
55 if (op_str == std::string(
"*")) {
58 if (op_str == std::string(
"/")) {
61 if (op_str ==
"MOD") {
64 if (op_str == std::string(
"AND")) {
67 if (op_str == std::string(
"OR")) {
70 if (op_str == std::string(
"CAST")) {
73 if (op_str == std::string(
"ENCODE_TEXT")) {
76 if (op_str == std::string(
"NOT")) {
79 if (op_str == std::string(
"IS NULL")) {
82 if (op_str == std::string(
"IS NOT NULL")) {
85 if (op_str == std::string(
"PG_UNNEST")) {
88 if (op_str == std::string(
"PG_ANY") || op_str == std::string(
"PG_ALL")) {
89 throw std::runtime_error(
"Invalid use of " + op_str +
" operator");
91 if (op_str == std::string(
"IN")) {
98 if (agg_name == std::string(
"COUNT")) {
101 if (agg_name == std::string(
"MIN")) {
104 if (agg_name == std::string(
"MAX")) {
107 if (agg_name == std::string(
"SUM")) {
110 if (agg_name == std::string(
"AVG")) {
113 if (agg_name == std::string(
"APPROX_COUNT_DISTINCT")) {
116 if (agg_name ==
"APPROX_MEDIAN" || agg_name ==
"APPROX_PERCENTILE" ||
117 agg_name ==
"APPROX_QUANTILE") {
120 if (agg_name == std::string(
"ANY_VALUE") || agg_name == std::string(
"SAMPLE") ||
121 agg_name == std::string(
"LAST_SAMPLE")) {
124 if (agg_name == std::string(
"SINGLE_VALUE")) {
127 if (agg_name ==
"MODE") {
130 if (agg_name ==
"COUNT_IF") {
133 if (agg_name ==
"SUM_IF") {
136 throw std::runtime_error(
"Aggregate function " + agg_name +
" not supported");
140 if (type_name == std::string(
"BIGINT")) {
143 if (type_name == std::string(
"INTEGER")) {
146 if (type_name == std::string(
"TINYINT")) {
149 if (type_name == std::string(
"SMALLINT")) {
152 if (type_name == std::string(
"FLOAT")) {
155 if (type_name == std::string(
"REAL")) {
158 if (type_name == std::string(
"DOUBLE")) {
161 if (type_name == std::string(
"DECIMAL")) {
164 if (type_name == std::string(
"CHAR") || type_name == std::string(
"VARCHAR") ||
165 type_name == std::string(
"SYMBOL")) {
168 if (type_name == std::string(
"BOOLEAN")) {
171 if (type_name == std::string(
"TIMESTAMP")) {
174 if (type_name == std::string(
"DATE")) {
177 if (type_name == std::string(
"TIME")) {
180 if (type_name == std::string(
"NULL")) {
183 if (type_name == std::string(
"ARRAY")) {
186 if (type_name == std::string(
"INTERVAL_DAY") ||
187 type_name == std::string(
"INTERVAL_HOUR") ||
188 type_name == std::string(
"INTERVAL_MINUTE") ||
189 type_name == std::string(
"INTERVAL_SECOND")) {
192 if (type_name == std::string(
"INTERVAL_MONTH") ||
193 type_name == std::string(
"INTERVAL_YEAR")) {
196 if (type_name == std::string(
"ANY")) {
199 if (type_name == std::string(
"TEXT")) {
202 if (type_name == std::string(
"POINT")) {
205 if (type_name == std::string(
"MULTIPOINT")) {
208 if (type_name == std::string(
"LINESTRING")) {
211 if (type_name == std::string(
"MULTILINESTRING")) {
214 if (type_name == std::string(
"POLYGON")) {
217 if (type_name == std::string(
"MULTIPOLYGON")) {
220 if (type_name == std::string(
"GEOMETRY")) {
223 if (type_name == std::string(
"GEOGRAPHY")) {
227 throw std::runtime_error(
"Unsupported type: " + type_name);
248 #endif // QUERYENGINE_CALCITEDESERIALIZERUTILS_H
SQLTypes to_sql_type(const std::string &type_name)
SQLAgg to_agg_kind(const std::string &agg_name)
SQLTypeInfo get_agg_type(const SQLAgg agg_kind, const Analyzer::Expr *arg_expr)
ExtractField to_datepart_field(const std::string &field)
SQLOps to_sql_op(const std::string &op_str)
DatetruncField to_datediff_field(const std::string &field)
std::shared_ptr< Analyzer::Constant > make_fp_constant(const int64_t val, const SQLTypeInfo &ti)
constexpr auto type_name() noexcept
DateaddField to_dateadd_field(const std::string &field)