From 83f0ad52558576e3286a15b2c1caee38bfae0090 Mon Sep 17 00:00:00 2001 From: PHILO-HE Date: Fri, 10 Mar 2023 14:19:50 +0800 Subject: [PATCH] Check a fallback case in validation: using literal partition key in window function (#148) --- velox/substrait/SubstraitToVeloxPlanValidator.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/velox/substrait/SubstraitToVeloxPlanValidator.cpp b/velox/substrait/SubstraitToVeloxPlanValidator.cpp index caf6ae392f012..a5b7cc363ca38 100644 --- a/velox/substrait/SubstraitToVeloxPlanValidator.cpp +++ b/velox/substrait/SubstraitToVeloxPlanValidator.cpp @@ -321,7 +321,17 @@ bool SubstraitToVeloxPlanValidator::validate( expressions.reserve(groupByExprs.size()); try { for (const auto& expr : groupByExprs) { - expressions.emplace_back(exprConverter_->toVeloxExpr(expr, rowType)); + auto expression = exprConverter_->toVeloxExpr(expr, rowType); + auto expr_field = + dynamic_cast(expression.get()); + if (expr_field == nullptr) { + std::cout + << "Only field is supported for partition key in Window Operator!" + << std::endl; + return false; + } else { + expressions.emplace_back(expression); + } } // Try to compile the expressions. If there is any unregistred funciton or // mismatched type, exception will be thrown.