Skip to content

Commit

Permalink
add blob version of repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
lnkuiper committed Sep 18, 2023
1 parent b0814a1 commit 2cd19e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/core_functions/function_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static StaticFunctionDefinition internal_functions[] = {
DUCKDB_AGGREGATE_FUNCTION(RegrSXXFun),
DUCKDB_AGGREGATE_FUNCTION(RegrSXYFun),
DUCKDB_AGGREGATE_FUNCTION(RegrSYYFun),
DUCKDB_SCALAR_FUNCTION(RepeatFun),
DUCKDB_SCALAR_FUNCTION_SET(RepeatFun),
DUCKDB_SCALAR_FUNCTION(ReplaceFun),
DUCKDB_AGGREGATE_FUNCTION_SET(ReservoirQuantileFun),
DUCKDB_SCALAR_FUNCTION(ReverseFun),
Expand Down
13 changes: 8 additions & 5 deletions src/core_functions/scalar/string/repeat.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "duckdb/core_functions/scalar/string_functions.hpp"

#include "duckdb/common/exception.hpp"
#include "duckdb/common/vector_operations/binary_executor.hpp"
#include "duckdb/core_functions/scalar/string_functions.hpp"

#include <string.h>
#include <ctype.h>
#include <string.h>

namespace duckdb {

Expand Down Expand Up @@ -33,8 +32,12 @@ static void RepeatFunction(DataChunk &args, ExpressionState &state, Vector &resu
});
}

ScalarFunction RepeatFun::GetFunction() {
return ScalarFunction({LogicalType::VARCHAR, LogicalType::BIGINT}, LogicalType::VARCHAR, RepeatFunction);
ScalarFunctionSet RepeatFun::GetFunctions() {
ScalarFunctionSet repeat;
for (const auto &type : {LogicalType::VARCHAR, LogicalType::BLOB}) {
repeat.AddFunction(ScalarFunction({type, LogicalType::BIGINT}, type, RepeatFunction));
}
return repeat;
}

} // namespace duckdb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct RepeatFun {
static constexpr const char *Description = "Repeats the string count number of times";
static constexpr const char *Example = "repeat('A', 5)";

static ScalarFunction GetFunction();
static ScalarFunctionSet GetFunctions();
};

struct ReplaceFun {
Expand Down

0 comments on commit 2cd19e1

Please sign in to comment.