Skip to content

Commit

Permalink
Update FunctionsIsIPAddr.h
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiTopQuark authored Feb 14, 2023
1 parent b66005f commit 32cef30
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions dbms/src/Functions/FunctionsIsIPAddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,28 @@ class FunctionIsIPv4OrIsIPv6 : public IFunction
}
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) const override
{
size_t size = block.getByPosition(arguments[0]).column->size();
auto col_res = ColumnUInt8::create();
ColumnUInt8::Container & vec_res = col_res->getData();
vec_res.resize(size);

/// Always null.
if (block.getByPosition(arguments[0]).type->onlyNull())
{
for (size_t i = 0; i < size; ++i)
{
vec_res[i] = 0;
}
block.getByPosition(result).column = std::move(col_res);
return;
}

auto [column, nullmap] = removeNullable(block.getByPosition(arguments[0]).column.get());
if (const auto * col_input = checkAndGetColumn<ColumnString>(column))
{
size_t size = block.getByPosition(arguments[0]).column->size();
const typename ColumnString::Chars_t & data = col_input->getChars();
const typename ColumnString::Offsets & offsets = col_input->getOffsets();

auto col_res = ColumnUInt8::create();
ColumnUInt8::Container & vec_res = col_res->getData();
vec_res.resize(size);

size_t prev_offset = 0;
for (size_t i = 0; i < size; ++i)
{
Expand Down

0 comments on commit 32cef30

Please sign in to comment.