Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the behavior of the substring function consistent with Spark #445

Open
wants to merge 57 commits into
base: clickhouse_backend
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6b7a3ea
Update autogenerated version to 23.3.2.1 and contributors
alexey-milovidov Mar 31, 2023
3d908aa
Backport #48314 to 23.3: Fix ThreadPool for DistributedSink and use S…
robot-clickhouse Apr 2, 2023
85f5600
Merge pull request #48323 from ClickHouse/backport/23.3/48314
tavplubix Apr 2, 2023
7d350fb
Backport #47246 to 23.3: Change the behavior of formatter %M in funct…
robot-clickhouse Apr 6, 2023
e14f2b4
Disable incompatible behavior
rschu1ze Apr 6, 2023
4d40c08
Backport #48469 to 23.3: Fix possible segfault in cache
robot-clickhouse Apr 6, 2023
1f4abc0
Merge pull request #48483 from ClickHouse/backport/23.3/48469
kssenii Apr 6, 2023
b25e79e
Backport #48357 to 23.3: Batch fix for projections analysis with anal…
robot-clickhouse Apr 6, 2023
9458145
Backport #48195 to 23.3: Remove a feature
robot-clickhouse Apr 6, 2023
09423f9
Backport #48386 to 23.3: Reset downloader for cache file segment in T…
robot-clickhouse Apr 6, 2023
8dff41e
Merge pull request #48508 from ClickHouse/backport/23.3/48195
robot-clickhouse Apr 7, 2023
4a2cc3d
Merge pull request #48511 from ClickHouse/backport/23.3/48386
kssenii Apr 7, 2023
39224dc
Backport #48311 to 23.3: Fix cpu usage in rabbitmq (was worsened in 2…
robot-clickhouse Apr 7, 2023
b7b4adb
Backport #48572 to 23.3: Update CCTZ
robot-clickhouse Apr 10, 2023
492f5fa
Merge pull request #48589 from ClickHouse/backport/23.3/48572
robot-ch-test-poll Apr 10, 2023
4fa42d7
Merge pull request #48459 from ClickHouse/backport/23.3/47246
rschu1ze Apr 11, 2023
1159098
Merge pull request #48540 from ClickHouse/backport/23.3/48311
kssenii Apr 11, 2023
8a6e964
Backport #48595 to 23.3: Fix bug in Keeper when a node is not created…
robot-clickhouse Apr 11, 2023
2cbc1e9
Backport #48611 to 23.3: Fix IPv4 comparable with UInt
robot-clickhouse Apr 11, 2023
19e7c2b
Merge pull request #48657 from ClickHouse/backport/23.3/48611
yakov-olkhovskiy Apr 12, 2023
29f7c41
Merge pull request #48648 from ClickHouse/backport/23.3/48595
antonio2368 Apr 12, 2023
6fc0789
Merge pull request #48495 from ClickHouse/backport/23.3/48357
KochetovNicolai Apr 12, 2023
4553c8b
Backport #48419 to 23.3: ClickHouse startup error when loading a dist…
robot-clickhouse Apr 12, 2023
b76e334
Merge pull request #48708 from ClickHouse/backport/23.3/48419
tavplubix Apr 14, 2023
691c206
Backport #48793 to 23.3: Fix a confusing warning about interserver mode
robot-clickhouse Apr 15, 2023
c032d98
Merge pull request #48813 from ClickHouse/backport/23.3/48793
alexey-milovidov Apr 17, 2023
fc80ad2
Backport #48759 to 23.3: Fix some settings of mysql dictionary with n…
robot-clickhouse Apr 17, 2023
61638dc
Backport #48556 to 23.3: Fix nested map for keys of IP and UUID types
robot-clickhouse Apr 18, 2023
65e7719
Merge pull request #48842 from ClickHouse/backport/23.3/48759
kssenii Apr 18, 2023
e86ae6b
Backport #48924 to 23.3: Reduce docker image size, fix slow startup
robot-clickhouse Apr 19, 2023
954a751
Merge pull request #48891 from ClickHouse/backport/23.3/48556
yakov-olkhovskiy Apr 19, 2023
ef8921f
Merge pull request #48960 from ClickHouse/backport/23.3/48924
Felixoid Apr 20, 2023
3485eaa
Disable check which rely on log level test
alesapin Apr 21, 2023
9b7e9bc
Backport #48989 to 23.3: Add fallback to password auth after failed S…
robot-clickhouse Apr 21, 2023
e4d19f0
Merge pull request #49035 from ClickHouse/backport/23.3/48989
evillique Apr 22, 2023
199692b
Merge pull request #49014 from ClickHouse/remove_outdated_flaky_test
alesapin Apr 21, 2023
1b144bc
Fix test again
alesapin Apr 22, 2023
cb89233
Update autogenerated version to 23.3.3.1 and contributors
alesapin Apr 22, 2023
dd129c5
Backport #48999 to 23.3: Fix aggregate empty string error
robot-clickhouse Apr 23, 2023
6faf086
Merge pull request #49073 from ClickHouse/backport/23.3/48999
alexey-milovidov Apr 23, 2023
43ac3d2
group array function change from lgbo
liuneng1994 Apr 19, 2023
2c44fb2
insert range selective for shuffle write
liuneng1994 Apr 19, 2023
49cb20f
memory manager
liuneng1994 Apr 19, 2023
e35c0d1
support nullable inside complex type
liuneng1994 Apr 19, 2023
3159189
add lowercase setting for format
liuneng1994 Apr 19, 2023
277ef66
function change from bigo
liuneng1994 Apr 19, 2023
8ec3541
api change for join parsing
liuneng1994 Apr 19, 2023
faa18d8
import extern local engine
liuneng1994 Apr 19, 2023
5679d23
project config change
liuneng1994 Apr 19, 2023
b66d985
change for complex type from liyang
liuneng1994 Apr 23, 2023
bca8fd6
remove useDefaultImplementationForNulls override
liuneng1994 Apr 23, 2023
518e861
wip support map args for map_from_arrays
taiyang-li Mar 30, 2023
7f3d157
fix bugs
taiyang-li Mar 30, 2023
5a78c65
add docs and uts
taiyang-li Mar 30, 2023
8ea193e
fix exception message
taiyang-li Apr 4, 2023
52be833
fix aggregate all key is null error
liuneng1994 Apr 25, 2023
6ad5078
minor fix subString use index 0
May 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,6 @@ tests/queries/0_stateless/*.expect.history
/rust/**/target
# It is autogenerated from *.in
/rust/**/.cargo/config.toml

utils/local-engine/tests/testConfig.h
/utils/extern-local-engine
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ endif ()

include(cmake/dbms_glob_sources.cmake)

set (CMAKE_POSITION_INDEPENDENT_CODE ON)

add_library(global-group INTERFACE)
if (OS_LINUX OR OS_ANDROID)
include(cmake/linux/default_libs.cmake)
Expand Down Expand Up @@ -434,7 +436,6 @@ endif ()

set (CMAKE_POSTFIX_VARIABLE "CMAKE_${CMAKE_BUILD_TYPE_UC}_POSTFIX")

set (CMAKE_POSITION_INDEPENDENT_CODE OFF)
if (OS_LINUX AND NOT (ARCH_AARCH64 OR ARCH_S390X))
# Slightly more efficient code can be generated
# It's disabled for ARM because otherwise ClickHouse cannot run on Android.
Expand Down Expand Up @@ -497,8 +498,10 @@ macro (clickhouse_add_executable target)
if (${type} STREQUAL EXECUTABLE)
# disabled for TSAN and gcc since libtsan.a provides overrides too
if (TARGET clickhouse_new_delete)
# operator::new/delete for executables (MemoryTracker stuff)
target_link_libraries (${target} PRIVATE clickhouse_new_delete)
if (NOT ${target} STREQUAL Git::Git)
# operator::new/delete for executables (MemoryTracker stuff)
target_link_libraries (${target} PRIVATE clickhouse_new_delete ${MALLOC_LIBRARIES})
endif()
endif()

# In case of static jemalloc, because zone_register() is located in zone.c and
Expand Down
12 changes: 12 additions & 0 deletions base/base/IPv4andIPv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ namespace DB
};

}

namespace std
{
template <>
struct hash<DB::IPv6>
{
size_t operator()(const DB::IPv6 & x) const
{
return std::hash<DB::IPv6::UnderlyingType>()(x.toUnderType());
}
};
}
2 changes: 1 addition & 1 deletion base/base/strong_typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct StrongTypedef
Self & operator=(T && rhs) { t = std::move(rhs); return *this;}

// NOLINTBEGIN(google-explicit-constructor)
operator const T & () const { return t; }
constexpr operator const T & () const { return t; }
operator T & () { return t; }
// NOLINTEND(google-explicit-constructor)

Expand Down
8 changes: 4 additions & 4 deletions cmake/autogenerated_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
SET(VERSION_REVISION 54472)
SET(VERSION_MAJOR 23)
SET(VERSION_MINOR 3)
SET(VERSION_PATCH 1)
SET(VERSION_GITHASH 52bf836e03a6ba7cf2d654eaaf73231701abc3a2)
SET(VERSION_DESCRIBE v23.3.1.2537-testing)
SET(VERSION_STRING 23.3.1.2537)
SET(VERSION_PATCH 3)
SET(VERSION_GITHASH 1b144bcd101ddf23466ba67e4fa0fd27afb9c060)
SET(VERSION_DESCRIBE v23.3.3.1-lts)
SET(VERSION_STRING 23.3.3.1)
# end of autochange
9 changes: 4 additions & 5 deletions docker/test/integration/runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ENV DOCKER_CHANNEL stable
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -c -s) ${DOCKER_CHANNEL}"

RUN apt-get update \
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -c -s) ${DOCKER_CHANNEL}" \
&& apt-get update \
&& env DEBIAN_FRONTEND=noninteractive apt-get install --yes \
docker-ce \
&& rm -rf \
Expand All @@ -60,7 +59,7 @@ RUN apt-get update \

RUN dockerd --version; docker --version

RUN python3 -m pip install \
RUN python3 -m pip install --no-cache-dir \
PyMySQL \
aerospike==4.0.0 \
avro==1.10.2 \
Expand Down
4 changes: 3 additions & 1 deletion docker/test/integration/runner/dockerd-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ echo '{
# and on hung you can simply press Ctrl-C and it will spawn a python pdb,
# but on SIGINT dockerd will exit, so ignore it to preserve the daemon.
trap '' INT
dockerd --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 --default-address-pool base=172.17.0.0/12,size=24 &>/ClickHouse/tests/integration/dockerd.log &
# Binding to an IP address without --tlsverify is deprecated. Startup is intentionally being slowed
# unless --tls=false or --tlsverify=false is set
dockerd --host=unix:///var/run/docker.sock --tls=false --host=tcp://0.0.0.0:2375 --default-address-pool base=172.17.0.0/12,size=24 &>/ClickHouse/tests/integration/dockerd.log &

set +e
reties=0
Expand Down
20 changes: 12 additions & 8 deletions docs/en/sql-reference/functions/tuple-map-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Result:

## mapFromArrays

Merges an [Array](../../sql-reference/data-types/array.md) of keys and an [Array](../../sql-reference/data-types/array.md) of values into a [Map(key, value)](../../sql-reference/data-types/map.md).
Merges an [Array](../../sql-reference/data-types/array.md) of keys and an [Array](../../sql-reference/data-types/array.md) of values into a [Map(key, value)](../../sql-reference/data-types/map.md). Notice that the second argument could also be a [Map](../../sql-reference/data-types/map.md), thus it is casted to an Array when executing.

The function is a more convenient alternative to `CAST((key_array, value_array), 'Map(key_type, value_type)')`. For example, instead of writing `CAST((['aa', 'bb'], [4, 5]), 'Map(String, UInt32)')`, you can write `mapFromArrays(['aa', 'bb'], [4, 5])`.
The function is a more convenient alternative to `CAST((key_array, value_array_or_map), 'Map(key_type, value_type)')`. For example, instead of writing `CAST((['aa', 'bb'], [4, 5]), 'Map(String, UInt32)')`, you can write `mapFromArrays(['aa', 'bb'], [4, 5])`.

**Syntax**

Expand All @@ -82,25 +82,29 @@ Alias: `MAP_FROM_ARRAYS(keys, values)`

**Arguments**
- `keys` — Given key array to create a map from. The nested type of array must be: [String](../../sql-reference/data-types/string.md), [Integer](../../sql-reference/data-types/int-uint.md), [LowCardinality](../../sql-reference/data-types/lowcardinality.md), [FixedString](../../sql-reference/data-types/fixedstring.md), [UUID](../../sql-reference/data-types/uuid.md), [Date](../../sql-reference/data-types/date.md), [DateTime](../../sql-reference/data-types/datetime.md), [Date32](../../sql-reference/data-types/date32.md), [Enum](../../sql-reference/data-types/enum.md)
- `values` - Given value array to create a map from.
- `values` - Given value array or map to create a map from.

**Returned value**

- A map whose keys and values are constructed from the key and value arrays
- A map whose keys and values are constructed from the key array and value array/map.

**Example**

Query:

```sql
select mapFromArrays(['a', 'b', 'c'], [1, 2, 3])
```

```text

┌─mapFromArrays(['a', 'b', 'c'], [1, 2, 3])─┐
│ {'a':1,'b':2,'c':3} │
└───────────────────────────────────────────┘
```

SELECT mapFromArrays([1, 2, 3], map('a', 1, 'b', 2, 'c', 3))

┌─mapFromArrays([1, 2, 3], map('a', 1, 'b', 2, 'c', 3))─┐
│ {1:('a',1),2:('b',2),3:('c',3)} │
└───────────────────────────────────────────────────────┘
```

## mapAdd

Expand Down
6 changes: 3 additions & 3 deletions programs/server/MetricsTransmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void MetricsTransmitter::transmit(std::vector<ProfileEvents::Count> & prev_count

if (send_events)
{
for (size_t i = 0, end = ProfileEvents::end(); i < end; ++i)
for (ProfileEvents::Event i = ProfileEvents::Event(0), end = ProfileEvents::end(); i < end; ++i)
{
const auto counter = ProfileEvents::global_counters[i].load(std::memory_order_relaxed);
const auto counter_increment = counter - prev_counters[i];
Expand All @@ -100,7 +100,7 @@ void MetricsTransmitter::transmit(std::vector<ProfileEvents::Count> & prev_count

if (send_events_cumulative)
{
for (size_t i = 0, end = ProfileEvents::end(); i < end; ++i)
for (ProfileEvents::Event i = ProfileEvents::Event(0), end = ProfileEvents::end(); i < end; ++i)
{
const auto counter = ProfileEvents::global_counters[i].load(std::memory_order_relaxed);
std::string key{ProfileEvents::getName(static_cast<ProfileEvents::Event>(i))};
Expand All @@ -110,7 +110,7 @@ void MetricsTransmitter::transmit(std::vector<ProfileEvents::Count> & prev_count

if (send_metrics)
{
for (size_t i = 0, end = CurrentMetrics::end(); i < end; ++i)
for (CurrentMetrics::Metric i = CurrentMetrics::Metric(0), end = CurrentMetrics::end(); i < end; ++i)
{
const auto value = CurrentMetrics::values[i].load(std::memory_order_relaxed);

Expand Down
2 changes: 1 addition & 1 deletion src/AggregateFunctions/AggregateFunctionGroupArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ AggregateFunctionPtr createAggregateFunctionGroupArraySample(

void registerAggregateFunctionGroupArray(AggregateFunctionFactory & factory)
{
AggregateFunctionProperties properties = { .returns_default_when_only_null = false, .is_order_dependent = true };
AggregateFunctionProperties properties = { .returns_default_when_only_null = true, .is_order_dependent = true };

factory.registerFunction("groupArray", { createAggregateFunctionGroupArray<false>, properties });
factory.registerFunction("groupArraySample", { createAggregateFunctionGroupArraySample, properties });
Expand Down
2 changes: 2 additions & 0 deletions src/AggregateFunctions/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ static IAggregateFunction * createWithNumericBasedType(const IDataType & argumen
if (which.idx == TypeIndex::Date) return new AggregateFunctionTemplate<UInt16>(std::forward<TArgs>(args)...);
if (which.idx == TypeIndex::DateTime) return new AggregateFunctionTemplate<UInt32>(std::forward<TArgs>(args)...);
if (which.idx == TypeIndex::UUID) return new AggregateFunctionTemplate<UUID>(std::forward<TArgs>(args)...);
if (which.idx == TypeIndex::IPv4) return new AggregateFunctionTemplate<IPv4>(std::forward<TArgs>(args)...);
if (which.idx == TypeIndex::IPv6) return new AggregateFunctionTemplate<IPv6>(std::forward<TArgs>(args)...);
return nullptr;
}

Expand Down
29 changes: 29 additions & 0 deletions src/Columns/ColumnAggregateFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,35 @@ void ColumnAggregateFunction::insertDefault()
pushBackAndCreateState(data, arena, func.get());
}

void ColumnAggregateFunction::insertRangeSelective(
const IColumn & from, const IColumn::Selector & selector, size_t selector_start, size_t length)
{
const ColumnAggregateFunction & from_concrete = static_cast<const ColumnAggregateFunction &>(from);
const auto & from_data = from_concrete.data;
if (!empty() && src.get() != &from_concrete)
{
ensureOwnership();
Arena & arena = createOrGetArena();
Arena * arena_ptr = &arena;
data.reserve(size() + length);
for (size_t i = 0; i < length; ++i)
{
pushBackAndCreateState(data, arena, func.get());
func->merge(data.back(), from_data[selector[selector_start + i]], arena_ptr);
}
return;
}
/// Keep shared ownership of aggregation states.
src = from_concrete.getPtr();

size_t old_size = data.size();
data.resize(old_size + length);
auto * data_start = data.data();
size_t element_size = sizeof(data[0]);
for (size_t i = 0; i < length; ++i)
memcpy(data_start + old_size + i, &from_concrete.data[selector[selector_start + i]], element_size);
}

StringRef ColumnAggregateFunction::serializeValueIntoArena(size_t n, Arena & arena, const char *& begin) const
{
WriteBufferFromArena out(arena, begin);
Expand Down
2 changes: 2 additions & 0 deletions src/Columns/ColumnAggregateFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class ColumnAggregateFunction final : public COWHelper<IColumn, ColumnAggregateF

void insertRangeFrom(const IColumn & from, size_t start, size_t length) override;

void insertRangeSelective(const IColumn & src, const IColumn::Selector & selector, size_t selector_start, size_t length) override;

void popBack(size_t n) override;

ColumnPtr filter(const Filter & filter, ssize_t result_size_hint) const override;
Expand Down
23 changes: 23 additions & 0 deletions src/Columns/ColumnArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,29 @@ void ColumnArray::insertRangeFrom(const IColumn & src, size_t start, size_t leng
}
}

void ColumnArray::insertRangeSelective(const IColumn & src, const Selector & selector, size_t selector_start, size_t length){

const ColumnArray & src_concrete = static_cast<const ColumnArray &>(src);
const Offsets & src_offsets = src_concrete.getOffsets();
const IColumn & src_data = src_concrete.getData();
IColumn & cur_data = getData();
Offsets & cur_offsets = getOffsets();

size_t old_size = cur_offsets.size();
size_t cur_size = old_size + length;
cur_data.reserve(cur_size);
cur_offsets.resize(cur_size);

for (size_t i = 0; i < length; ++i)
{
size_t src_pos = selector[selector_start + i];
size_t offset = src_offsets[src_pos - 1];
size_t size = src_offsets[src_pos] - offset;
cur_data.insertRangeFrom(src_data, offset, size);
cur_offsets[old_size + i] = cur_offsets[old_size + i - 1] + size; // PaddedPODArray allows to use -1th element that will have value 0
}
}


ColumnPtr ColumnArray::filter(const Filter & filt, ssize_t result_size_hint) const
{
Expand Down
3 changes: 3 additions & 0 deletions src/Columns/ColumnArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ColumnArray final : public COWHelper<IColumn, ColumnArray>
void updateWeakHash32(WeakHash32 & hash) const override;
void updateHashFast(SipHash & hash) const override;
void insertRangeFrom(const IColumn & src, size_t start, size_t length) override;
void insertRangeSelective(const IColumn & src, const Selector & selector, size_t selector_start, size_t length) override;
void insert(const Field & x) override;
void insertFrom(const IColumn & src_, size_t n) override;
void insertDefault() override;
Expand Down Expand Up @@ -149,6 +150,8 @@ class ColumnArray final : public COWHelper<IColumn, ColumnArray>

void gather(ColumnGathererStream & gatherer_stream) override;

bool canBeInsideNullable() const override { return true; }

ColumnPtr compress() const override;

void forEachSubcolumn(ColumnCallback callback) const override
Expand Down
1 change: 1 addition & 0 deletions src/Columns/ColumnCompressed.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ColumnCompressed : public COWHelper<IColumn, ColumnCompressed>
bool isDefaultAt(size_t) const override { throwMustBeDecompressed(); }
void insert(const Field &) override { throwMustBeDecompressed(); }
void insertRangeFrom(const IColumn &, size_t, size_t) override { throwMustBeDecompressed(); }
void insertRangeSelective(const IColumn &, const Selector &, size_t, size_t) override { throwMustBeDecompressed(); }
void insertData(const char *, size_t) override { throwMustBeDecompressed(); }
void insertDefault() override { throwMustBeDecompressed(); }
void popBack(size_t) override { throwMustBeDecompressed(); }
Expand Down
5 changes: 5 additions & 0 deletions src/Columns/ColumnConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class ColumnConst final : public COWHelper<IColumn, ColumnConst>
s += length;
}

void insertRangeSelective(const IColumn & /*src*/, const Selector & /*selector*/, size_t /*selector_start*/, size_t length) override
{
s += length;
}

void insert(const Field &) override
{
++s;
Expand Down
12 changes: 12 additions & 0 deletions src/Columns/ColumnDecimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ void ColumnDecimal<T>::insertRangeFrom(const IColumn & src, size_t start, size_t
memcpy(data.data() + old_size, &src_vec.data[start], length * sizeof(data[0]));
}

template <is_decimal T>
void ColumnDecimal<T>::insertRangeSelective(const IColumn & src, const IColumn::Selector & selector, size_t selector_start, size_t length)
{
size_t old_size = data.size();
data.resize(old_size + length);
const auto & src_data = (static_cast<const Self &>(src)).getData();
for (size_t i = 0; i < length; ++i)
{
data[old_size + i] = src_data[selector[selector_start + i]];
}
}

template <is_decimal T>
ColumnPtr ColumnDecimal<T>::filter(const IColumn::Filter & filt, ssize_t result_size_hint) const
{
Expand Down
1 change: 1 addition & 0 deletions src/Columns/ColumnDecimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ColumnDecimal final : public COWHelper<ColumnVectorHelper, ColumnDecimal<T
void insertManyDefaults(size_t length) override { data.resize_fill(data.size() + length); }
void insert(const Field & x) override { data.push_back(x.get<T>()); }
void insertRangeFrom(const IColumn & src, size_t start, size_t length) override;
void insertRangeSelective(const IColumn & src, const IColumn::Selector & selector, size_t selector_start, size_t length) override;

void popBack(size_t n) override
{
Expand Down
16 changes: 16 additions & 0 deletions src/Columns/ColumnFixedString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,22 @@ void ColumnFixedString::insertRangeFrom(const IColumn & src, size_t start, size_
memcpy(chars.data() + old_size, &src_concrete.chars[start * n], length * n);
}

void ColumnFixedString::insertRangeSelective(const IColumn & src, const IColumn::Selector & selector, size_t selector_start, size_t length)
{
const ColumnFixedString & src_concrete = static_cast<const ColumnFixedString &>(src);

size_t old_size = chars.size();
chars.resize(old_size + length * n);
auto * cur_data_end = chars.data() + old_size;
auto * src_data_start = src_concrete.chars.data();

for (size_t i = 0; i < length; ++i)
{
size_t src_pos = selector[selector_start + i];
memcpySmallAllowReadWriteOverflow15(cur_data_end + i * n, src_data_start+ n * src_pos, n);
}
}

ColumnPtr ColumnFixedString::filter(const IColumn::Filter & filt, ssize_t result_size_hint) const
{
size_t col_size = size();
Expand Down
2 changes: 2 additions & 0 deletions src/Columns/ColumnFixedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class ColumnFixedString final : public COWHelper<ColumnVectorHelper, ColumnFixed

void insertRangeFrom(const IColumn & src, size_t start, size_t length) override;

void insertRangeSelective(const IColumn & src, const Selector & selector, size_t selector_start, size_t length) override;

ColumnPtr filter(const IColumn::Filter & filt, ssize_t result_size_hint) const override;

void expand(const IColumn::Filter & mask, bool inverted) override;
Expand Down
5 changes: 5 additions & 0 deletions src/Columns/ColumnMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ void ColumnMap::insertRangeFrom(const IColumn & src, size_t start, size_t length
start, length);
}

void ColumnMap::insertRangeSelective(const IColumn & src, const Selector & selector, size_t selector_start, size_t length)
{
nested->insertRangeSelective(assert_cast<const ColumnMap &>(src).getNestedColumn(), selector, selector_start, length);
}

ColumnPtr ColumnMap::filter(const Filter & filt, ssize_t result_size_hint) const
{
auto filtered = nested->filter(filt, result_size_hint);
Expand Down
Loading