This is an automated email from the ASF dual-hosted git repository.
chengchengjin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 7caa96a666 [VL]Use isTimestamp/Varchar/Row func to check type (#8902)
7caa96a666 is described below
commit 7caa96a666c029df280dacd24c4b4a7e3e631be8
Author: Joey <[email protected]>
AuthorDate: Thu Mar 6 22:09:39 2025 +0800
[VL]Use isTimestamp/Varchar/Row func to check type (#8902)
---
cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
index ac1c3226e7..2494abe976 100644
--- a/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
+++ b/cpp/velox/substrait/SubstraitToVeloxPlanValidator.cc
@@ -89,7 +89,7 @@ bool SubstraitToVeloxPlanValidator::parseVeloxType(
}
bool SubstraitToVeloxPlanValidator::flattenSingleLevel(const TypePtr& type,
std::vector<TypePtr>& out) {
- if (type->kind() != TypeKind::ROW) {
+ if (!type->isRow()) {
LOG_VALIDATION_MSG("Type is not a RowType.");
return false;
}
@@ -105,7 +105,7 @@ bool
SubstraitToVeloxPlanValidator::flattenSingleLevel(const TypePtr& type, std:
}
bool SubstraitToVeloxPlanValidator::flattenDualLevel(const TypePtr& type,
std::vector<std::vector<TypePtr>>& out) {
- if (type->kind() != TypeKind::ROW) {
+ if (!type->isRow()) {
LOG_VALIDATION_MSG("Type is not a RowType.");
return false;
}
@@ -241,7 +241,7 @@ 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.
@@ -249,12 +249,6 @@ bool SubstraitToVeloxPlanValidator::isAllowedCast(const
TypePtr& fromType, const
// 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.");
@@ -262,26 +256,26 @@ bool SubstraitToVeloxPlanValidator::isAllowedCast(const
TypePtr& fromType, const
}
// 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()) {
LOG_VALIDATION_MSG("Casting from " + fromType->toString() + " is not
currently supported.");
return false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]