OmniSciDB  72c90bc290
 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"
38 
39 namespace ThriftSerializers {
40 
41 #define THRIFT_LAYOUT_CASE(layout) \
42  case QueryDescriptionType::layout: \
43  return TResultSetLayout::layout;
44 
46  switch (layout) {
51  default:
52  CHECK(false) << static_cast<int>(layout);
53  }
54  abort();
55 }
56 
57 #undef THRIFT_LAYOUT_CASE
58 
59 #define UNTHRIFT_LAYOUT_CASE(layout) \
60  case TResultSetLayout::layout: \
61  return QueryDescriptionType::layout;
62 
64  switch (layout) {
69  default:
70  CHECK(false) << static_cast<int>(layout);
71  }
72  abort();
73 }
74 
75 #undef UNTHRIFT_LAYOUT_CASE
76 
77 #define THRIFT_AGGKIND_CASE(kind) \
78  case k##kind: \
79  return TAggKind::kind;
80 
82  switch (agg) {
88  THRIFT_AGGKIND_CASE(APPROX_COUNT_DISTINCT)
89  THRIFT_AGGKIND_CASE(SAMPLE)
90  THRIFT_AGGKIND_CASE(SINGLE_VALUE)
93  default:
94  CHECK(false) << static_cast<int>(agg);
95  }
96  abort();
97 }
98 
99 #undef THRIFT_AGGKIND_CASE
100 
101 #define UNTHRIFT_AGGKIND_CASE(kind) \
102  case TAggKind::kind: \
103  return k##kind;
104 
106  switch (agg) {
112  UNTHRIFT_AGGKIND_CASE(APPROX_COUNT_DISTINCT)
113  UNTHRIFT_AGGKIND_CASE(SAMPLE)
114  UNTHRIFT_AGGKIND_CASE(SINGLE_VALUE)
117  default:
118  CHECK(false) << static_cast<int>(agg);
119  }
120  abort();
121 }
122 
123 #undef UNTHRIFT_AGGKIND_CASE
124 
126  const std::vector<TColumnRange>& thrift_column_ranges) {
127  AggregatedColRange column_ranges;
128  for (const auto& thrift_column_range : thrift_column_ranges) {
129  PhysicalInput phys_input{thrift_column_range.col_id,
130  thrift_column_range.table_id,
131  thrift_column_range.db_id};
132  switch (thrift_column_range.type) {
133  case TExpressionRangeType::INTEGER:
134  column_ranges.setColRange(
135  phys_input,
136  ExpressionRange::makeIntRange(thrift_column_range.int_min,
137  thrift_column_range.int_max,
138  thrift_column_range.bucket,
139  thrift_column_range.has_nulls));
140  break;
141  case TExpressionRangeType::FLOAT:
142  column_ranges.setColRange(
143  phys_input,
144  ExpressionRange::makeFloatRange(thrift_column_range.fp_min,
145  thrift_column_range.fp_max,
146  thrift_column_range.has_nulls));
147  break;
148  case TExpressionRangeType::DOUBLE:
149  column_ranges.setColRange(
150  phys_input,
151  ExpressionRange::makeDoubleRange(thrift_column_range.fp_min,
152  thrift_column_range.fp_max,
153  thrift_column_range.has_nulls));
154  break;
156  column_ranges.setColRange(phys_input, ExpressionRange::makeInvalidRange());
157  break;
158  default:
159  CHECK(false);
160  }
161  }
162  return column_ranges;
163 }
164 
166  const std::vector<TDictionaryGeneration>& thrift_string_dictionary_generations) {
167  StringDictionaryGenerations string_dictionary_generations;
168  for (const auto& thrift_string_dictionary_generation :
169  thrift_string_dictionary_generations) {
170  string_dictionary_generations.setGeneration(
171  {thrift_string_dictionary_generation.db_id,
172  thrift_string_dictionary_generation.dict_id},
173  thrift_string_dictionary_generation.entry_count);
174  }
175  return string_dictionary_generations;
176 }
177 
178 inline TTypeInfo type_info_to_thrift(const SQLTypeInfo& ti) {
179  TTypeInfo thrift_ti;
180  thrift_ti.type =
182  thrift_ti.encoding = encoding_to_thrift(ti);
183  thrift_ti.nullable = !ti.get_notnull();
184  thrift_ti.is_array = ti.is_array();
185  // TODO: Properly serialize geospatial subtype. For now, the value in precision is the
186  // same as the value in scale; overload the precision field with the subtype of the
187  // geospatial type (currently kGEOMETRY or kGEOGRAPHY)
188  thrift_ti.precision =
189  IS_GEO(ti.get_type()) ? static_cast<int32_t>(ti.get_subtype()) : ti.get_precision();
190  thrift_ti.scale = ti.get_scale();
191  thrift_ti.comp_param = ti.get_comp_param();
192  thrift_ti.size = ti.get_size();
193 
194  if (ti.get_compression() == kENCODING_DICT) {
195  const auto& dict_key = ti.getStringDictKey();
196  TStringDictKey t_dict_key;
197  t_dict_key.db_id = dict_key.db_id;
198  t_dict_key.dict_id = dict_key.dict_id;
199  thrift_ti.__set_dict_key(t_dict_key);
200  }
201  return thrift_ti;
202 }
203 
204 inline bool takes_arg(const TargetInfo& target_info) {
205  return target_info.is_agg &&
206  (target_info.agg_kind != kCOUNT || is_distinct_target(target_info));
207 }
208 
209 inline std::vector<TargetMetaInfo> target_meta_infos_from_thrift(
210  const TRowDescriptor& row_desc) {
211  std::vector<TargetMetaInfo> target_meta_infos;
212  for (const auto& col : row_desc) {
213  target_meta_infos.emplace_back(col.col_name, type_info_from_thrift(col.col_type));
214  }
215  return target_meta_infos;
216 }
217 
218 inline void fixup_geo_column_descriptor(TColumnType& col_type,
219  const SQLTypes subtype,
220  const int output_srid) {
221  col_type.col_type.precision = static_cast<int>(subtype);
222  col_type.col_type.scale = output_srid;
223 }
224 
225 inline TColumnType target_meta_info_to_thrift(const TargetMetaInfo& target,
226  const size_t idx) {
227  TColumnType proj_info;
228  proj_info.col_name = target.get_resname();
229  if (proj_info.col_name.empty()) {
230  proj_info.col_name = "result_" + std::to_string(idx + 1);
231  }
232  const auto& target_ti = target.get_type_info();
233  proj_info.col_type.type = type_to_thrift(target_ti);
234  proj_info.col_type.encoding = encoding_to_thrift(target_ti);
235  proj_info.col_type.nullable = !target_ti.get_notnull();
236  proj_info.col_type.is_array = target_ti.get_type() == kARRAY;
237  if (IS_GEO(target_ti.get_type())) {
239  proj_info, target_ti.get_subtype(), target_ti.get_output_srid());
240  } else {
241  proj_info.col_type.precision = target_ti.get_precision();
242  proj_info.col_type.scale = target_ti.get_scale();
243  }
244  if (target_ti.get_type() == kDATE) {
245  proj_info.col_type.size = target_ti.get_size();
246  }
247  proj_info.col_type.comp_param =
248  (target_ti.is_date_in_days() && target_ti.get_comp_param() == 0)
249  ? 32
250  : target_ti.get_comp_param();
251 
252  if (target_ti.get_compression() == kENCODING_DICT) {
253  const auto& dict_key = target_ti.getStringDictKey();
254  TStringDictKey t_dict_key;
255  t_dict_key.db_id = dict_key.db_id;
256  t_dict_key.dict_id = dict_key.dict_id;
257  proj_info.col_type.__set_dict_key(t_dict_key);
258  }
259  return proj_info;
260 }
261 
262 inline TRowDescriptor target_meta_infos_to_thrift(
263  const std::vector<TargetMetaInfo>& targets) {
264  TRowDescriptor row_desc;
265  size_t i = 0;
266  for (const auto& target : targets) {
267  row_desc.push_back(target_meta_info_to_thrift(target, i));
268  ++i;
269  }
270  return row_desc;
271 }
272 
273 inline TTargetInfo target_info_to_thrift(const TargetInfo& target_info) {
274  TTargetInfo thrift_target_info;
275  thrift_target_info.is_agg = target_info.is_agg;
276  thrift_target_info.kind = agg_kind_to_thrift(target_info.agg_kind);
277  thrift_target_info.type = type_info_to_thrift(target_info.sql_type);
278  thrift_target_info.arg_type = takes_arg(target_info)
279  ? type_info_to_thrift(target_info.agg_arg_type)
280  : thrift_target_info.type;
281  thrift_target_info.skip_nulls = target_info.skip_null_val;
282  thrift_target_info.is_distinct = target_info.is_distinct;
283  return thrift_target_info;
284 }
285 
286 inline TargetInfo target_info_from_thrift(const TTargetInfo& thrift_target_info) {
287  TargetInfo target_info;
288  target_info.is_agg = thrift_target_info.is_agg;
289  target_info.agg_kind = agg_kind_from_thrift(thrift_target_info.kind);
290  target_info.sql_type = type_info_from_thrift(thrift_target_info.type);
291  target_info.is_distinct = thrift_target_info.is_distinct;
292  target_info.agg_arg_type = takes_arg(target_info)
293  ? type_info_from_thrift(thrift_target_info.arg_type)
294  : SQLTypeInfo(kNULLT, false);
295  target_info.skip_null_val = thrift_target_info.skip_nulls;
296  return target_info;
297 }
298 
299 inline std::vector<TTargetInfo> target_infos_to_thrift(
300  const std::vector<TargetInfo>& targets) {
301  std::vector<TTargetInfo> thrift_targets;
302  for (const auto& target_info : targets) {
303  thrift_targets.push_back(target_info_to_thrift(target_info));
304  }
305  return thrift_targets;
306 }
307 
308 inline std::vector<TargetInfo> target_infos_from_thrift(
309  const std::vector<TTargetInfo>& thrift_targets) {
310  std::vector<TargetInfo> targets;
311  for (const auto& thrift_target_info : thrift_targets) {
312  targets.push_back(target_info_from_thrift(thrift_target_info));
313  }
314  return targets;
315 }
316 
317 #define THRIFT_COUNTDESCRIPTORIMPL_CASE(kind) \
318  case CountDistinctImplType::kind: \
319  return TCountDistinctImplType::kind;
320 
322  const CountDistinctImplType impl_type) {
323  switch (impl_type) {
327  default:
328  CHECK(false);
329  }
330  abort();
331 }
332 
333 #undef THRIFT_COUNTDESCRIPTORIMPL_CASE
334 
335 inline TCountDistinctDescriptor count_distinct_descriptor_to_thrift(
336  const CountDistinctDescriptor& count_distinct_descriptor) {
337  TCountDistinctDescriptor thrift_count_distinct_descriptor;
338  thrift_count_distinct_descriptor.impl_type =
339  count_distinct_impl_type_to_thrift(count_distinct_descriptor.impl_type_);
340  thrift_count_distinct_descriptor.min_val = count_distinct_descriptor.min_val;
341  thrift_count_distinct_descriptor.bitmap_sz_bits =
342  count_distinct_descriptor.bitmap_sz_bits;
343  thrift_count_distinct_descriptor.approximate = count_distinct_descriptor.approximate;
344  thrift_count_distinct_descriptor.device_type =
345  count_distinct_descriptor.device_type == ExecutorDeviceType::GPU ? TDeviceType::GPU
346  : TDeviceType::CPU;
347  thrift_count_distinct_descriptor.sub_bitmap_count =
348  count_distinct_descriptor.sub_bitmap_count;
349  return thrift_count_distinct_descriptor;
350 }
351 
352 #define UNTHRIFT_COUNTDESCRIPTORIMPL_CASE(kind) \
353  case TCountDistinctImplType::kind: \
354  return CountDistinctImplType::kind;
355 
357  const TCountDistinctImplType::type impl_type) {
358  switch (impl_type) {
362  default:
363  CHECK(false);
364  }
365  abort();
366 }
367 
368 #undef UNTHRIFT_COUNTDESCRIPTORIMPL_CASE
369 
371  const TCountDistinctDescriptor& thrift_count_distinct_descriptor) {
372  CountDistinctDescriptor count_distinct_descriptor;
373  count_distinct_descriptor.impl_type_ =
374  count_distinct_impl_type_from_thrift(thrift_count_distinct_descriptor.impl_type);
375  count_distinct_descriptor.min_val = thrift_count_distinct_descriptor.min_val;
376  count_distinct_descriptor.bitmap_sz_bits =
377  thrift_count_distinct_descriptor.bitmap_sz_bits;
378  count_distinct_descriptor.approximate = thrift_count_distinct_descriptor.approximate;
379  count_distinct_descriptor.device_type =
380  thrift_count_distinct_descriptor.device_type == TDeviceType::GPU
383  count_distinct_descriptor.sub_bitmap_count =
384  thrift_count_distinct_descriptor.sub_bitmap_count;
385  return count_distinct_descriptor;
386 }
387 
389  switch (t) {
390  case TExtArgumentType::Int8:
391  return ExtArgumentType::Int8;
392  case TExtArgumentType::Int16:
393  return ExtArgumentType::Int16;
394  case TExtArgumentType::Int32:
395  return ExtArgumentType::Int32;
396  case TExtArgumentType::Int64:
397  return ExtArgumentType::Int64;
398  case TExtArgumentType::Float:
399  return ExtArgumentType::Float;
402  case TExtArgumentType::Void:
403  return ExtArgumentType::Void;
404  case TExtArgumentType::PInt8:
405  return ExtArgumentType::PInt8;
406  case TExtArgumentType::PInt16:
408  case TExtArgumentType::PInt32:
410  case TExtArgumentType::PInt64:
412  case TExtArgumentType::PFloat:
414  case TExtArgumentType::PDouble:
416  case TExtArgumentType::PBool:
417  return ExtArgumentType::PBool;
418  case TExtArgumentType::Bool:
419  return ExtArgumentType::Bool;
420  case TExtArgumentType::ArrayInt8:
422  case TExtArgumentType::ArrayInt16:
424  case TExtArgumentType::ArrayInt32:
426  case TExtArgumentType::ArrayInt64:
428  case TExtArgumentType::ArrayFloat:
430  case TExtArgumentType::ArrayDouble:
432  case TExtArgumentType::ArrayBool:
434  case TExtArgumentType::ArrayTextEncodingNone:
436  case TExtArgumentType::ArrayTextEncodingDict:
446  case TExtArgumentType::Cursor:
452  case TExtArgumentType::ColumnInt8:
454  case TExtArgumentType::ColumnInt16:
456  case TExtArgumentType::ColumnInt32:
458  case TExtArgumentType::ColumnInt64:
460  case TExtArgumentType::ColumnFloat:
462  case TExtArgumentType::ColumnDouble:
464  case TExtArgumentType::ColumnBool:
466  case TExtArgumentType::ColumnTextEncodingNone:
468  case TExtArgumentType::ColumnTextEncodingDict:
470  case TExtArgumentType::ColumnTimestamp:
472  case TExtArgumentType::TextEncodingNone:
474  case TExtArgumentType::TextEncodingDict:
476  case TExtArgumentType::Timestamp:
478  case TExtArgumentType::ColumnListInt8:
480  case TExtArgumentType::ColumnListInt16:
482  case TExtArgumentType::ColumnListInt32:
484  case TExtArgumentType::ColumnListInt64:
486  case TExtArgumentType::ColumnListFloat:
488  case TExtArgumentType::ColumnListDouble:
490  case TExtArgumentType::ColumnListBool:
492  case TExtArgumentType::ColumnListTextEncodingNone:
494  case TExtArgumentType::ColumnListTextEncodingDict:
496  case TExtArgumentType::ColumnArrayInt8:
498  case TExtArgumentType::ColumnArrayInt16:
500  case TExtArgumentType::ColumnArrayInt32:
502  case TExtArgumentType::ColumnArrayInt64:
504  case TExtArgumentType::ColumnArrayFloat:
506  case TExtArgumentType::ColumnArrayDouble:
508  case TExtArgumentType::ColumnArrayBool:
510  case TExtArgumentType::ColumnArrayTextEncodingNone:
512  case TExtArgumentType::ColumnArrayTextEncodingDict:
514  case TExtArgumentType::ColumnListArrayInt8:
516  case TExtArgumentType::ColumnListArrayInt16:
518  case TExtArgumentType::ColumnListArrayInt32:
520  case TExtArgumentType::ColumnListArrayInt64:
522  case TExtArgumentType::ColumnListArrayFloat:
524  case TExtArgumentType::ColumnListArrayDouble:
526  case TExtArgumentType::ColumnListArrayBool:
528  case TExtArgumentType::ColumnListArrayTextEncodingNone:
530  case TExtArgumentType::ColumnListArrayTextEncodingDict:
532  case TExtArgumentType::DayTimeInterval:
534  case TExtArgumentType::YearMonthTimeInterval:
536  case TExtArgumentType::ColumnGeoPoint:
538  case TExtArgumentType::ColumnGeoLineString:
540  case TExtArgumentType::ColumnGeoPolygon:
542  case TExtArgumentType::ColumnGeoMultiPoint:
544  case TExtArgumentType::ColumnGeoMultiLineString:
546  case TExtArgumentType::ColumnGeoMultiPolygon:
548  case TExtArgumentType::ColumnListGeoPoint:
550  case TExtArgumentType::ColumnListGeoLineString:
552  case TExtArgumentType::ColumnListGeoPolygon:
554  case TExtArgumentType::ColumnListGeoMultiPoint:
556  case TExtArgumentType::ColumnListGeoMultiLineString:
558  case TExtArgumentType::ColumnListGeoMultiPolygon:
560  }
561  UNREACHABLE();
562  return ExtArgumentType{};
563 }
564 
566  switch (t) {
568  return TExtArgumentType::Int8;
570  return TExtArgumentType::Int16;
572  return TExtArgumentType::Int32;
574  return TExtArgumentType::Int64;
576  return TExtArgumentType::Float;
580  return TExtArgumentType::Void;
582  return TExtArgumentType::PInt8;
584  return TExtArgumentType::PInt16;
586  return TExtArgumentType::PInt32;
588  return TExtArgumentType::PInt64;
590  return TExtArgumentType::PFloat;
592  return TExtArgumentType::PDouble;
594  return TExtArgumentType::PBool;
596  return TExtArgumentType::Bool;
598  return TExtArgumentType::ArrayInt8;
600  return TExtArgumentType::ArrayInt16;
602  return TExtArgumentType::ArrayInt32;
604  return TExtArgumentType::ArrayInt64;
606  return TExtArgumentType::ArrayFloat;
608  return TExtArgumentType::ArrayDouble;
610  return TExtArgumentType::ArrayBool;
612  return TExtArgumentType::ArrayTextEncodingNone;
614  return TExtArgumentType::ArrayTextEncodingDict;
624  return TExtArgumentType::Cursor;
630  return TExtArgumentType::ColumnInt8;
632  return TExtArgumentType::ColumnInt16;
634  return TExtArgumentType::ColumnInt32;
636  return TExtArgumentType::ColumnInt64;
638  return TExtArgumentType::ColumnFloat;
640  return TExtArgumentType::ColumnDouble;
642  return TExtArgumentType::ColumnBool;
644  return TExtArgumentType::ColumnTextEncodingNone;
646  return TExtArgumentType::ColumnTextEncodingDict;
648  return TExtArgumentType::ColumnTimestamp;
650  return TExtArgumentType::TextEncodingNone;
652  return TExtArgumentType::TextEncodingDict;
654  return TExtArgumentType::Timestamp;
656  return TExtArgumentType::ColumnListInt8;
658  return TExtArgumentType::ColumnListInt16;
660  return TExtArgumentType::ColumnListInt32;
662  return TExtArgumentType::ColumnListInt64;
664  return TExtArgumentType::ColumnListFloat;
666  return TExtArgumentType::ColumnListDouble;
668  return TExtArgumentType::ColumnListBool;
670  return TExtArgumentType::ColumnListTextEncodingNone;
672  return TExtArgumentType::ColumnListTextEncodingDict;
674  return TExtArgumentType::ColumnArrayInt8;
676  return TExtArgumentType::ColumnArrayInt16;
678  return TExtArgumentType::ColumnArrayInt32;
680  return TExtArgumentType::ColumnArrayInt64;
682  return TExtArgumentType::ColumnArrayFloat;
684  return TExtArgumentType::ColumnArrayDouble;
686  return TExtArgumentType::ColumnArrayBool;
688  return TExtArgumentType::ColumnArrayTextEncodingNone;
690  return TExtArgumentType::ColumnArrayTextEncodingDict;
692  return TExtArgumentType::ColumnListArrayInt8;
694  return TExtArgumentType::ColumnListArrayInt16;
696  return TExtArgumentType::ColumnListArrayInt32;
698  return TExtArgumentType::ColumnListArrayInt64;
700  return TExtArgumentType::ColumnListArrayFloat;
702  return TExtArgumentType::ColumnListArrayDouble;
704  return TExtArgumentType::ColumnListArrayBool;
706  return TExtArgumentType::ColumnListArrayTextEncodingDict;
708  return TExtArgumentType::ColumnListArrayTextEncodingNone;
710  return TExtArgumentType::DayTimeInterval;
712  return TExtArgumentType::YearMonthTimeInterval;
714  return TExtArgumentType::ColumnGeoPoint;
716  return TExtArgumentType::ColumnGeoLineString;
718  return TExtArgumentType::ColumnGeoPolygon;
720  return TExtArgumentType::ColumnGeoMultiPoint;
722  return TExtArgumentType::ColumnGeoMultiLineString;
724  return TExtArgumentType::ColumnGeoMultiPolygon;
726  return TExtArgumentType::ColumnListGeoPoint;
728  return TExtArgumentType::ColumnListGeoLineString;
730  return TExtArgumentType::ColumnListGeoPolygon;
732  return TExtArgumentType::ColumnListGeoMultiPoint;
734  return TExtArgumentType::ColumnListGeoMultiLineString;
736  return TExtArgumentType::ColumnListGeoMultiPolygon;
737  }
738  UNREACHABLE();
739  return TExtArgumentType::type{};
740 }
741 
742 inline std::vector<ExtArgumentType> from_thrift(
743  const std::vector<TExtArgumentType::type>& v) {
744  std::vector<ExtArgumentType> result;
746  v.begin(),
747  v.end(),
748  std::back_inserter(result),
749  [](TExtArgumentType::type c) -> ExtArgumentType { return from_thrift(c); });
750  return result;
751 }
752 
753 inline std::vector<TExtArgumentType::type> to_thrift(
754  const std::vector<ExtArgumentType>& v) {
755  std::vector<TExtArgumentType::type> result;
757  v.begin(),
758  v.end(),
759  std::back_inserter(result),
760  [](ExtArgumentType c) -> TExtArgumentType::type { return to_thrift(c); });
761  return result;
762 }
763 
765  const TOutputBufferSizeType::type& t) {
766  switch (t) {
767  case TOutputBufferSizeType::kConstant:
769  case TOutputBufferSizeType::kUserSpecifiedConstantParameter:
771  case TOutputBufferSizeType::kUserSpecifiedRowMultiplier:
773  case TOutputBufferSizeType::kTableFunctionSpecifiedParameter:
775  case TOutputBufferSizeType::kPreFlightParameter:
777  }
778  UNREACHABLE();
780 }
781 
784  switch (t) {
786  return TOutputBufferSizeType::kConstant;
788  return TOutputBufferSizeType::kUserSpecifiedConstantParameter;
790  return TOutputBufferSizeType::kUserSpecifiedRowMultiplier;
792  return TOutputBufferSizeType::kTableFunctionSpecifiedParameter;
794  return TOutputBufferSizeType::kPreFlightParameter;
795  }
796  UNREACHABLE();
798 }
799 
800 inline TUserDefinedFunction to_thrift(const ExtensionFunction& udf) {
801  TUserDefinedFunction tfunc;
802  tfunc.name = udf.getName(/* keep_suffix */ true);
803  tfunc.argTypes = to_thrift(udf.getInputArgs());
804  tfunc.retType = to_thrift(udf.getRet());
805  tfunc.annotations = udf.getAnnotations();
806  return tfunc;
807 }
808 
809 inline TUserDefinedTableFunction to_thrift(const table_functions::TableFunction& func) {
810  TUserDefinedTableFunction tfunc;
811  tfunc.name = func.getName();
812  tfunc.sizerType = to_thrift(func.getOutputRowSizeType());
813  tfunc.sizerArgPos = func.getOutputRowSizeParameter();
814  tfunc.inputArgTypes = to_thrift(func.getInputArgs());
815  tfunc.outputArgTypes = to_thrift(func.getOutputArgs());
816  tfunc.sqlArgTypes = to_thrift(func.getSqlArgs());
817  tfunc.annotations = func.getAnnotations();
818  return tfunc;
819 }
820 
821 inline std::vector<TUserDefinedTableFunction> to_thrift(
822  const std::vector<table_functions::TableFunction>& v) {
823  std::vector<TUserDefinedTableFunction> result;
824  std::transform(v.begin(),
825  v.end(),
826  std::back_inserter(result),
827  [](table_functions::TableFunction c) -> TUserDefinedTableFunction {
828  return to_thrift(c);
829  });
830  return result;
831 }
832 
833 } // namespace ThriftSerializers
834 
835 #endif // QUERYENGINE_THRIFTSERIALIZERS_H
TCountDistinctImplType::type count_distinct_impl_type_to_thrift(const CountDistinctImplType impl_type)
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:73
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)
QueryDescriptionType layout_from_thrift(const TResultSetLayout::type layout)
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
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:320
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
const std::vector< ExtArgumentType > & getInputArgs() const
Definition: sqldefs.h:78
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:1268
QueryDescriptionType
Definition: Types.h:29
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
TResultSetLayout::type layout_to_thrift(const QueryDescriptionType layout)
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:975
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:583
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:1055
TEncodingType::type encoding_to_thrift(const SQLTypeInfo &type_info)