-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VL] Register row_constructor_with_null (#3499)
- Loading branch information
Showing
5 changed files
with
124 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "RowConstructorWithNull.h" | ||
#include "velox/expression/VectorFunction.h" | ||
|
||
namespace gluten { | ||
facebook::velox::TypePtr RowConstructorWithNullCallToSpecialForm::resolveType( | ||
const std::vector<facebook::velox::TypePtr>& argTypes) { | ||
auto numInput = argTypes.size(); | ||
std::vector<std::string> names(numInput); | ||
std::vector<facebook::velox::TypePtr> types(numInput); | ||
for (auto i = 0; i < numInput; i++) { | ||
types[i] = argTypes[i]; | ||
names[i] = fmt::format("c{}", i + 1); | ||
} | ||
return facebook::velox::ROW(std::move(names), std::move(types)); | ||
} | ||
|
||
facebook::velox::exec::ExprPtr RowConstructorWithNullCallToSpecialForm::constructSpecialForm( | ||
const std::string& name, | ||
const facebook::velox::TypePtr& type, | ||
std::vector<facebook::velox::exec::ExprPtr>&& compiledChildren, | ||
bool trackCpuUsage, | ||
const facebook::velox::core::QueryConfig& config) { | ||
auto rowConstructorVectorFunction = | ||
facebook::velox::exec::vectorFunctionFactories().withRLock([&config, &name](auto& functionMap) { | ||
auto functionIterator = functionMap.find(name); | ||
return functionIterator->second.factory(name, {}, config); | ||
}); | ||
|
||
return std::make_shared<facebook::velox::exec::Expr>( | ||
type, std::move(compiledChildren), rowConstructorVectorFunction, name, trackCpuUsage); | ||
} | ||
|
||
facebook::velox::exec::ExprPtr RowConstructorWithNullCallToSpecialForm::constructSpecialForm( | ||
const facebook::velox::TypePtr& type, | ||
std::vector<facebook::velox::exec::ExprPtr>&& compiledChildren, | ||
bool trackCpuUsage, | ||
const facebook::velox::core::QueryConfig& config) { | ||
return constructSpecialForm(kRowConstructorWithNull, type, std::move(compiledChildren), trackCpuUsage, config); | ||
} | ||
} // namespace gluten |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "velox/expression/FunctionCallToSpecialForm.h" | ||
#include "velox/expression/SpecialForm.h" | ||
|
||
namespace gluten { | ||
class RowConstructorWithNullCallToSpecialForm : public facebook::velox::exec::FunctionCallToSpecialForm { | ||
public: | ||
facebook::velox::TypePtr resolveType(const std::vector<facebook::velox::TypePtr>& argTypes) override; | ||
|
||
facebook::velox::exec::ExprPtr constructSpecialForm( | ||
const facebook::velox::TypePtr& type, | ||
std::vector<facebook::velox::exec::ExprPtr>&& compiledChildren, | ||
bool trackCpuUsage, | ||
const facebook::velox::core::QueryConfig& config) override; | ||
|
||
static constexpr const char* kRowConstructorWithNull = "row_constructor_with_null"; | ||
|
||
protected: | ||
facebook::velox::exec::ExprPtr constructSpecialForm( | ||
const std::string& name, | ||
const facebook::velox::TypePtr& type, | ||
std::vector<facebook::velox::exec::ExprPtr>&& compiledChildren, | ||
bool trackCpuUsage, | ||
const facebook::velox::core::QueryConfig& config); | ||
}; | ||
} // namespace gluten |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters