OmniSciDB  04ee39c94c
anonymous_namespace{ArrowResultSet.cpp} Namespace Reference

Functions

SQLTypeInfo type_from_arrow_field (const arrow::Field &field)
 

Function Documentation

◆ type_from_arrow_field()

SQLTypeInfo anonymous_namespace{ArrowResultSet.cpp}::type_from_arrow_field ( const arrow::Field &  field)

Definition at line 27 of file ArrowResultSet.cpp.

References CHECK, field(), kBIGINT, kDATE, kDOUBLE, kENCODING_DATE_IN_DAYS, kENCODING_DICT, kFLOAT, kINT, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, run-benchmark-import::type, SQLTypeInfoCore< TYPE_FACET_PACK >::type, and UNREACHABLE.

Referenced by ArrowResultSet::ArrowResultSet().

27  {
28  switch (field.type()->id()) {
29  case arrow::Type::INT16:
30  return SQLTypeInfo(kSMALLINT, !field.nullable());
31  case arrow::Type::INT32:
32  return SQLTypeInfo(kINT, !field.nullable());
33  case arrow::Type::INT64:
34  return SQLTypeInfo(kBIGINT, !field.nullable());
35  case arrow::Type::FLOAT:
36  return SQLTypeInfo(kFLOAT, !field.nullable());
37  case arrow::Type::DOUBLE:
38  return SQLTypeInfo(kDOUBLE, !field.nullable());
39  case arrow::Type::DICTIONARY:
40  return SQLTypeInfo(kTEXT, !field.nullable(), kENCODING_DICT);
41  case arrow::Type::TIMESTAMP: {
42  // TODO(Wamsi): go right fold expr in c++17
43  auto get_precision = [&field](auto type) { return field.type()->Equals(type); };
44  if (get_precision(arrow::timestamp(arrow::TimeUnit::SECOND))) {
45  return SQLTypeInfo(kTIMESTAMP, !field.nullable());
46  } else if (get_precision(arrow::timestamp(arrow::TimeUnit::MILLI))) {
47  return SQLTypeInfo(kTIMESTAMP, 3, 0, !field.nullable());
48  } else if (get_precision(arrow::timestamp(arrow::TimeUnit::MICRO))) {
49  return SQLTypeInfo(kTIMESTAMP, 6, 0, !field.nullable());
50  } else if (get_precision(arrow::timestamp(arrow::TimeUnit::NANO))) {
51  return SQLTypeInfo(kTIMESTAMP, 9, 0, !field.nullable());
52  } else {
53  UNREACHABLE();
54  }
55  }
56  case arrow::Type::DATE32:
57  return SQLTypeInfo(kDATE, !field.nullable(), kENCODING_DATE_IN_DAYS);
58  case arrow::Type::DATE64:
59  return SQLTypeInfo(kDATE, !field.nullable());
60  case arrow::Type::TIME32:
61  return SQLTypeInfo(kTIME, !field.nullable());
62  default:
63  CHECK(false);
64  }
65  CHECK(false);
66  return SQLTypeInfo();
67 }
Definition: sqltypes.h:51
#define UNREACHABLE()
Definition: Logger.h:231
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
Definition: sqltypes.h:54
Definition: sqltypes.h:55
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqltypes.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function: