Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
  • Loading branch information
zhouyuan committed Jun 8, 2022
1 parent 403aa6c commit 0d6cd91
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ case class ColumnarWindowExec(windowExpression: Seq[NamedExpression],

override def output: Seq[Attribute] = child.output ++ windowExpression.map(_.toAttribute)

//buildCheck()
buildCheck()

override def requiredChildDistribution: Seq[Distribution] = {
if (isLocal) {
Expand Down Expand Up @@ -103,6 +103,10 @@ case class ColumnarWindowExec(windowExpression: Seq[NamedExpression],
try {
breakable {
for (func <- validateWindowFunctions()) {
if (func._1 == "row_number") {
allLiteral = false
break
}
for (child <- func._2.children) {
if (!child.isInstanceOf[Literal]) {
allLiteral = false
Expand Down Expand Up @@ -216,9 +220,10 @@ case class ColumnarWindowExec(windowExpression: Seq[NamedExpression],
Iterator.empty
} else {
val prev1 = System.nanoTime()
val gWindowFunctions = windowFunctions.map {
case ("row_number", fc) =>
val attr = ConverterUtils.getAttrFromExpr(fc, true)
val gWindowFunctions = windowFunctions.map {
case ("row_number", spec) =>
//TODO(): should get attr from orderSpec
val attr = ConverterUtils.getAttrFromExpr(orderSpec.head.child, true)
TreeBuilder.makeFunction("row_number",
List(TreeBuilder.makeField(
Field.nullable(attr.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ arrow::Status ExprVisitor::MakeWindow(
for (const auto& child : node.children()) {
auto child_function = std::dynamic_pointer_cast<gandiva::FunctionNode>(child);
auto child_func_name = child_function->descriptor()->name();
std::cout << "window func name: " << child_func_name << std::endl;

if (child_func_name == "sum" || child_func_name == "avg" ||
child_func_name == "min" || child_func_name == "max" ||
child_func_name == "count" || child_func_name == "count_literal" ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ class WindowVisitorImpl : public ExprVisitorImpl {
function_param_type_list,
&function_kernel, true));
} else if (window_function_name == "row_number") {
RETURN_NOT_OK(extra::WindowRankKernel::Make(&p_->ctx_, window_function_name,
function_param_type_list,
&function_kernel, true/*FIXME: force decending*/));
RETURN_NOT_OK(extra::WindowRankKernel::Make(
&p_->ctx_, window_function_name, function_param_type_list, &function_kernel,
true /*FIXME: force decending*/));
} else {
return arrow::Status::Invalid("window function not supported: " +
window_function_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ class WindowRankKernel : public KernalBase {
public:
WindowRankKernel(arrow::compute::ExecContext* ctx,
std::vector<std::shared_ptr<arrow::DataType>> type_list,
std::shared_ptr<WindowSortKernel::Impl> sorter, bool desc, bool is_row_number = false);
std::shared_ptr<WindowSortKernel::Impl> sorter, bool desc,
bool is_row_number = false);
static arrow::Status Make(arrow::compute::ExecContext* ctx, std::string function_name,
std::vector<std::shared_ptr<arrow::DataType>> type_list,
std::shared_ptr<KernalBase>* out, bool desc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ arrow::Status WindowRankKernel::Make(
} else {
*out = std::make_shared<WindowRankKernel>(ctx, type_list, sorter, desc);
}

return arrow::Status::OK();
}

Expand Down Expand Up @@ -534,7 +534,7 @@ arrow::Status WindowRankKernel::AreTheSameValue(const std::vector<ArrayList>& va
bool* out) {
if (is_row_number_) {
*out = false;
return arrow::Status::OK();
return arrow::Status::OK();
}
auto typed_array_i =
std::dynamic_pointer_cast<ArrayType>(values.at(i->array_id).at(column));
Expand Down

0 comments on commit 0d6cd91

Please sign in to comment.