Skip to content

Commit

Permalink
Merge branch 'master' into non-experimental-qpl-deflate
Browse files Browse the repository at this point in the history
  • Loading branch information
rschu1ze committed Jun 20, 2023
2 parents 0047559 + 3cf2f54 commit bc7df2b
Show file tree
Hide file tree
Showing 470 changed files with 10,695 additions and 3,413 deletions.
1 change: 1 addition & 0 deletions .clang-format
Expand Up @@ -74,6 +74,7 @@ ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
DerivePointerAlignment: false
DisableFormat: false
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
MacroBlockBegin: ''
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/woboq.yml
Expand Up @@ -12,6 +12,7 @@ jobs:
# don't use dockerhub push because this image updates so rarely
WoboqCodebrowser:
runs-on: [self-hosted, style-checker]
timeout-minutes: 420 # the task is pretty heavy, so there's an additional hour
steps:
- name: Set envs
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Expand Up @@ -19,7 +19,7 @@
url = https://github.com/google/googletest
[submodule "contrib/capnproto"]
path = contrib/capnproto
url = https://github.com/capnproto/capnproto
url = https://github.com/ClickHouse/capnproto
[submodule "contrib/double-conversion"]
path = contrib/double-conversion
url = https://github.com/google/double-conversion
Expand Down
6 changes: 4 additions & 2 deletions .yamllint
Expand Up @@ -6,8 +6,10 @@ rules:
level: warning
indent-sequences: consistent
line-length:
# there are some bash -c "", so this is OK
max: 300
# there are:
# - bash -c "", so this is OK
# - yaml in tests
max: 1000
level: warning
comments:
min-spaces-from-content: 1
Expand Down
5 changes: 5 additions & 0 deletions base/base/interpolate.h
Expand Up @@ -11,3 +11,8 @@ constexpr double interpolateExponential(double min, double max, double ratio)
assert(min > 0 && ratio >= 0 && ratio <= 1);
return min * std::pow(max / min, ratio);
}

constexpr double interpolateLinear(double min, double max, double ratio)
{
return std::lerp(min, max, ratio);
}
2 changes: 1 addition & 1 deletion contrib/capnproto
Submodule capnproto updated 66 files
+8 −3 .github/workflows/quick-test.yml
+26 −9 c++/.bazelrc
+1 −1 c++/.bazelversion
+8 −1 c++/WORKSPACE
+13 −0 c++/build/configure.bzl
+12 −0 c++/build/load_br.bzl
+1 −0 c++/compile_flags.txt
+10 −1 c++/src/capnp/BUILD.bazel
+15 −0 c++/src/capnp/capability.h
+3 −3 c++/src/capnp/compat/byte-stream-test.c++
+59 −3 c++/src/capnp/compat/byte-stream.c++
+4 −0 c++/src/capnp/compat/byte-stream.capnp
+3 −0 c++/src/capnp/compat/byte-stream.h
+128 −4 c++/src/capnp/compat/http-over-capnp-test.c++
+43 −19 c++/src/capnp/compat/http-over-capnp.c++
+6 −1 c++/src/capnp/compat/http-over-capnp.capnp
+20 −0 c++/src/capnp/compat/json.capnp.c++
+10 −6 c++/src/capnp/compiler/capnpc-c++.c++
+96 −0 c++/src/capnp/compiler/grammar.capnp.c++
+16 −0 c++/src/capnp/compiler/lexer.capnp.c++
+29 −28 c++/src/capnp/dynamic.c++
+21 −7 c++/src/capnp/dynamic.h
+15 −4 c++/src/capnp/generated-header-support.h
+40 −9 c++/src/capnp/membrane.c++
+18 −0 c++/src/capnp/membrane.h
+10 −0 c++/src/capnp/persistent.capnp.h
+137 −0 c++/src/capnp/rpc-twoparty-test.c++
+25 −10 c++/src/capnp/rpc-twoparty.c++
+24 −0 c++/src/capnp/rpc-twoparty.capnp.c++
+4 −1 c++/src/capnp/rpc-twoparty.h
+176 −32 c++/src/capnp/rpc.c++
+80 −0 c++/src/capnp/rpc.capnp.c++
+1 −1 c++/src/capnp/schema-parser.c++
+141 −1 c++/src/capnp/schema.capnp.c++
+4 −0 c++/src/capnp/stream.capnp.c++
+40 −10 c++/src/kj/BUILD.bazel
+25 −8 c++/src/kj/async-inl.h
+1 −1 c++/src/kj/async-io-unix.c++
+2 −2 c++/src/kj/async-io-win32.c++
+2 −2 c++/src/kj/async-io.c++
+51 −0 c++/src/kj/async-io.h
+1 −0 c++/src/kj/async-prelude.h
+117 −19 c++/src/kj/async-test.c++
+6 −1 c++/src/kj/async-win32.c++
+2 −2 c++/src/kj/async-win32.h
+37 −15 c++/src/kj/async.c++
+12 −1 c++/src/kj/async.h
+4 −1 c++/src/kj/common.h
+31 −0 c++/src/kj/compat/BUILD.bazel
+410 −0 c++/src/kj/compat/brotli-test.c++
+369 −0 c++/src/kj/compat/brotli.c++
+190 −0 c++/src/kj/compat/brotli.h
+8 −2 c++/src/kj/compat/gzip.c++
+5 −3 c++/src/kj/compat/gzip.h
+31 −16 c++/src/kj/compat/http-test.c++
+158 −37 c++/src/kj/compat/http.c++
+195 −2 c++/src/kj/compat/http.h
+72 −0 c++/src/kj/compat/tls-test.c++
+1 −1 c++/src/kj/compat/tls.h
+3 −2 c++/src/kj/exception.c++
+3 −3 c++/src/kj/filesystem.c++
+24 −0 c++/src/kj/memory-test.c++
+8 −2 c++/src/kj/memory.h
+2 −3 doc/otherlang.md
+4 −2 kjdoc/tour.md
+3 −1 style-guide.md
2 changes: 1 addition & 1 deletion contrib/jemalloc-cmake/CMakeLists.txt
Expand Up @@ -4,7 +4,7 @@ if (SANITIZE OR NOT (
))
if (ENABLE_JEMALLOC)
message (${RECONFIGURE_MESSAGE_LEVEL}
"jemalloc is disabled implicitly: it doesn't work with sanitizers and can only be used with x86_64, aarch64, or ppc64le Linux or FreeBSD builds and RelWithDebInfo macOS builds.")
"jemalloc is disabled implicitly: it doesn't work with sanitizers and can only be used with x86_64, aarch64, or ppc64le Linux or FreeBSD builds and RelWithDebInfo macOS builds. Use -DENABLE_JEMALLOC=0")
endif ()
set (ENABLE_JEMALLOC OFF)
else ()
Expand Down
2 changes: 1 addition & 1 deletion docker/keeper/Dockerfile
Expand Up @@ -32,7 +32,7 @@ RUN arch=${TARGETARCH:-amd64} \
esac

ARG REPOSITORY="https://s3.amazonaws.com/clickhouse-builds/22.4/31c367d3cd3aefd316778601ff6565119fe36682/package_release"
ARG VERSION="23.5.2.7"
ARG VERSION="23.5.3.24"
ARG PACKAGES="clickhouse-keeper"

# user/group precreated explicitly with fixed uid/gid on purpose.
Expand Down
2 changes: 1 addition & 1 deletion docker/server/Dockerfile.alpine
Expand Up @@ -33,7 +33,7 @@ RUN arch=${TARGETARCH:-amd64} \
# lts / testing / prestable / etc
ARG REPO_CHANNEL="stable"
ARG REPOSITORY="https://packages.clickhouse.com/tgz/${REPO_CHANNEL}"
ARG VERSION="23.5.2.7"
ARG VERSION="23.5.3.24"
ARG PACKAGES="clickhouse-client clickhouse-server clickhouse-common-static"

# user/group precreated explicitly with fixed uid/gid on purpose.
Expand Down
2 changes: 1 addition & 1 deletion docker/server/Dockerfile.ubuntu
Expand Up @@ -22,7 +22,7 @@ RUN sed -i "s|http://archive.ubuntu.com|${apt_archive}|g" /etc/apt/sources.list

ARG REPO_CHANNEL="stable"
ARG REPOSITORY="deb https://packages.clickhouse.com/deb ${REPO_CHANNEL} main"
ARG VERSION="23.5.2.7"
ARG VERSION="23.5.3.24"
ARG PACKAGES="clickhouse-client clickhouse-server clickhouse-common-static"

# set non-empty deb_location_url url to create a docker image
Expand Down
1 change: 1 addition & 0 deletions docker/server/README.md
Expand Up @@ -20,6 +20,7 @@ For more information and documentation see https://clickhouse.com/.

- The amd64 image requires support for [SSE3 instructions](https://en.wikipedia.org/wiki/SSE3). Virtually all x86 CPUs after 2005 support SSE3.
- The arm64 image requires support for the [ARMv8.2-A architecture](https://en.wikipedia.org/wiki/AArch64#ARMv8.2-A). Most ARM CPUs after 2017 support ARMv8.2-A. A notable exception is Raspberry Pi 4 from 2019 whose CPU only supports ARMv8.0-A.
- Since the Clickhouse 23.3 Ubuntu image started using `ubuntu:22.04` as its base image, it requires docker version >= `20.10.10`, or use `docker run -- privileged` instead. Alternatively, try the Clickhouse Alpine image.

## How to use this image

Expand Down
6 changes: 3 additions & 3 deletions docker/test/sqlancer/Dockerfile
Expand Up @@ -12,10 +12,10 @@ RUN apt-get update --yes && \
# We need to get the repository's HEAD each time despite, so we invalidate layers' cache
ARG CACHE_INVALIDATOR=0
RUN mkdir /sqlancer && \
wget -q -O- https://github.com/sqlancer/sqlancer/archive/master.tar.gz | \
wget -q -O- https://github.com/sqlancer/sqlancer/archive/main.tar.gz | \
tar zx -C /sqlancer && \
cd /sqlancer/sqlancer-master && \
mvn package -DskipTests && \
cd /sqlancer/sqlancer-main && \
mvn --no-transfer-progress package -DskipTests && \
rm -r /root/.m2

COPY run.sh /
Expand Down
1 change: 0 additions & 1 deletion docker/test/sqlancer/process_sqlancer_result.py
Expand Up @@ -16,7 +16,6 @@ def process_result(result_folder):
"TLPGroupBy",
"TLPHaving",
"TLPWhere",
"TLPWhereGroupBy",
"NoREC",
]
failed_tests = []
Expand Down
2 changes: 1 addition & 1 deletion docker/test/sqlancer/run.sh
Expand Up @@ -33,7 +33,7 @@ cd /workspace

for _ in $(seq 1 60); do if [[ $(wget -q 'localhost:8123' -O-) == 'Ok.' ]]; then break ; else sleep 1; fi ; done

cd /sqlancer/sqlancer-master
cd /sqlancer/sqlancer-main

TIMEOUT=300
NUM_QUERIES=1000
Expand Down
5 changes: 5 additions & 0 deletions docker/test/stateless/run.sh
Expand Up @@ -15,6 +15,9 @@ dpkg -i package_folder/clickhouse-client_*.deb

ln -s /usr/share/clickhouse-test/clickhouse-test /usr/bin/clickhouse-test

# shellcheck disable=SC1091
source /usr/share/clickhouse-test/ci/attach_gdb.lib || true # FIXME: to not break old builds, clean on 2023-09-01

# install test configs
/usr/share/clickhouse-test/config/install.sh

Expand Down Expand Up @@ -85,6 +88,8 @@ fi

sleep 5

attach_gdb_to_clickhouse || true # FIXME: to not break old builds, clean on 2023-09-01

function run_tests()
{
set -x
Expand Down
2 changes: 2 additions & 0 deletions docker/test/upgrade/run.sh
Expand Up @@ -61,6 +61,7 @@ configure

# it contains some new settings, but we can safely remove it
rm /etc/clickhouse-server/config.d/merge_tree.xml
rm /etc/clickhouse-server/users.d/nonconst_timezone.xml

start
stop
Expand Down Expand Up @@ -88,6 +89,7 @@ configure

# it contains some new settings, but we can safely remove it
rm /etc/clickhouse-server/config.d/merge_tree.xml
rm /etc/clickhouse-server/users.d/nonconst_timezone.xml

start

Expand Down
19 changes: 19 additions & 0 deletions docs/changelogs/v22.8.19.10-lts.md
@@ -0,0 +1,19 @@
---
sidebar_position: 1
sidebar_label: 2023
---

# 2023 Changelog

### ClickHouse release v22.8.19.10-lts (989bc2fe8b0) FIXME as compared to v22.8.18.31-lts (4de7a95a544)

#### Bug Fix (user-visible misbehavior in an official stable release)

* Fix subtly broken copy-on-write of ColumnLowCardinality dictionary [#51064](https://github.com/ClickHouse/ClickHouse/pull/51064) ([Michael Kolupaev](https://github.com/al13n321)).
* Generate safe IVs [#51086](https://github.com/ClickHouse/ClickHouse/pull/51086) ([Salvatore Mesoraca](https://github.com/aiven-sal)).

#### NOT FOR CHANGELOG / INSIGNIFICANT

* Fix a versions' tweak for tagged commits, improve version_helper [#51035](https://github.com/ClickHouse/ClickHouse/pull/51035) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Sqlancer has changed master to main [#51060](https://github.com/ClickHouse/ClickHouse/pull/51060) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).

22 changes: 22 additions & 0 deletions docs/changelogs/v23.3.4.17-lts.md
@@ -0,0 +1,22 @@
---
sidebar_position: 1
sidebar_label: 2023
---

# 2023 Changelog

### ClickHouse release v23.3.4.17-lts (2c99b73ff40) FIXME as compared to v23.3.3.52-lts (cb963c474db)

#### Bug Fix (user-visible misbehavior in an official stable release)

* Fix crash when Pool::Entry::disconnect() is called [#50334](https://github.com/ClickHouse/ClickHouse/pull/50334) ([Val Doroshchuk](https://github.com/valbok)).
* Avoid storing logs in Keeper containing unknown operation [#50751](https://github.com/ClickHouse/ClickHouse/pull/50751) ([Antonio Andelic](https://github.com/antonio2368)).
* Fix subtly broken copy-on-write of ColumnLowCardinality dictionary [#51064](https://github.com/ClickHouse/ClickHouse/pull/51064) ([Michael Kolupaev](https://github.com/al13n321)).
* Generate safe IVs [#51086](https://github.com/ClickHouse/ClickHouse/pull/51086) ([Salvatore Mesoraca](https://github.com/aiven-sal)).

#### NOT FOR CHANGELOG / INSIGNIFICANT

* Don't mark a part as broken on `Poco::TimeoutException` [#50811](https://github.com/ClickHouse/ClickHouse/pull/50811) ([Alexander Tokmakov](https://github.com/tavplubix)).
* Fix a versions' tweak for tagged commits, improve version_helper [#51035](https://github.com/ClickHouse/ClickHouse/pull/51035) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Sqlancer has changed master to main [#51060](https://github.com/ClickHouse/ClickHouse/pull/51060) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).

22 changes: 22 additions & 0 deletions docs/changelogs/v23.4.4.16-stable.md
@@ -0,0 +1,22 @@
---
sidebar_position: 1
sidebar_label: 2023
---

# 2023 Changelog

### ClickHouse release v23.4.4.16-stable (747ba4fc6a0) FIXME as compared to v23.4.3.48-stable (d9199f8d3cc)

#### Bug Fix (user-visible misbehavior in an official stable release)

* Fix crash when Pool::Entry::disconnect() is called [#50334](https://github.com/ClickHouse/ClickHouse/pull/50334) ([Val Doroshchuk](https://github.com/valbok)).
* Fix iceberg V2 optional metadata parsing [#50974](https://github.com/ClickHouse/ClickHouse/pull/50974) ([Kseniia Sumarokova](https://github.com/kssenii)).
* Fix subtly broken copy-on-write of ColumnLowCardinality dictionary [#51064](https://github.com/ClickHouse/ClickHouse/pull/51064) ([Michael Kolupaev](https://github.com/al13n321)).
* Generate safe IVs [#51086](https://github.com/ClickHouse/ClickHouse/pull/51086) ([Salvatore Mesoraca](https://github.com/aiven-sal)).

#### NOT FOR CHANGELOG / INSIGNIFICANT

* Don't mark a part as broken on `Poco::TimeoutException` [#50811](https://github.com/ClickHouse/ClickHouse/pull/50811) ([Alexander Tokmakov](https://github.com/tavplubix)).
* Fix a versions' tweak for tagged commits, improve version_helper [#51035](https://github.com/ClickHouse/ClickHouse/pull/51035) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Sqlancer has changed master to main [#51060](https://github.com/ClickHouse/ClickHouse/pull/51060) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).

26 changes: 26 additions & 0 deletions docs/changelogs/v23.5.3.24-stable.md
@@ -0,0 +1,26 @@
---
sidebar_position: 1
sidebar_label: 2023
---

# 2023 Changelog

### ClickHouse release v23.5.3.24-stable (76f54616d3b) FIXME as compared to v23.5.2.7-stable (5751aa1ab9f)

#### Bug Fix (user-visible misbehavior in an official stable release)

* Fix Log family table return wrong rows count after truncate [#50585](https://github.com/ClickHouse/ClickHouse/pull/50585) ([flynn](https://github.com/ucasfl)).
* Fix bug in `uniqExact` parallel merging [#50590](https://github.com/ClickHouse/ClickHouse/pull/50590) ([Nikita Taranov](https://github.com/nickitat)).
* Revert recent grace hash join changes [#50699](https://github.com/ClickHouse/ClickHouse/pull/50699) ([vdimir](https://github.com/vdimir)).
* Avoid storing logs in Keeper containing unknown operation [#50751](https://github.com/ClickHouse/ClickHouse/pull/50751) ([Antonio Andelic](https://github.com/antonio2368)).
* Add compat setting for non-const timezones [#50834](https://github.com/ClickHouse/ClickHouse/pull/50834) ([Robert Schulze](https://github.com/rschu1ze)).
* Fix iceberg V2 optional metadata parsing [#50974](https://github.com/ClickHouse/ClickHouse/pull/50974) ([Kseniia Sumarokova](https://github.com/kssenii)).
* Fix subtly broken copy-on-write of ColumnLowCardinality dictionary [#51064](https://github.com/ClickHouse/ClickHouse/pull/51064) ([Michael Kolupaev](https://github.com/al13n321)).
* Generate safe IVs [#51086](https://github.com/ClickHouse/ClickHouse/pull/51086) ([Salvatore Mesoraca](https://github.com/aiven-sal)).

#### NOT FOR CHANGELOG / INSIGNIFICANT

* Don't mark a part as broken on `Poco::TimeoutException` [#50811](https://github.com/ClickHouse/ClickHouse/pull/50811) ([Alexander Tokmakov](https://github.com/tavplubix)).
* Fix a versions' tweak for tagged commits, improve version_helper [#51035](https://github.com/ClickHouse/ClickHouse/pull/51035) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).
* Sqlancer has changed master to main [#51060](https://github.com/ClickHouse/ClickHouse/pull/51060) ([Mikhail f. Shiryaev](https://github.com/Felixoid)).

1 change: 1 addition & 0 deletions docs/en/engines/table-engines/index.md
Expand Up @@ -53,6 +53,7 @@ Engines in the family:
- [JDBC](../../engines/table-engines/integrations/jdbc.md)
- [MySQL](../../engines/table-engines/integrations/mysql.md)
- [MongoDB](../../engines/table-engines/integrations/mongodb.md)
- [Redis](../../engines/table-engines/integrations/redis.md)
- [HDFS](../../engines/table-engines/integrations/hdfs.md)
- [S3](../../engines/table-engines/integrations/s3.md)
- [Kafka](../../engines/table-engines/integrations/kafka.md)
Expand Down
Expand Up @@ -48,4 +48,4 @@ SELECT * FROM test_table;

## See also

[Azure Blob Storage Table Function](/docs/en/sql-reference/table-functions/azureBlobStorage.md)
[Azure Blob Storage Table Function](/docs/en/sql-reference/table-functions/azureBlobStorage)
6 changes: 6 additions & 0 deletions docs/en/engines/table-engines/integrations/hdfs.md
Expand Up @@ -233,6 +233,12 @@ libhdfs3 support HDFS namenode HA.
- `_path` — Path to the file.
- `_file` — Name of the file.

## Storage Settings {#storage-settings}

- [hdfs_truncate_on_insert](/docs/en/operations/settings/settings.md#hdfs-truncate-on-insert) - allows to truncate file before insert into it. Disabled by default.
- [hdfs_create_multiple_files](/docs/en/operations/settings/settings.md#hdfs_allow_create_multiple_files) - allows to create a new file on each insert if format has suffix. Disabled by default.
- [hdfs_skip_empty_files](/docs/en/operations/settings/settings.md#hdfs_skip_empty_files) - allows to skip empty files while reading. Disabled by default.

**See Also**

- [Virtual columns](../../../engines/table-engines/index.md#table_engines-virtual_columns)
1 change: 0 additions & 1 deletion docs/en/engines/table-engines/integrations/index.md
Expand Up @@ -7,4 +7,3 @@ sidebar_label: Integrations
# Table Engines for Integrations

ClickHouse provides various means for integrating with external systems, including table engines. Like with all other table engines, the configuration is done using `CREATE TABLE` or `ALTER TABLE` queries. Then from a user perspective, the configured integration looks like a normal table, but queries to it are proxied to the external system. This transparent querying is one of the key advantages of this approach over alternative integration methods, like dictionaries or table functions, which require the use of custom query methods on each use.

4 changes: 4 additions & 0 deletions docs/en/engines/table-engines/integrations/mysql.md
Expand Up @@ -35,6 +35,10 @@ The table structure can differ from the original MySQL table structure:
- Column types may differ from those in the original MySQL table. ClickHouse tries to [cast](../../../engines/database-engines/mysql.md#data_types-support) values to the ClickHouse data types.
- The [external_table_functions_use_nulls](../../../operations/settings/settings.md#external-table-functions-use-nulls) setting defines how to handle Nullable columns. Default value: 1. If 0, the table function does not make Nullable columns and inserts default values instead of nulls. This is also applicable for NULL values inside arrays.

:::note
The MySQL Table Engine is currently not available on the ClickHouse builds for MacOS ([issue](https://github.com/ClickHouse/ClickHouse/issues/21191))
:::

**Engine Parameters**

- `host:port` — MySQL server address.
Expand Down
23 changes: 17 additions & 6 deletions docs/en/engines/table-engines/integrations/postgresql.md
Expand Up @@ -136,7 +136,7 @@ postgresql> SELECT * FROM test;

### Creating Table in ClickHouse, and connecting to PostgreSQL table created above

This example uses the [PostgreSQL table engine](/docs/en/engines/table-engines/integrations/postgresql.md) to connect the ClickHouse table to the PostgreSQL table:
This example uses the [PostgreSQL table engine](/docs/en/engines/table-engines/integrations/postgresql.md) to connect the ClickHouse table to the PostgreSQL table and use both SELECT and INSERT statements to the PostgreSQL database:

``` sql
CREATE TABLE default.postgresql_table
Expand All @@ -150,10 +150,21 @@ ENGINE = PostgreSQL('localhost:5432', 'public', 'test', 'postges_user', 'postgre

### Inserting initial data from PostgreSQL table into ClickHouse table, using a SELECT query

The [postgresql table function](/docs/en/sql-reference/table-functions/postgresql.md) copies the data from PostgreSQL to ClickHouse, which is often used for improving the query performance of the data by querying or performing analytics in ClickHouse rather than in PostgreSQL, or can also be used for migrating data from PostgreSQL to ClickHouse:
The [postgresql table function](/docs/en/sql-reference/table-functions/postgresql.md) copies the data from PostgreSQL to ClickHouse, which is often used for improving the query performance of the data by querying or performing analytics in ClickHouse rather than in PostgreSQL, or can also be used for migrating data from PostgreSQL to ClickHouse. Since we will be copying the data from PostgreSQL to ClickHouse, we will use a MergeTree table engine in ClickHouse and call it postgresql_copy:

``` sql
INSERT INTO default.postgresql_table
CREATE TABLE default.postgresql_copy
(
`float_nullable` Nullable(Float32),
`str` String,
`int_id` Int32
)
ENGINE = MergeTree
ORDER BY (int_id);
```

``` sql
INSERT INTO default.postgresql_copy
SELECT * FROM postgresql('localhost:5432', 'public', 'test', 'postges_user', 'postgres_password');
```

Expand All @@ -164,21 +175,21 @@ If then performing ongoing synchronization between the PostgreSQL table and Clic
This would require keeping track of the max ID or timestamp previously added, such as the following:

``` sql
SELECT max(`int_id`) AS maxIntID FROM default.postgresql_table;
SELECT max(`int_id`) AS maxIntID FROM default.postgresql_copy;
```

Then inserting values from PostgreSQL table greater than the max

``` sql
INSERT INTO default.postgresql_table
INSERT INTO default.postgresql_copy
SELECT * FROM postgresql('localhost:5432', 'public', 'test', 'postges_user', 'postgres_password');
WHERE int_id > maxIntID;
```

### Selecting data from the resulting ClickHouse table

``` sql
SELECT * FROM postgresql_table WHERE str IN ('test');
SELECT * FROM postgresql_copy WHERE str IN ('test');
```

``` text
Expand Down

0 comments on commit bc7df2b

Please sign in to comment.