OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThriftSerializers.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
23 #ifndef QUERYENGINE_THRIFTSERIALIZERS_H
24 #define QUERYENGINE_THRIFTSERIALIZERS_H
25 
26 #include "gen-cpp/serialized_result_set_types.h"
27 
28 #include "Logger/Logger.h"
36 #include "Shared/TargetInfo.h"
38 #include "enums.h"
39 
40 namespace ThriftSerializers {
41 
42 #define THRIFT_LAYOUT_CASE(layout) \
43  case heavyai::QueryDescriptionType::layout: \
44  return TResultSetLayout::layout;
45 
47  const heavyai::QueryDescriptionType layout) {
48  switch (layout) {
53  default:
54  CHECK(false) << static_cast<int>(layout);
55  }
56  abort();
57 }
58 
59 #undef THRIFT_LAYOUT_CASE
60 
61 #define UNTHRIFT_LAYOUT_CASE(layout) \
62  case TResultSetLayout::layout: \
63  return heavyai::QueryDescriptionType::layout;
64 
65 inline heavyai::QueryDescriptionType layout_from_thrift(
66  const TResultSetLayout::type layout) {
67  switch (layout) {
72  default:
73  CHECK(false) << static_cast<int>(layout);
74  }
75  abort();
76 }
77 
78 #undef UNTHRIFT_LAYOUT_CASE
79 
80 #define THRIFT_AGGKIND_CASE(kind) \
81  case k##kind: \
82  return TAggKind::kind;
83 
85  switch (agg) {
91  THRIFT_AGGKIND_CASE(APPROX_COUNT_DISTINCT)
92  THRIFT_AGGKIND_CASE(SAMPLE)
93  THRIFT_AGGKIND_CASE(SINGLE_VALUE)
96  default:
97  CHECK(false) << static_cast<int>(agg);
98  }
99  abort();
100 }
101 
102 #undef THRIFT_AGGKIND_CASE
103 
104 #define UNTHRIFT_AGGKIND_CASE(kind) \
105  case TAggKind::kind: \
106  return k##kind;
107 
109  switch (agg) {
115  UNTHRIFT_AGGKIND_CASE(APPROX_COUNT_DISTINCT)
116  UNTHRIFT_AGGKIND_CASE(SAMPLE)
117  UNTHRIFT_AGGKIND_CASE(SINGLE_VALUE)
120  default:
121  CHECK(false) << static_cast<int>(agg);
122  }
123  abort();
124 }
125 
126 #undef UNTHRIFT_AGGKIND_CASE
127 
129  const std::vector<TColumnRange>& thrift_column_ranges) {
130  AggregatedColRange column_ranges;
131  for (const auto& thrift_column_range : thrift_column_ranges) {
132  PhysicalInput phys_input{thrift_column_range.col_id,
133  thrift_column_range.table_id,
134  thrift_column_range.db_id};
135  switch (thrift_column_range.type) {
136  case TExpressionRangeType::INTEGER:
137  column_ranges.setColRange(
138  phys_input,
139  ExpressionRange::makeIntRange(thrift_column_range.int_min,
140  thrift_column_range.int_max,
141  thrift_column_range.bucket,
142  thrift_column_range.has_nulls));
143  break;
144  case TExpressionRangeType::FLOAT:
145  column_ranges.setColRange(
146  phys_input,
147  ExpressionRange::makeFloatRange(thrift_column_range.fp_min,
148  thrift_column_range.fp_max,
149  thrift_column_range.has_nulls));
150  break;
151  case TExpressionRangeType::DOUBLE:
152  column_ranges.setColRange(
153  phys_input,
154  ExpressionRange::makeDoubleRange(thrift_column_range.fp_min,
155  thrift_column_range.fp_max,
156  thrift_column_range.has_nulls));
157  break;
159  column_ranges.setColRange(phys_input, ExpressionRange::makeInvalidRange());
160  break;
161  default:
162  CHECK(false);
163  }
164  }
165  return column_ranges;
166 }
167 
169  const std::vector<TDictionaryGeneration>& thrift_string_dictionary_generations) {
170  StringDictionaryGenerations string_dictionary_generations;
171  for (const auto& thrift_string_dictionary_generation :
172  thrift_string_dictionary_generations) {
173  string_dictionary_generations.setGeneration(
174  {thrift_string_dictionary_generation.db_id,
175  thrift_string_dictionary_generation.dict_id},
176  thrift_string_dictionary_generation.entry_count);
177  }
178  return string_dictionary_generations;
179 }
180 
181 inline TTypeInfo type_info_to_thrift(const SQLTypeInfo& ti) {
182  TTypeInfo thrift_ti;
183  thrift_ti.type =
185  thrift_ti.encoding = encoding_to_thrift(ti);
186  thrift_ti.nullable = !ti.get_notnull();
187  thrift_ti.is_array = ti.is_array();
188  // TODO: Properly serialize geospatial subtype. For now, the value in precision is the
189  // same as the value in scale; overload the precision field with the subtype of the
190  // geospatial type (currently kGEOMETRY or kGEOGRAPHY)
191  thrift_ti.precision =
192  IS_GEO(ti.get_type()) ? static_cast<int32_t>(ti.get_subtype()) : ti.get_precision();
193  thrift_ti.scale = ti.get_scale();
194  thrift_ti.comp_param = ti.get_comp_param();
195  thrift_ti.size = ti.get_size();
196 
197  if (ti.get_compression() == kENCODING_DICT) {
198  const auto& dict_key = ti.getStringDictKey();
199  TStringDictKey t_dict_key;
200  t_dict_key.db_id = dict_key.db_id;
201  t_dict_key.dict_id = dict_key.dict_id;
202  thrift_ti.__set_dict_key(t_dict_key);
203  }
204  return thrift_ti;
205 }
206 
207 inline bool takes_arg(const TargetInfo& target_info) {
208  return target_info.is_agg &&
209  (target_info.agg_kind != kCOUNT || is_distinct_target(target_info));
210 }
211 
212 inline std::vector<TargetMetaInfo> target_meta_infos_from_thrift(
213  const TRowDescriptor& row_desc) {
214  std::vector<TargetMetaInfo> target_meta_infos;
215  for (const auto& col : row_desc) {
216  target_meta_infos.emplace_back(col.col_name, type_info_from_thrift(col.col_type));
217  }
218  return target_meta_infos;
219 }
220 
221 inline void fixup_geo_column_descriptor(TColumnType& col_type,
222  const SQLTypes subtype,
223  const int output_srid) {
224  col_type.col_type.precision = static_cast<int>(subtype);
225  col_type.col_type.scale = output_srid;
226 }
227 
228 inline TColumnType target_meta_info_to_thrift(const TargetMetaInfo& target,
229  const size_t idx) {
230  TColumnType proj_info;
231  proj_info.col_name = target.get_resname();
232  if (proj_info.col_name.empty()) {
233  proj_info.col_name = "result_" + std::to_string(idx + 1);
234  }
235  const auto& target_ti = target.get_type_info();
236  proj_info.col_type.type = type_to_thrift(target_ti);
237  proj_info.col_type.encoding = encoding_to_thrift(target_ti);
238  proj_info.col_type.nullable = !target_ti.get_notnull();
239  proj_info.col_type.is_array = target_ti.get_type() == kARRAY;
240  if (IS_GEO(target_ti.get_type())) {
242  proj_info, target_ti.get_subtype(), target_ti.get_output_srid());
243  } else {
244  proj_info.col_type.precision = target_ti.get_precision();
245  proj_info.col_type.scale = target_ti.get_scale();
246  }
247  if (target_ti.get_type() == kDATE) {
248  proj_info.col_type.size = target_ti.get_size();
249  }
250  proj_info.col_type.comp_param =
251  (target_ti.is_date_in_days() && target_ti.get_comp_param() == 0)
252  ? 32
253  : target_ti.get_comp_param();
254 
255  if (target_ti.get_compression() == kENCODING_DICT) {
256  const auto& dict_key = target_ti.getStringDictKey();
257  TStringDictKey t_dict_key;
258  t_dict_key.db_id = dict_key.db_id;
259  t_dict_key.dict_id = dict_key.dict_id;
260  proj_info.col_type.__set_dict_key(t_dict_key);
261  }
262  return proj_info;
263 }
264 
265 inline TRowDescriptor target_meta_infos_to_thrift(
266  const std::vector<TargetMetaInfo>& targets) {
267  TRowDescriptor row_desc;
268  size_t i = 0;
269  for (const auto& target : targets) {
270  row_desc.push_back(target_meta_info_to_thrift(target, i));
271  ++i;
272  }
273  return row_desc;
274 }
275 
276 inline TTargetInfo target_info_to_thrift(const TargetInfo& target_info) {
277  TTargetInfo thrift_target_info;
278  thrift_target_info.is_agg = target_info.is_agg;
279  thrift_target_info.kind = agg_kind_to_thrift(target_info.agg_kind);
280  thrift_target_info.type = type_info_to_thrift(target_info.sql_type);
281  thrift_target_info.arg_type = takes_arg(target_info)
282  ? type_info_to_thrift(target_info.agg_arg_type)
283  : thrift_target_info.type;
284  thrift_target_info.skip_nulls = target_info.skip_null_val;
285  thrift_target_info.is_distinct = target_info.is_distinct;
286  return thrift_target_info;
287 }
288 
289 inline TargetInfo target_info_from_thrift(const TTargetInfo& thrift_target_info) {
290  TargetInfo target_info;
291  target_info.is_agg = thrift_target_info.is_agg;
292  target_info.agg_kind = agg_kind_from_thrift(thrift_target_info.kind);
293  target_info.sql_type = type_info_from_thrift(thrift_target_info.type);
294  target_info.is_distinct = thrift_target_info.is_distinct;
295  target_info.agg_arg_type = takes_arg(target_info)
296  ? type_info_from_thrift(thrift_target_info.arg_type)
297  : SQLTypeInfo(kNULLT, false);
298  target_info.skip_null_val = thrift_target_info.skip_nulls;
299  return target_info;
300 }
301 
302 inline std::vector<TTargetInfo> target_infos_to_thrift(
303  const std::vector<TargetInfo>& targets) {
304  std::vector<TTargetInfo> thrift_targets;
305  for (const auto& target_info : targets) {
306  thrift_targets.push_back(target_info_to_thrift(target_info));
307  }
308  return thrift_targets;
309 }
310 
311 inline std::vector<TargetInfo> target_infos_from_thrift(
312  const std::vector<TTargetInfo>& thrift_targets) {
313  std::vector<TargetInfo> targets;
314  for (const auto& thrift_target_info : thrift_targets) {
315  targets.push_back(target_info_from_thrift(thrift_target_info));
316  }
317  return targets;
318 }
319 
320 #define THRIFT_COUNTDESCRIPTORIMPL_CASE(kind) \
321  case CountDistinctImplType::kind: \
322  return TCountDistinctImplType::kind;
323 
325  const CountDistinctImplType impl_type) {
326  switch (impl_type) {
330  default:
331  CHECK(false);
332  }
333  abort();
334 }
335 
336 #undef THRIFT_COUNTDESCRIPTORIMPL_CASE
337 
338 inline TCountDistinctDescriptor count_distinct_descriptor_to_thrift(
339  const CountDistinctDescriptor& count_distinct_descriptor) {
340  TCountDistinctDescriptor thrift_count_distinct_descriptor;
341  thrift_count_distinct_descriptor.impl_type =
342  count_distinct_impl_type_to_thrift(count_distinct_descriptor.impl_type_);
343  thrift_count_distinct_descriptor.min_val = count_distinct_descriptor.min_val;
344  thrift_count_distinct_descriptor.bitmap_sz_bits =
345  count_distinct_descriptor.bitmap_sz_bits;
346  thrift_count_distinct_descriptor.approximate = count_distinct_descriptor.approximate;
347  thrift_count_distinct_descriptor.device_type =
348  count_distinct_descriptor.device_type == ExecutorDeviceType::GPU ? TDeviceType::GPU
349  : TDeviceType::CPU;
350  thrift_count_distinct_descriptor.sub_bitmap_count =
351  count_distinct_descriptor.sub_bitmap_count;
352  return thrift_count_distinct_descriptor;
353 }
354 
355 #define UNTHRIFT_COUNTDESCRIPTORIMPL_CASE(kind) \
356  case TCountDistinctImplType::kind: \
357  return CountDistinctImplType::kind;
358 
360  const TCountDistinctImplType::type impl_type) {
361  switch (impl_type) {
365  default:
366  CHECK(false);
367  }
368  abort();
369 }
370 
371 #undef UNTHRIFT_COUNTDESCRIPTORIMPL_CASE
372 
374  const TCountDistinctDescriptor& thrift_count_distinct_descriptor) {
375  CountDistinctDescriptor count_distinct_descriptor;
376  count_distinct_descriptor.impl_type_ =
377  count_distinct_impl_type_from_thrift(thrift_count_distinct_descriptor.impl_type);
378  count_distinct_descriptor.min_val = thrift_count_distinct_descriptor.min_val;
379  count_distinct_descriptor.bitmap_sz_bits =
380  thrift_count_distinct_descriptor.bitmap_sz_bits;
381  count_distinct_descriptor.approximate = thrift_count_distinct_descriptor.approximate;
382  count_distinct_descriptor.device_type =
383  thrift_count_distinct_descriptor.device_type == TDeviceType::GPU
386  count_distinct_descriptor.sub_bitmap_count =
387  thrift_count_distinct_descriptor.sub_bitmap_count;
388  return count_distinct_descriptor;
389 }
390 
392  switch (t) {
393  case TExtArgumentType::Int8:
394  return ExtArgumentType::Int8;
395  case TExtArgumentType::Int16:
396  return ExtArgumentType::Int16;
397  case TExtArgumentType::Int32:
398  return ExtArgumentType::Int32;
399  case TExtArgumentType::Int64:
400  return ExtArgumentType::Int64;
401  case TExtArgumentType::Float:
402  return ExtArgumentType::Float;
405  case TExtArgumentType::Void:
406  return ExtArgumentType::Void;
407  case TExtArgumentType::PInt8:
408  return ExtArgumentType::PInt8;
409  case TExtArgumentType::PInt16:
411  case TExtArgumentType::PInt32:
413  case TExtArgumentType::PInt64:
415  case TExtArgumentType::PFloat:
417  case TExtArgumentType::PDouble:
419  case TExtArgumentType::PBool:
420  return ExtArgumentType::PBool;
421  case TExtArgumentType::Bool:
422  return ExtArgumentType::Bool;
423  case TExtArgumentType::ArrayInt8:
425  case TExtArgumentType::ArrayInt16:
427  case TExtArgumentType::ArrayInt32:
429  case TExtArgumentType::ArrayInt64:
431  case TExtArgumentType::ArrayFloat:
433  case TExtArgumentType::ArrayDouble:
435  case TExtArgumentType::ArrayBool:
437  case TExtArgumentType::ArrayTextEncodingNone:
439  case TExtArgumentType::ArrayTextEncodingDict:
449  case TExtArgumentType::Cursor:
455  case TExtArgumentType::ColumnInt8:
457  case TExtArgumentType::ColumnInt16:
459  case TExtArgumentType::ColumnInt32:
461  case TExtArgumentType::ColumnInt64:
463  case TExtArgumentType::ColumnFloat:
465  case TExtArgumentType::ColumnDouble:
467  case TExtArgumentType::ColumnBool:
469  case TExtArgumentType::ColumnTextEncodingNone:
471  case TExtArgumentType::ColumnTextEncodingDict:
473  case TExtArgumentType::ColumnTimestamp:
475  case TExtArgumentType::TextEncodingNone:
477  case TExtArgumentType::TextEncodingDict:
479  case TExtArgumentType::Timestamp:
481  case TExtArgumentType::ColumnListInt8:
483  case TExtArgumentType::ColumnListInt16:
485  case TExtArgumentType::ColumnListInt32:
487  case TExtArgumentType::ColumnListInt64:
489  case TExtArgumentType::ColumnListFloat:
491  case TExtArgumentType::ColumnListDouble:
493  case TExtArgumentType::ColumnListBool:
495  case TExtArgumentType::ColumnListTextEncodingNone:
497  case TExtArgumentType::ColumnListTextEncodingDict:
499  case TExtArgumentType::ColumnArrayInt8:
501  case TExtArgumentType::ColumnArrayInt16:
503  case TExtArgumentType::ColumnArrayInt32:
505  case TExtArgumentType::ColumnArrayInt64:
507  case TExtArgumentType::ColumnArrayFloat:
509  case TExtArgumentType::ColumnArrayDouble:
511  case TExtArgumentType::ColumnArrayBool:
513  case TExtArgumentType::ColumnArrayTextEncodingNone:
515  case TExtArgumentType::ColumnArrayTextEncodingDict:
517  case TExtArgumentType::ColumnListArrayInt8:
519  case TExtArgumentType::ColumnListArrayInt16:
521  case TExtArgumentType::ColumnListArrayInt32:
523  case TExtArgumentType::ColumnListArrayInt64:
525  case TExtArgumentType::ColumnListArrayFloat:
527  case TExtArgumentType::ColumnListArrayDouble:
529  case TExtArgumentType::ColumnListArrayBool:
531  case TExtArgumentType::ColumnListArrayTextEncodingNone:
533  case TExtArgumentType::ColumnListArrayTextEncodingDict:
535  case TExtArgumentType::DayTimeInterval:
537  case TExtArgumentType::YearMonthTimeInterval:
539  case TExtArgumentType::ColumnGeoPoint:
541  case TExtArgumentType::ColumnGeoLineString:
543  case TExtArgumentType::ColumnGeoPolygon:
545  case TExtArgumentType::ColumnGeoMultiPoint:
547  case TExtArgumentType::ColumnGeoMultiLineString:
549  case TExtArgumentType::ColumnGeoMultiPolygon:
551  case TExtArgumentType::ColumnListGeoPoint:
553  case TExtArgumentType::ColumnListGeoLineString:
555  case TExtArgumentType::ColumnListGeoPolygon:
557  case TExtArgumentType::ColumnListGeoMultiPoint:
559  case TExtArgumentType::ColumnListGeoMultiLineString:
561  case TExtArgumentType::ColumnListGeoMultiPolygon:
563  }
564  UNREACHABLE();
565  return ExtArgumentType{};
566 }
567 
569  switch (t) {
571  return TExtArgumentType::Int8;
573  return TExtArgumentType::Int16;
575  return TExtArgumentType::Int32;
577  return TExtArgumentType::Int64;
579  return TExtArgumentType::Float;
583  return TExtArgumentType::Void;
585  return TExtArgumentType::PInt8;
587  return TExtArgumentType::PInt16;
589  return TExtArgumentType::PInt32;
591  return TExtArgumentType::PInt64;
593  return TExtArgumentType::PFloat;
595  return TExtArgumentType::PDouble;
597  return TExtArgumentType::PBool;
599  return TExtArgumentType::Bool;
601  return TExtArgumentType::ArrayInt8;
603  return TExtArgumentType::ArrayInt16;
605  return TExtArgumentType::ArrayInt32;
607  return TExtArgumentType::ArrayInt64;
609  return TExtArgumentType::ArrayFloat;
611  return TExtArgumentType::ArrayDouble;
613  return TExtArgumentType::ArrayBool;
615  return TExtArgumentType::ArrayTextEncodingNone;
617  return TExtArgumentType::ArrayTextEncodingDict;
627  return TExtArgumentType::Cursor;
633  return TExtArgumentType::ColumnInt8;
635  return TExtArgumentType::ColumnInt16;
637  return TExtArgumentType::ColumnInt32;
639  return TExtArgumentType::ColumnInt64;
641  return TExtArgumentType::ColumnFloat;
643  return TExtArgumentType::ColumnDouble;
645  return TExtArgumentType::ColumnBool;
647  return TExtArgumentType::ColumnTextEncodingNone;
649  return TExtArgumentType::ColumnTextEncodingDict;
651  return TExtArgumentType::ColumnTimestamp;
653  return TExtArgumentType::TextEncodingNone;
655  return TExtArgumentType::TextEncodingDict;
657  return TExtArgumentType::Timestamp;
659  return TExtArgumentType::ColumnListInt8;
661  return TExtArgumentType::ColumnListInt16;
663  return TExtArgumentType::ColumnListInt32;
665  return TExtArgumentType::ColumnListInt64;
667  return TExtArgumentType::ColumnListFloat;
669  return TExtArgumentType::ColumnListDouble;
671  return TExtArgumentType::ColumnListBool;
673  return TExtArgumentType::ColumnListTextEncodingNone;
675  return TExtArgumentType::ColumnListTextEncodingDict;
677  return TExtArgumentType::ColumnArrayInt8;
679  return TExtArgumentType::ColumnArrayInt16;
681  return TExtArgumentType::ColumnArrayInt32;
683  return TExtArgumentType::ColumnArrayInt64;
685  return TExtArgumentType::ColumnArrayFloat;
687  return TExtArgumentType::ColumnArrayDouble;
689  return TExtArgumentType::ColumnArrayBool;
691  return TExtArgumentType::ColumnArrayTextEncodingNone;
693  return TExtArgumentType::ColumnArrayTextEncodingDict;
695  return TExtArgumentType::ColumnListArrayInt8;
697  return TExtArgumentType::ColumnListArrayInt16;
699  return TExtArgumentType::ColumnListArrayInt32;
701  return TExtArgumentType::ColumnListArrayInt64;
703  return TExtArgumentType::ColumnListArrayFloat;
705  return TExtArgumentType::ColumnListArrayDouble;
707  return TExtArgumentType::ColumnListArrayBool;
709  return TExtArgumentType::ColumnListArrayTextEncodingDict;
711  return TExtArgumentType::ColumnListArrayTextEncodingNone;
713  return TExtArgumentType::DayTimeInterval;
715  return TExtArgumentType::YearMonthTimeInterval;
717  return TExtArgumentType::ColumnGeoPoint;
719  return TExtArgumentType::ColumnGeoLineString;
721  return TExtArgumentType::ColumnGeoPolygon;
723  return TExtArgumentType::ColumnGeoMultiPoint;
725  return TExtArgumentType::ColumnGeoMultiLineString;
727  return TExtArgumentType::ColumnGeoMultiPolygon;
729  return TExtArgumentType::ColumnListGeoPoint;
731  return TExtArgumentType::ColumnListGeoLineString;
733  return TExtArgumentType::ColumnListGeoPolygon;
735  return TExtArgumentType::ColumnListGeoMultiPoint;
737  return TExtArgumentType::ColumnListGeoMultiLineString;
739  return TExtArgumentType::ColumnListGeoMultiPolygon;
740  }
741  UNREACHABLE();
742  return TExtArgumentType::type{};
743 }
744 
745 inline std::vector<ExtArgumentType> from_thrift(
746  const std::vector<TExtArgumentType::type>& v) {
747  std::vector<ExtArgumentType> result;
749  v.begin(),
750  v.end(),
751  std::back_inserter(result),
752  [](TExtArgumentType::type c) -> ExtArgumentType { return from_thrift(c); });
753  return result;
754 }
755 
756 inline std::vector<TExtArgumentType::type> to_thrift(
757  const std::vector<ExtArgumentType>& v) {
758  std::vector<TExtArgumentType::type> result;
760  v.begin(),
761  v.end(),
762  std::back_inserter(result),
763  [](ExtArgumentType c) -> TExtArgumentType::type { return to_thrift(c); });
764  return result;
765 }
766 
768  const TOutputBufferSizeType::type& t) {
769  switch (t) {
770  case TOutputBufferSizeType::kConstant:
772  case TOutputBufferSizeType::kUserSpecifiedConstantParameter:
774  case TOutputBufferSizeType::kUserSpecifiedRowMultiplier:
776  case TOutputBufferSizeType::kTableFunctionSpecifiedParameter:
778  case TOutputBufferSizeType::kPreFlightParameter:
780  }
781  UNREACHABLE();
783 }
784 
787  switch (t) {
789  return TOutputBufferSizeType::kConstant;
791  return TOutputBufferSizeType::kUserSpecifiedConstantParameter;
793  return TOutputBufferSizeType::kUserSpecifiedRowMultiplier;
795  return TOutputBufferSizeType::kTableFunctionSpecifiedParameter;
797  return TOutputBufferSizeType::kPreFlightParameter;
798  }
799  UNREACHABLE();
801 }
802 
803 inline TUserDefinedFunction to_thrift(const ExtensionFunction& udf) {
804  TUserDefinedFunction tfunc;
805  tfunc.name = udf.getName(/* keep_suffix */ true);
806  tfunc.argTypes = to_thrift(udf.getInputArgs());
807  tfunc.retType = to_thrift(udf.getRet());
808  tfunc.annotations = udf.getAnnotations();
809  return tfunc;
810 }
811 
812 inline TUserDefinedTableFunction to_thrift(const table_functions::TableFunction& func) {
813  TUserDefinedTableFunction tfunc;
814  tfunc.name = func.getName();
815  tfunc.sizerType = to_thrift(func.getOutputRowSizeType());
816  tfunc.sizerArgPos = func.getOutputRowSizeParameter();
817  tfunc.inputArgTypes = to_thrift(func.getInputArgs());
818  tfunc.outputArgTypes = to_thrift(func.getOutputArgs());
819  tfunc.sqlArgTypes = to_thrift(func.getSqlArgs());
820  tfunc.annotations = func.getAnnotations();
821  return tfunc;
822 }
823 
824 inline std::vector<TUserDefinedTableFunction> to_thrift(
825  const std::vector<table_functions::TableFunction>& v) {
826  std::vector<TUserDefinedTableFunction> result;
827  std::transform(v.begin(),
828  v.end(),
829  std::back_inserter(result),
830  [](table_functions::TableFunction c) -> TUserDefinedTableFunction {
831  return to_thrift(c);
832  });
833  return result;
834 }
835 
836 } // namespace ThriftSerializers
837 
838 #endif // QUERYENGINE_THRIFTSERIALIZERS_H
TCountDistinctImplType::type count_distinct_impl_type_to_thrift(const CountDistinctImplType impl_type)
GroupByPerfectHash
Definition: enums.h:58
AggregatedColRange column_ranges_from_thrift(const std::vector< TColumnRange > &thrift_column_ranges)
std::vector< TTargetInfo > target_infos_to_thrift(const std::vector< TargetInfo > &targets)
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:392
SQLAgg
Definition: sqldefs.h:76
StringDictionaryGenerations string_dictionary_generations_from_thrift(const std::vector< TDictionaryGeneration > &thrift_string_dictionary_generations)
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
struct GeoLineStringStruct GeoLineString
Definition: heavydbTypes.h:999
Descriptor for the storage layout use for (approximate) count distinct operations.
TDatumType::type type_to_thrift(const SQLTypeInfo &type_info)
SQLTypes
Definition: sqltypes.h:65
#define UNTHRIFT_AGGKIND_CASE(kind)
TCountDistinctDescriptor count_distinct_descriptor_to_thrift(const CountDistinctDescriptor &count_distinct_descriptor)
TRowDescriptor target_meta_infos_to_thrift(const std::vector< TargetMetaInfo > &targets)
NonGroupedAggregate
Definition: enums.h:58
void setGeneration(const shared::StringDictKey &dict_key, const uint64_t generation)
struct GeoPointStruct GeoPoint
Definition: heavydbTypes.h:963
const ExtArgumentType getRet() const
TargetInfo target_info_from_thrift(const TTargetInfo &thrift_target_info)
SQLTypeInfo sql_type
Definition: TargetInfo.h:52
HOST DEVICE int get_scale() const
Definition: sqltypes.h:396
Cache for physical column ranges. Set by the aggregator on the leaves.
CountDistinctDescriptor count_distinct_descriptor_from_thrift(const TCountDistinctDescriptor &thrift_count_distinct_descriptor)
#define UNREACHABLE()
Definition: Logger.h:338
Projection
Definition: enums.h:58
ExtArgumentType from_thrift(const TExtArgumentType::type &t)
const std::string getName(bool keep_suffix=true) const
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
bool skip_null_val
Definition: TargetInfo.h:54
CountDistinctImplType impl_type_
const SQLTypeInfo & get_type_info() const
static ExpressionRange makeFloatRange(const float fp_min, const float fp_max, const bool has_nulls)
std::string to_string(char const *&&v)
SQLTypeInfo agg_arg_type
Definition: TargetInfo.h:53
std::vector< TargetInfo > target_infos_from_thrift(const std::vector< TTargetInfo > &thrift_targets)
Supported runtime functions management and retrieval.
bool is_agg
Definition: TargetInfo.h:50
bool is_distinct_target(const TargetInfo &target_info)
Definition: TargetInfo.h:102
const std::vector< ExtArgumentType > & getOutputArgs() const
OUTPUT transform(INPUT const &input, FUNC const &func)
Definition: misc.h:329
SQLTypeInfo type_info_from_thrift(const TTypeInfo &thrift_ti, const bool strip_geo_encoding=false)
SQLAgg agg_kind_from_thrift(const TAggKind::type agg)
std::string getName(const bool drop_suffix=false, const bool lower=false) const
SQLAgg agg_kind
Definition: TargetInfo.h:51
struct GeoMultiPointStruct GeoMultiPoint
Definition: heavydbTypes.h:981
int get_precision() const
Definition: sqltypes.h:394
static ExpressionRange makeIntRange(const int64_t int_min, const int64_t int_max, const int64_t bucket, const bool has_nulls)
void fixup_geo_column_descriptor(TColumnType &col_type, const SQLTypes subtype, const int output_srid)
#define THRIFT_COUNTDESCRIPTORIMPL_CASE(kind)
static ExpressionRange makeDoubleRange(const double fp_min, const double fp_max, const bool has_nulls)
Definition: sqltypes.h:80
TExtArgumentType::type to_thrift(const ExtArgumentType &t)
CountDistinctImplType count_distinct_impl_type_from_thrift(const TCountDistinctImplType::type impl_type)
struct GeoMultiLineStringStruct GeoMultiLineString
#define UNTHRIFT_COUNTDESCRIPTORIMPL_CASE(kind)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
heavyai::QueryDescriptionType layout_from_thrift(const TResultSetLayout::type layout)
const std::vector< ExtArgumentType > & getInputArgs() const
Definition: sqldefs.h:81
QueryEngine enum classes with minimal #include files.
GroupByBaselineHash
Definition: enums.h:58
const std::vector< ExtArgumentType > & getInputArgs() const
bool takes_arg(const TargetInfo &target_info)
TColumnType target_meta_info_to_thrift(const TargetMetaInfo &target, const size_t idx)
CountDistinctImplType
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:402
const std::vector< ExtArgumentType > & getSqlArgs() const
#define CHECK(condition)
Definition: Logger.h:291
SQLTypes type
Definition: sqltypes.h:1270
std::vector< TargetMetaInfo > target_meta_infos_from_thrift(const TRowDescriptor &row_desc)
TAggKind::type agg_kind_to_thrift(const SQLAgg agg)
void setColRange(const PhysicalInput &, const ExpressionRange &)
struct GeoMultiPolygonStruct GeoMultiPolygon
static ExpressionRange makeInvalidRange()
const std::string & get_resname() const
#define THRIFT_LAYOUT_CASE(layout)
bool is_distinct
Definition: TargetInfo.h:55
struct GeoPolygonStruct GeoPolygon
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398
const std::vector< std::map< std::string, std::string > > & getAnnotations() const
TTypeInfo type_info_to_thrift(const SQLTypeInfo &ti)
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:977
OutputBufferSizeType getOutputRowSizeType() const
#define UNTHRIFT_LAYOUT_CASE(layout)
#define IS_GEO(T)
Definition: sqltypes.h:310
#define THRIFT_AGGKIND_CASE(kind)
bool is_array() const
Definition: sqltypes.h:585
const std::vector< std::map< std::string, std::string > > & getAnnotations() const
TTargetInfo target_info_to_thrift(const TargetInfo &target_info)
const shared::StringDictKey & getStringDictKey() const
Definition: sqltypes.h:1057
TResultSetLayout::type layout_to_thrift(const heavyai::QueryDescriptionType layout)
TEncodingType::type encoding_to_thrift(const SQLTypeInfo &type_info)