Skip to content

Commit

Permalink
Fix null separator provided only
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Mar 26, 2024
1 parent fe68088 commit c58f5cf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions velox/functions/sparksql/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,18 @@ class ConcatWs : public exec::VectorFunction {
context.ensureWritable(selected, VARCHAR(), result);
auto flatResult = result->asFlatVector<StringView>();
auto numArgs = args.size();
// If separator is NULL, result is NULL.
if (args[0]->isNullAt(0)) {
selected.applyToSelected([&](int row) { result->setNull(row, true); });
return;
}
// If only separator (not a NULL) is provided, result is an empty array.
if (numArgs == 1) {
selected.applyToSelected(
[&](int row) { flatResult->setNoCopy(row, StringView("")); });
return;
}

if (args[0]->isNullAt(0)) {
selected.applyToSelected([&](int row) { result->setNull(row, true); });
return;
}

auto arrayArgs = args[1]->typeKind() == TypeKind::ARRAY;
if (arrayArgs) {
concatWsArray(selected, args, context, connector_, *flatResult);
Expand Down

0 comments on commit c58f5cf

Please sign in to comment.