@@ -89,7 +89,7 @@ bool SubstraitToVeloxPlanValidator::parseVeloxType(
89
89
}
90
90
91
91
bool SubstraitToVeloxPlanValidator::flattenSingleLevel (const TypePtr& type, std::vector<TypePtr>& out) {
92
- if (type->kind () != TypeKind::ROW ) {
92
+ if (! type->isRow () ) {
93
93
LOG_VALIDATION_MSG (" Type is not a RowType." );
94
94
return false ;
95
95
}
@@ -105,7 +105,7 @@ bool SubstraitToVeloxPlanValidator::flattenSingleLevel(const TypePtr& type, std:
105
105
}
106
106
107
107
bool SubstraitToVeloxPlanValidator::flattenDualLevel (const TypePtr& type, std::vector<std::vector<TypePtr>>& out) {
108
- if (type->kind () != TypeKind::ROW ) {
108
+ if (! type->isRow () ) {
109
109
LOG_VALIDATION_MSG (" Type is not a RowType." );
110
110
return false ;
111
111
}
@@ -241,47 +241,41 @@ bool SubstraitToVeloxPlanValidator::validateScalarFunction(
241
241
242
242
bool SubstraitToVeloxPlanValidator::isAllowedCast (const TypePtr& fromType, const TypePtr& toType) {
243
243
// Currently cast is not allowed for various categories, code has a bunch of rules
244
- // which define the cast categories and if we should offload to velox. Currently
244
+ // which define the cast categories and if we should offload to velox. Currently,
245
245
// the following categories are denied.
246
246
//
247
247
// 1. from/to isIntervalYearMonth is not allowed.
248
248
// 2. Date to most categories except few supported types is not allowed.
249
249
// 3. Timestamp to most categories except few supported types is not allowed.
250
250
// 4. Certain complex types are not allowed.
251
251
252
- TypeKind fromKind = fromType->kind ();
253
- TypeKind toKind = toType->kind ();
254
-
255
- static const std::unordered_set<TypeKind> complexTypeList = {
256
- TypeKind::ARRAY, TypeKind::MAP, TypeKind::ROW, TypeKind::VARBINARY};
257
-
258
252
// Don't support isIntervalYearMonth.
259
253
if (fromType->isIntervalYearMonth () || toType->isIntervalYearMonth ()) {
260
254
LOG_VALIDATION_MSG (" Casting involving INTERVAL_YEAR_MONTH is not supported." );
261
255
return false ;
262
256
}
263
257
264
258
// Limited support for DATE to X.
265
- if (fromType->isDate () && toKind != TypeKind::TIMESTAMP && toKind != TypeKind::VARCHAR ) {
259
+ if (fromType->isDate () && !toType-> isTimestamp () && !toType-> isVarchar () ) {
266
260
LOG_VALIDATION_MSG (" Casting from DATE to " + toType->toString () + " is not supported." );
267
261
return false ;
268
262
}
269
263
270
264
// Limited support for Timestamp to X.
271
- if (fromKind == TypeKind::TIMESTAMP && !(toType->isDate () || toKind == TypeKind::VARCHAR )) {
265
+ if (fromType-> isTimestamp () && !(toType->isDate () || toType-> isVarchar () )) {
272
266
LOG_VALIDATION_MSG (
273
267
" Casting from TIMESTAMP to " + toType->toString () + " is not supported or has incorrect result." );
274
268
return false ;
275
269
}
276
270
277
271
// Limited support for X to Timestamp.
278
- if (toKind == TypeKind::TIMESTAMP && !fromType->isDate ()) {
272
+ if (toType-> isTimestamp () && !fromType->isDate ()) {
279
273
LOG_VALIDATION_MSG (" Casting from " + fromType->toString () + " to TIMESTAMP is not supported." );
280
274
return false ;
281
275
}
282
276
283
277
// Limited support for Complex types.
284
- if (complexTypeList. find (fromKind) != complexTypeList. end ()) {
278
+ if (fromType-> isArray () || fromType-> isMap () || fromType-> isRow () || fromType-> isVarbinary ()) {
285
279
LOG_VALIDATION_MSG (" Casting from " + fromType->toString () + " is not currently supported." );
286
280
return false ;
287
281
}
0 commit comments