19 #include "../Analyzer/Analyzer.h"
22 #include <boost/algorithm/string.hpp>
47 throw std::runtime_error(
"SINGLE_VALUE not supported on '" +
54 UNREACHABLE() <<
"Unsupported agg_kind: " << agg_kind;
61 if (boost::iequals(field,
"year") || boost::iequals(field,
"yy") ||
62 boost::iequals(field,
"yyyy") || boost::iequals(field,
"sql_tsi_year")) {
64 }
else if (boost::iequals(field,
"quarter") || boost::iequals(field,
"qq") ||
65 boost::iequals(field,
"q") || boost::iequals(field,
"sql_tsi_quarter")) {
67 }
else if (boost::iequals(field,
"month") || boost::iequals(field,
"mm") ||
68 boost::iequals(field,
"m") || boost::iequals(field,
"sql_tsi_month")) {
70 }
else if (boost::iequals(field,
"dayofyear") || boost::iequals(field,
"dy") ||
71 boost::iequals(field,
"y")) {
73 }
else if (boost::iequals(field,
"day") || boost::iequals(field,
"dd") ||
74 boost::iequals(field,
"d") || boost::iequals(field,
"sql_tsi_day")) {
76 }
else if (boost::iequals(field,
"week") || boost::iequals(field,
"ww") ||
77 boost::iequals(field,
"w") || boost::iequals(field,
"sql_tsi_week")) {
79 }
else if (boost::iequals(field,
"week_sunday")) {
81 }
else if (boost::iequals(field,
"week_saturday")) {
83 }
else if (boost::iequals(field,
"hour") || boost::iequals(field,
"hh") ||
84 boost::iequals(field,
"sql_tsi_hour")) {
86 }
else if (boost::iequals(field,
"minute") || boost::iequals(field,
"mi") ||
87 boost::iequals(field,
"n") || boost::iequals(field,
"sql_tsi_minute")) {
89 }
else if (boost::iequals(field,
"second") || boost::iequals(field,
"ss") ||
90 boost::iequals(field,
"s") || boost::iequals(field,
"sql_tsi_second")) {
92 }
else if (boost::iequals(field,
"millisecond") || boost::iequals(field,
"ms")) {
94 }
else if (boost::iequals(field,
"microsecond") || boost::iequals(field,
"us") ||
95 boost::iequals(field,
"sql_tsi_microsecond") ||
96 boost::iequals(field,
"frac_second")) {
98 }
else if (boost::iequals(field,
"nanosecond") || boost::iequals(field,
"ns") ||
99 boost::iequals(field,
"sql_tsi_frac_second")) {
101 }
else if (boost::iequals(field,
"weekday") || boost::iequals(field,
"dw")) {
103 }
else if (boost::iequals(field,
"quarterday") || boost::iequals(field,
"dq")) {
106 throw std::runtime_error(
"Unsupported field in DATEPART function: " + field);
113 if (boost::iequals(field,
"year") || boost::iequals(field,
"yy") ||
114 boost::iequals(field,
"yyyy") || boost::iequals(field,
"sql_tsi_year")) {
116 }
else if (boost::iequals(field,
"quarter") || boost::iequals(field,
"qq") ||
117 boost::iequals(field,
"q") || boost::iequals(field,
"sql_tsi_quarter")) {
119 }
else if (boost::iequals(field,
"month") || boost::iequals(field,
"mm") ||
120 boost::iequals(field,
"m") || boost::iequals(field,
"sql_tsi_month")) {
122 }
else if (boost::iequals(field,
"day") || boost::iequals(field,
"dd") ||
123 boost::iequals(field,
"d") || boost::iequals(field,
"sql_tsi_day")) {
125 }
else if (boost::iequals(field,
"week") || boost::iequals(field,
"ww") ||
126 boost::iequals(field,
"w") || boost::iequals(field,
"sql_tsi_week")) {
128 }
else if (boost::iequals(field,
"hour") || boost::iequals(field,
"hh") ||
129 boost::iequals(field,
"sql_tsi_hour")) {
131 }
else if (boost::iequals(field,
"minute") || boost::iequals(field,
"mi") ||
132 boost::iequals(field,
"n") || boost::iequals(field,
"sql_tsi_minute")) {
134 }
else if (boost::iequals(field,
"second") || boost::iequals(field,
"ss") ||
135 boost::iequals(field,
"s") || boost::iequals(field,
"sql_tsi_second")) {
137 }
else if (boost::iequals(field,
"millisecond") || boost::iequals(field,
"ms")) {
139 }
else if (boost::iequals(field,
"microsecond") || boost::iequals(field,
"us") ||
140 boost::iequals(field,
"sql_tsi_microsecond") ||
141 boost::iequals(field,
"frac_second")) {
143 }
else if (boost::iequals(field,
"nanosecond") || boost::iequals(field,
"ns") ||
144 boost::iequals(field,
"sql_tsi_frac_second")) {
146 }
else if (boost::iequals(field,
"weekday") || boost::iequals(field,
"dw")) {
148 }
else if (boost::iequals(field,
"decade") || boost::iequals(field,
"dc")) {
150 }
else if (boost::iequals(field,
"century")) {
152 }
else if (boost::iequals(field,
"millennium")) {
155 throw std::runtime_error(
"Unsupported field in DATEADD function: " + field);
162 if (boost::iequals(field,
"year") || boost::iequals(field,
"yy") ||
163 boost::iequals(field,
"yyyy") || boost::iequals(field,
"sql_tsi_year")) {
165 }
else if (boost::iequals(field,
"quarter") || boost::iequals(field,
"qq") ||
166 boost::iequals(field,
"q") || boost::iequals(field,
"sql_tsi_quarter")) {
168 }
else if (boost::iequals(field,
"month") || boost::iequals(field,
"mm") ||
169 boost::iequals(field,
"m") || boost::iequals(field,
"sql_tsi_month")) {
171 }
else if (boost::iequals(field,
"week") || boost::iequals(field,
"ww") ||
172 boost::iequals(field,
"w") || boost::iequals(field,
"sql_tsi_week")) {
174 }
else if (boost::iequals(field,
"week_sunday")) {
176 }
else if (boost::iequals(field,
"week_saturday")) {
178 }
else if (boost::iequals(field,
"day") || boost::iequals(field,
"dd") ||
179 boost::iequals(field,
"d") || boost::iequals(field,
"sql_tsi_day")) {
181 }
else if (boost::iequals(field,
"quarterday")) {
183 }
else if (boost::iequals(field,
"hour") || boost::iequals(field,
"hh") ||
184 boost::iequals(field,
"sql_tsi_hour")) {
186 }
else if (boost::iequals(field,
"minute") || boost::iequals(field,
"mi") ||
187 boost::iequals(field,
"n") || boost::iequals(field,
"sql_tsi_minute")) {
189 }
else if (boost::iequals(field,
"second") || boost::iequals(field,
"ss") ||
190 boost::iequals(field,
"s") || boost::iequals(field,
"sql_tsi_second")) {
192 }
else if (boost::iequals(field,
"millisecond") || boost::iequals(field,
"ms")) {
194 }
else if (boost::iequals(field,
"microsecond") || boost::iequals(field,
"us") ||
195 boost::iequals(field,
"sql_tsi_microsecond") ||
196 boost::iequals(field,
"frac_second")) {
198 }
else if (boost::iequals(field,
"nanosecond") || boost::iequals(field,
"ns") ||
199 boost::iequals(field,
"sql_tsi_frac_second")) {
201 }
else if (boost::iequals(field,
"decade") || boost::iequals(field,
"dc")) {
203 }
else if (boost::iequals(field,
"century")) {
205 }
else if (boost::iequals(field,
"millennium")) {
208 throw std::runtime_error(
"Unsupported field in DATEDIFF function: " + field);
226 return makeExpr<Analyzer::Constant>(ti,
false, d);
SQLTypeInfo get_agg_type(const SQLAgg agg_kind, const Analyzer::Expr *arg_expr)
HOST DEVICE SQLTypes get_type() const
ExtractField to_datepart_field(const std::string &field)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
DatetruncField to_datediff_field(const std::string &field)
const SQLTypeInfo & get_type_info() const
std::string get_type_name() const
std::shared_ptr< Analyzer::Constant > make_fp_constant(const int64_t val, const SQLTypeInfo &ti)
DateaddField to_dateadd_field(const std::string &field)