FelixYBW commented on code in PR #8902:
URL: https://github.com/apache/incubator-gluten/pull/8902#discussion_r1982364872


##########
cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc:
##########
@@ -242,47 +242,41 @@ bool 
SubstraitToVeloxPlanValidator::validateScalarFunction(
 
 bool SubstraitToVeloxPlanValidator::isAllowedCast(const TypePtr& fromType, 
const TypePtr& toType) {
   // Currently cast is not allowed for various categories, code has a bunch of 
rules
-  // which define the cast categories and if we should offload to velox. 
Currently
+  // which define the cast categories and if we should offload to velox. 
Currently,
   // the following categories are denied.
   //
   // 1. from/to isIntervalYearMonth is not allowed.
   // 2. Date to most categories except few supported types is not allowed.
   // 3. Timestamp to most categories except few supported types is not allowed.
   // 4. Certain complex types are not allowed.
 
-  TypeKind fromKind = fromType->kind();
-  TypeKind toKind = toType->kind();
-
-  static const std::unordered_set<TypeKind> complexTypeList = {
-      TypeKind::ARRAY, TypeKind::MAP, TypeKind::ROW, TypeKind::VARBINARY};
-
   // Don't support isIntervalYearMonth.
   if (fromType->isIntervalYearMonth() || toType->isIntervalYearMonth()) {
     LOG_VALIDATION_MSG("Casting involving INTERVAL_YEAR_MONTH is not 
supported.");
     return false;
   }
 
   // Limited support for DATE to X.
-  if (fromType->isDate() && toKind != TypeKind::TIMESTAMP && toKind != 
TypeKind::VARCHAR) {
+  if (fromType->isDate() && !toType->isTimestamp() && !toType->isVarchar()) {
     LOG_VALIDATION_MSG("Casting from DATE to " + toType->toString() + " is not 
supported.");
     return false;
   }
 
   // Limited support for Timestamp to X.
-  if (fromKind == TypeKind::TIMESTAMP && !(toType->isDate() || toKind == 
TypeKind::VARCHAR)) {
+  if (fromType->isTimestamp() && !(toType->isDate() || toType->isVarchar())) {
     LOG_VALIDATION_MSG(
         "Casting from TIMESTAMP to " + toType->toString() + " is not supported 
or has incorrect result.");
     return false;
   }
 
   // Limited support for X to Timestamp.
-  if (toKind == TypeKind::TIMESTAMP && !fromType->isDate()) {
+  if (toType->isTimestamp() && !fromType->isDate()) {
     LOG_VALIDATION_MSG("Casting from " + fromType->toString() + " to TIMESTAMP 
is not supported.");
     return false;
   }
 
   // Limited support for Complex types.
-  if (complexTypeList.find(fromKind) != complexTypeList.end()) {
+  if (fromType->isArray() || fromType->isMap() || fromType->isRow() || 
fromType->isVarbinary()) {

Review Comment:
   list the types is OK, more clear



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to