forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
relative pr: Fix replace SparkSQL function facebookincubator#277 Support kPreceeding & kFollowing for window range frame type facebookincubator#287 support timestamp hash facebookincubator#269 Spark sum can overflow facebookincubator#101 Support float & double types in pmod function facebookincubator#157 Implement datetime functions in velox/sparksql. facebookincubator#81 Fix type check in MapFunction facebookincubator#273 Let function validation fail for lookaround pattern in RE2-based implementation facebookincubator#124 Register lpad/rpad functions for Spark SQL. facebookincubator#63 Support substring_index sql function facebookincubator#189 Fix First/Last aggregate functions intermediate type and support decimal facebookincubator#245 Support date_add spark sql function facebookincubator#144
- Loading branch information
1 parent
26e686f
commit 731b4be
Showing
67 changed files
with
5,887 additions
and
156 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
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
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
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,72 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed 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 "velox/expression/Expr.h" | ||
#include "velox/expression/VectorFunction.h" | ||
|
||
namespace facebook::velox::functions { | ||
namespace { | ||
|
||
class RowFunctionWithNull : public exec::VectorFunction { | ||
public: | ||
void apply( | ||
const SelectivityVector& rows, | ||
std::vector<VectorPtr>& args, | ||
const TypePtr& outputType, | ||
exec::EvalCtx& context, | ||
VectorPtr& result) const override { | ||
auto argsCopy = args; | ||
|
||
BufferPtr nulls = AlignedBuffer::allocate<char>( | ||
bits::nbytes(rows.size()), context.pool(), 1); | ||
auto* nullsPtr = nulls->asMutable<uint64_t>(); | ||
auto cntNull = 0; | ||
rows.applyToSelected([&](vector_size_t i) { | ||
bits::clearNull(nullsPtr, i); | ||
if (!bits::isBitNull(nullsPtr, i)) { | ||
for (size_t c = 0; c < argsCopy.size(); c++) { | ||
auto arg = argsCopy[c].get(); | ||
if (arg->mayHaveNulls() && arg->isNullAt(i)) { | ||
// If any argument of the struct is null, set the struct as null. | ||
bits::setNull(nullsPtr, i, true); | ||
cntNull++; | ||
break; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
RowVectorPtr localResult = std::make_shared<RowVector>( | ||
context.pool(), | ||
outputType, | ||
nulls, | ||
rows.size(), | ||
std::move(argsCopy), | ||
cntNull /*nullCount*/); | ||
context.moveOrCopyResult(localResult, rows, result); | ||
} | ||
|
||
bool isDefaultNullBehavior() const override { | ||
return false; | ||
} | ||
}; | ||
} // namespace | ||
|
||
VELOX_DECLARE_VECTOR_FUNCTION( | ||
udf_concat_row_with_null, | ||
std::vector<std::shared_ptr<exec::FunctionSignature>>{}, | ||
std::make_unique<RowFunctionWithNull>()); | ||
|
||
} // namespace facebook::velox::functions |
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
Oops, something went wrong.