OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{ArrowResultSet.cpp} Namespace Reference

Functions

SQLTypeInfo type_from_arrow_field (const arrow::Field &field)
 

Function Documentation

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

Definition at line 28 of file ArrowResultSet.cpp.

References CHECK, DICTIONARY, DOUBLE, field(), FLOAT, kBIGINT, kDATE, kDOUBLE, kENCODING_DATE_IN_DAYS, kENCODING_DICT, kFLOAT, kINT, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, TIMESTAMP, run_benchmark_import::type, and UNREACHABLE.

Referenced by ArrowResultSet::ArrowResultSet().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: