@@ -76,66 +76,50 @@ TypePtr Type::decode(const std::string &rawType) {
7676
7777 if (TypeTraits<TypeKind::kList >::typeString == baseType) {
7878 return std::make_shared<ListType>(nestedTypes[0 ]);
79- } else if (TypeTraits<TypeKind::kMap >::typeString ==
80- baseType) {
79+ } else if (TypeTraits<TypeKind::kMap >::typeString == baseType) {
8180 return std::make_shared<MapType>(nestedTypes[0 ], nestedTypes[1 ]);
82- } else if (TypeTraits<TypeKind::kDecimal >::typeString ==
83- baseType) {
81+ } else if (TypeTraits<TypeKind::kDecimal >::typeString == baseType) {
8482 auto precision =
85- std::dynamic_pointer_cast<const StringLiteralType>(
86- nestedTypes[0 ]);
87- auto scale = std::dynamic_pointer_cast<const StringLiteralType>(
88- nestedTypes[1 ]);
83+ std::dynamic_pointer_cast<const StringLiteralType>(nestedTypes[0 ]);
84+ auto scale =
85+ std::dynamic_pointer_cast<const StringLiteralType>(nestedTypes[1 ]);
8986 return std::make_shared<DecimalType>(precision, scale);
90- } else if (TypeTraits<TypeKind::kVarchar >::typeString ==
91- baseType) {
92- auto length = std::dynamic_pointer_cast<const StringLiteralType>(
93- nestedTypes[0 ]);
87+ } else if (TypeTraits<TypeKind::kVarchar >::typeString == baseType) {
88+ auto length =
89+ std::dynamic_pointer_cast<const StringLiteralType>(nestedTypes[0 ]);
9490 return std::make_shared<VarcharType>(length);
95- } else if (TypeTraits<TypeKind::kFixedChar >::typeString ==
96- baseType) {
97- auto length = std::dynamic_pointer_cast<const StringLiteralType>(
98- nestedTypes[0 ]);
91+ } else if (TypeTraits<TypeKind::kFixedChar >::typeString == baseType) {
92+ auto length =
93+ std::dynamic_pointer_cast<const StringLiteralType>(nestedTypes[0 ]);
9994 return std::make_shared<FixedCharType>(length);
100- } else if (TypeTraits<TypeKind::kFixedBinary >::typeString ==
101- baseType) {
102- auto length = std::dynamic_pointer_cast<const StringLiteralType>(
103- nestedTypes[0 ]);
95+ } else if (TypeTraits<TypeKind::kFixedBinary >::typeString == baseType) {
96+ auto length =
97+ std::dynamic_pointer_cast<const StringLiteralType>(nestedTypes[0 ]);
10498 return std::make_shared<FixedBinaryType>(length);
105- } else if (TypeTraits<TypeKind::kStruct >::typeString ==
106- baseType) {
99+ } else if (TypeTraits<TypeKind::kStruct >::typeString == baseType) {
107100 return std::make_shared<StructType>(nestedTypes);
108101 } else {
109102 throw std::runtime_error (" Unsupported substrait type: " + rawType);
110103 }
111104}
112105
113- #define SCALAR_TYPE_MAPPING (typeKind ) \
106+ #define SCALAR_TYPE_MAPPING (typeKind ) \
114107 { \
115- TypeTraits<TypeKind::typeKind>::typeString, \
108+ TypeTraits<TypeKind::typeKind>::typeString, \
116109 std::make_shared<TypeBase<TypeKind::typeKind>>( \
117- TypeBase<TypeKind::typeKind>()) \
110+ TypeBase<TypeKind::typeKind>()) \
118111 }
119112
120- const std::unordered_map<std::string, TypePtr> &
121- Type::scalarTypeMapping () {
113+ const std::unordered_map<std::string, TypePtr> &Type::scalarTypeMapping () {
122114 static const std::unordered_map<std::string, TypePtr> scalarTypeMap{
123- SCALAR_TYPE_MAPPING (kBool ),
124- SCALAR_TYPE_MAPPING (kI8 ),
125- SCALAR_TYPE_MAPPING (kI16 ),
126- SCALAR_TYPE_MAPPING (kI32 ),
127- SCALAR_TYPE_MAPPING (kI64 ),
128- SCALAR_TYPE_MAPPING (kFp32 ),
129- SCALAR_TYPE_MAPPING (kFp64 ),
130- SCALAR_TYPE_MAPPING (kString ),
131- SCALAR_TYPE_MAPPING (kBinary ),
132- SCALAR_TYPE_MAPPING (kTimestamp ),
133- SCALAR_TYPE_MAPPING (kTimestampTz ),
134- SCALAR_TYPE_MAPPING (kDate ),
135- SCALAR_TYPE_MAPPING (kTime ),
136- SCALAR_TYPE_MAPPING (kIntervalDay ),
137- SCALAR_TYPE_MAPPING (kIntervalYear ),
138- SCALAR_TYPE_MAPPING (kUuid ),
115+ SCALAR_TYPE_MAPPING (kBool ), SCALAR_TYPE_MAPPING (kI8 ),
116+ SCALAR_TYPE_MAPPING (kI16 ), SCALAR_TYPE_MAPPING (kI32 ),
117+ SCALAR_TYPE_MAPPING (kI64 ), SCALAR_TYPE_MAPPING (kFp32 ),
118+ SCALAR_TYPE_MAPPING (kFp64 ), SCALAR_TYPE_MAPPING (kString ),
119+ SCALAR_TYPE_MAPPING (kBinary ), SCALAR_TYPE_MAPPING (kTimestamp ),
120+ SCALAR_TYPE_MAPPING (kTimestampTz ), SCALAR_TYPE_MAPPING (kDate ),
121+ SCALAR_TYPE_MAPPING (kTime ), SCALAR_TYPE_MAPPING (kIntervalDay ),
122+ SCALAR_TYPE_MAPPING (kIntervalYear ), SCALAR_TYPE_MAPPING (kUuid ),
139123 };
140124 return scalarTypeMap;
141125}
@@ -149,8 +133,7 @@ const std::string FixedBinaryType::signature() const {
149133 return sign.str ();
150134}
151135
152- bool FixedBinaryType::isSameAs (
153- const std::shared_ptr<const Type> &other) const {
136+ bool FixedBinaryType::isSameAs (const std::shared_ptr<const Type> &other) const {
154137 if (const auto &type =
155138 std::dynamic_pointer_cast<const FixedBinaryType>(other)) {
156139 return true ;
@@ -167,10 +150,8 @@ const std::string DecimalType::signature() const {
167150 return signature.str ();
168151}
169152
170- bool DecimalType::isSameAs (
171- const std::shared_ptr<const Type> &other) const {
172- if (const auto &type =
173- std::dynamic_pointer_cast<const DecimalType>(other)) {
153+ bool DecimalType::isSameAs (const std::shared_ptr<const Type> &other) const {
154+ if (const auto &type = std::dynamic_pointer_cast<const DecimalType>(other)) {
174155 return true ;
175156 }
176157 return false ;
@@ -185,8 +166,7 @@ const std::string FixedCharType::signature() const {
185166 return sign.str ();
186167}
187168
188- bool FixedCharType::isSameAs (
189- const std::shared_ptr<const Type> &other) const {
169+ bool FixedCharType::isSameAs (const std::shared_ptr<const Type> &other) const {
190170 if (const auto &type =
191171 std::dynamic_pointer_cast<const FixedCharType>(other)) {
192172 return true ;
@@ -203,10 +183,8 @@ const std::string VarcharType::signature() const {
203183 return sign.str ();
204184}
205185
206- bool VarcharType::isSameAs (
207- const std::shared_ptr<const Type> &other) const {
208- if (const auto &type =
209- std::dynamic_pointer_cast<const VarcharType>(other)) {
186+ bool VarcharType::isSameAs (const std::shared_ptr<const Type> &other) const {
187+ if (const auto &type = std::dynamic_pointer_cast<const VarcharType>(other)) {
210188 return true ;
211189 }
212190 return false ;
@@ -228,10 +206,8 @@ const std::string StructType::signature() const {
228206 return signature.str ();
229207}
230208
231- bool StructType::isSameAs (
232- const std::shared_ptr<const Type> &other) const {
233- if (const auto &type =
234- std::dynamic_pointer_cast<const StructType>(other)) {
209+ bool StructType::isSameAs (const std::shared_ptr<const Type> &other) const {
210+ if (const auto &type = std::dynamic_pointer_cast<const StructType>(other)) {
235211 bool sameSize = type->children_ .size () == children_.size ();
236212 if (sameSize) {
237213 for (int i = 0 ; i < children_.size (); i++) {
@@ -256,10 +232,8 @@ const std::string MapType::signature() const {
256232 return signature.str ();
257233}
258234
259- bool MapType::isSameAs (
260- const std::shared_ptr<const Type> &other) const {
261- if (const auto &type =
262- std::dynamic_pointer_cast<const MapType>(other)) {
235+ bool MapType::isSameAs (const std::shared_ptr<const Type> &other) const {
236+ if (const auto &type = std::dynamic_pointer_cast<const MapType>(other)) {
263237 return keyType_->isSameAs (type->keyType_ ) &&
264238 valueType_->isSameAs (type->valueType_ );
265239 }
@@ -275,17 +249,14 @@ const std::string ListType::signature() const {
275249 return signature.str ();
276250}
277251
278- bool ListType::isSameAs (
279- const std::shared_ptr<const Type> &other) const {
280- if (const auto &type =
281- std::dynamic_pointer_cast<const ListType>(other)) {
252+ bool ListType::isSameAs (const std::shared_ptr<const Type> &other) const {
253+ if (const auto &type = std::dynamic_pointer_cast<const ListType>(other)) {
282254 return elementType_->isSameAs (type->elementType_ );
283255 }
284256 return false ;
285257}
286258
287- bool UsedDefinedType::isSameAs (
288- const std::shared_ptr<const Type> &other) const {
259+ bool UsedDefinedType::isSameAs (const std::shared_ptr<const Type> &other) const {
289260 if (const auto &type =
290261 std::dynamic_pointer_cast<const UsedDefinedType>(other)) {
291262 return type->value_ == value_;
@@ -305,11 +276,9 @@ bool StringLiteralType::isSameAs(
305276 return false ;
306277}
307278
308- #define DEFINE_SCALAR_ACCESSOR (typeKind ) \
309- std::shared_ptr<const ScalarType<TypeKind::typeKind>> \
310- typeKind () { \
311- return std::make_shared< \
312- const ScalarType<TypeKind::typeKind>>(); \
279+ #define DEFINE_SCALAR_ACCESSOR (typeKind ) \
280+ std::shared_ptr<const ScalarType<TypeKind::typeKind>> typeKind () { \
281+ return std::make_shared<const ScalarType<TypeKind::typeKind>>(); \
313282 }
314283
315284DEFINE_SCALAR_ACCESSOR (kBool );
0 commit comments