MCPcopy Create free account
hub / github.com/apache/arrow / MakeNull

Method MakeNull

cpp/src/gandiva/tree_expr_builder.cc:60–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60NodePtr TreeExprBuilder::MakeNull(DataTypePtr data_type) {
61 static const std::string empty;
62
63 if (data_type == nullptr) {
64 return nullptr;
65 }
66
67 switch (data_type->id()) {
68 case arrow::Type::BOOL:
69 return std::make_shared<LiteralNode>(data_type, LiteralHolder(false), true);
70 case arrow::Type::INT8:
71 return std::make_shared<LiteralNode>(data_type, LiteralHolder((int8_t)0), true);
72 case arrow::Type::INT16:
73 return std::make_shared<LiteralNode>(data_type, LiteralHolder((int16_t)0), true);
74 return std::make_shared<LiteralNode>(data_type, LiteralHolder((int32_t)0), true);
75 case arrow::Type::UINT8:
76 return std::make_shared<LiteralNode>(data_type, LiteralHolder((uint8_t)0), true);
77 case arrow::Type::UINT16:
78 return std::make_shared<LiteralNode>(data_type, LiteralHolder((uint16_t)0), true);
79 case arrow::Type::UINT32:
80 return std::make_shared<LiteralNode>(data_type, LiteralHolder((uint32_t)0), true);
81 case arrow::Type::UINT64:
82 return std::make_shared<LiteralNode>(data_type, LiteralHolder((uint64_t)0), true);
83 case arrow::Type::FLOAT:
84 return std::make_shared<LiteralNode>(data_type,
85 LiteralHolder(static_cast<float>(0)), true);
86 case arrow::Type::DOUBLE:
87 return std::make_shared<LiteralNode>(data_type,
88 LiteralHolder(static_cast<double>(0)), true);
89 case arrow::Type::STRING:
90 case arrow::Type::BINARY:
91 return std::make_shared<LiteralNode>(data_type, LiteralHolder(empty), true);
92 case arrow::Type::INT32:
93 case arrow::Type::DATE32:
94 case arrow::Type::TIME32:
95 case arrow::Type::INTERVAL_MONTHS:
96 return std::make_shared<LiteralNode>(data_type, LiteralHolder((int32_t)0), true);
97 case arrow::Type::INT64:
98 case arrow::Type::DATE64:
99 case arrow::Type::TIME64:
100 case arrow::Type::TIMESTAMP:
101 case arrow::Type::INTERVAL_DAY_TIME:
102 return std::make_shared<LiteralNode>(data_type, LiteralHolder((int64_t)0), true);
103 case arrow::Type::DECIMAL: {
104 std::shared_ptr<arrow::DecimalType> decimal_type =
105 arrow::internal::checked_pointer_cast<arrow::DecimalType>(data_type);
106 DecimalScalar128 literal(decimal_type->precision(), decimal_type->scale());
107 return std::make_shared<LiteralNode>(data_type, LiteralHolder(literal), true);
108 }
109 default:
110 return nullptr;
111 }
112}
113
114NodePtr TreeExprBuilder::MakeField(FieldPtr field) {
115 return NodePtr(new FieldNode(field));

Callers

nothing calls this directly

Calls 3

idMethod · 0.45
precisionMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected