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

Fix datetime limits #379

Merged
merged 37 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f55a348
Added test case to test datatypes replication when clickhouse server …
subkanthi Nov 17, 2023
534c06c
Removed postgres.yml.OLD
subkanthi Nov 17, 2023
9f47a23
Added test case to retrieve server timezone
subkanthi Nov 17, 2023
a898275
Merge branch 'develop' into fix_datetime_limits
subkanthi Nov 17, 2023
01de83f
Converted logic of converting datetime, added function to retrieve cl…
subkanthi Nov 20, 2023
63e2223
Merge branch 'develop' of github.com:Altinity/clickhouse-sink-connect…
subkanthi Nov 20, 2023
8ede79d
Merge branch 'fix_datetime_limits' of github.com:Altinity/clickhouse-…
subkanthi Nov 20, 2023
1d5dbb5
Added integration test for testing data types in schema only mode
subkanthi Nov 21, 2023
7f4ed11
Merge branch 'develop' into fix_datetime_limits
subkanthi Nov 22, 2023
44ab85d
Added logic to override DateTime/DateTime64 insert syntax to String
subkanthi Nov 22, 2023
aedf70d
Merge branch 'fix_datetime_limits' of github.com:Altinity/clickhouse-…
subkanthi Nov 22, 2023
492f007
Added logic to limit DateTime/DateTime32, DateTime64 based on clickho…
subkanthi Nov 23, 2023
63bb852
Added new class to store column overrides
subkanthi Nov 23, 2023
334ad64
Added more test cases to cover datetime limits in DebeziumConverterTest
subkanthi Nov 24, 2023
db76a1a
Added tests for microtimestamp converter(dateTime(4, 5, 6)
subkanthi Nov 25, 2023
d7199e9
Fixed DateTime max range for timestamp converter
subkanthi Nov 25, 2023
ecc4061
Added test to validate precision in datetime fields
subkanthi Nov 27, 2023
16e4655
Fixed integration tests for datetime, added logic to include primary …
subkanthi Nov 27, 2023
0ebaae9
Fixed logic of retrieving precision from CREATE DDL and mapping it to…
subkanthi Nov 29, 2023
30e8553
Merge branch 'develop' of github.com:Altinity/clickhouse-sink-connect…
subkanthi Nov 29, 2023
c0a00c7
Fix unit tests for data type converter
subkanthi Nov 29, 2023
1a5cf29
Merge branch 'develop' of github.com:Altinity/clickhouse-sink-connect…
subkanthi Nov 29, 2023
867ca00
Added tests to cover timezone
subkanthi Dec 1, 2023
34bbd0e
Added test to validate datetime when user configuration to override t…
subkanthi Dec 1, 2023
6f8b2d3
Added documentation on Datetime timezone override logic
subkanthi Dec 1, 2023
cc397ba
Updated JDK to 17 for lightweight, added tests to validate timezone o…
subkanthi Dec 1, 2023
ce6995b
Pulled changes from develop
subkanthi Dec 1, 2023
fbe9ce8
Fixed integration unit tests
subkanthi Dec 2, 2023
4ce61ee
Updated JDK to 17 and fixed google guice requirements for JDK 17, Add…
subkanthi Dec 4, 2023
710e650
Updated JDK to 17 in github workflows
subkanthi Dec 4, 2023
0cd215d
Update to JDK 17 in docker-build.yml
subkanthi Dec 4, 2023
d4ae914
Fixed flow when skip_replica_start is set
subkanthi Dec 4, 2023
ddfbc7c
Updated test cases to include forceStart flag when restarting debezium
subkanthi Dec 4, 2023
9092cc4
Use clickhouse-jdbc functions to parse the data type from column name…
subkanthi Dec 5, 2023
4c1d490
Pulled changes from develop
subkanthi Dec 5, 2023
e498af9
Fixed limits check in DateTime tests
subkanthi Dec 7, 2023
aad4813
Update configuration of timezone and binary.handling.mode in config.yml
subkanthi Dec 7, 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
4 changes: 2 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sink-connector-kafka-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sink-connector-lightweight-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Install maven
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:11
FROM openjdk:17
COPY sink-connector-client/sink-connector-client /sink-connector-client
COPY sink-connector-lightweight/target/clickhouse-debezium-embedded-1.0-SNAPSHOT.jar /app.jar
COPY sink-connector-lightweight/target/clickhouse-debezium-embedded*.jar /app.jar
ENV JAVA_OPTS="-Dlog4jDebug=true"
ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005", "-jar","/app.jar", "/config.yml", "com.altinity.clickhouse.debezium.embedded.ClickHouseDebeziumEmbeddedApplication"]
5 changes: 5 additions & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ https://debezium.io/documentation/reference/stable/connectors/postgresql.html#po
| persist.raw.bytes | Debezium.BYTES data(usually UUID) is persisted as raw bytes(CH String) if set to true. |
| database.connectionTimeZone | Example: "US/Samoa, Specify MySQL timezone for DATETIME conversions.https://debezium.io/documentation/reference/stable/connectors/mysql.html#mysql-temporal-types |
| enable.snapshot.ddl | When true, pre-existing DDL statements from source(MySQL) will be executed. Warning: This might run DROP TABLE commands. |
| clickhouse.datetime.timezone | Override timezone for DateTime columns in ClickHouse server. |
| skip_replica_start | If set to true, replication is not started, the user is expected to start replication with the sink-connector-client program. |



## Kafka Sink Connector for ClickHouse

### Recommended Memory limits.
Expand Down
61 changes: 61 additions & 0 deletions doc/timezone.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Time Zone

### MySQL
1. The environment variable `TZ=US/Central` in docker-compose under mysql can be used to set the timezone for MySQL.

2. To make sure the timezone is properly set in MySQL, run the following SQL on MySQL Server.

`select @@system_time_zone`

3. Set the `database.connectionTimezone: 'US/Central'` in config.yml to make sure the sink connector performs the datetime/timestamp conversions using the same timezone.

Note: With the new version of Debezium there are no errors if the `database.connectionTimeZone` is not set and if the MySQL server is set to a different timezone
`TZ=US/Central`

### ClickHouse

To check the ClickHouse server timezone.
```
SELECT timezone()

Query id: f7b665b5-639f-4e1c-b494-256744c4310f

┌─timezone()──────┐
│ America/Chicago │
└─────────────────┘

```
The configuration variable `clickhouse.datetime.timezone: "UTC"` is to used to force the timezone for `DateTime/DateTime64` fields
when its persisted to ClickHouse. By Default the server timezone will be used.
```

SELECT toDateTime(Mid_Value, 'UTC') AS utc_time
FROM temporal_types_DATETIME5

Query id: f6c735bc-cdb3-4df6-995d-00dfe2d13ae8

┌────────────utc_time─┐
│ 2022-09-29 06:50:28 │
└─────────────────────┘

d1c194dbabc3 :) select toDateTime(Mid_Value, 'America/Chicago') as chicago_time from temporal_types_DATETIME5;

SELECT toDateTime(Mid_Value, 'America/Chicago') AS chicago_time
FROM temporal_types_DATETIME5

Query id: 77602998-f7f8-4bfb-b7a4-2a2034541c62

┌────────chicago_time─┐
│ 2022-09-29 01:50:28 │


SELECT *
FROM temporal_types_DATETIME5

Query id: c2f743df-f64e-4037-ad85-6363f9d7f11c

┌─Type────────┬─────────────Minimum_Value─┬─────────────────Mid_Value─┬─────────────Maximum_Value─┬─Null_Value─┬────────────_version─┬─is_deleted─┐
│ DATETIME(5) │ 1900-01-01 00:00:00.00000 │ 2022-09-29 01:50:28.12345 │ 2299-12-31 23:59:59.99999 │ ᴺᵁᴸᴸ │ 1730606158705590330 │ 0 │
└─────────────┴───────────────────────────┴───────────────────────────┴───────────────────────────┴────────────┴─────────────────────┴────────────┘

```
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<packaging>pom</packaging>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.debezium>2.4.0</version.debezium>
Expand Down
Binary file modified sink-connector-client/sink-connector-client
Binary file not shown.
2 changes: 1 addition & 1 deletion sink-connector-lightweight/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11
FROM openjdk:17
COPY sink-connector-client/sink-connector-client /sink-connector-client
COPY sink-connector-lightweight/target/clickhouse-debezium-embedded-*.jar /app.jar
ENV JAVA_OPTS="-Dlog4jDebug=true"
Expand Down
11 changes: 11 additions & 0 deletions sink-connector-lightweight/clickhouse/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<clickhouse replace="true">
<user_directories>
<users_xml>
<path>users.xml</path>
</users_xml>
<local_directory>
<path>/var/lib/clickhouse/access/</path>
</local_directory>
</user_directories>
<timezone>America/Chicago</timezone>
</clickhouse>
7 changes: 4 additions & 3 deletions sink-connector-lightweight/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.altinity</groupId>
<artifactId>clickhouse-debezium-embedded</artifactId>
<version>1.1-SNAPSHOT</version>
<version>0.0.4</version>
<build>
<extensions>
<extension>
Expand Down Expand Up @@ -293,11 +293,12 @@
<version.testcontainers>1.19.1</version.testcontainers>
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sink-connector-library-version>0.0.5</sink-connector-library-version>
<version.junit>5.9.1</version.junit>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.source>17</maven.compiler.source>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<version.checkstyle.plugin>3.1.1</version.checkstyle.plugin>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.target>17</maven.compiler.target>
<version.debezium>2.5.0.Alpha1</version.debezium>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
</properties>
Expand Down
3 changes: 3 additions & 0 deletions sink-connector-lightweight/docker/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ schema.history.internal.jdbc.schema.history.table.name: "altinity_sink_connector
enable.snapshot.ddl: "true"
persist.raw.bytes: "false"
auto.create.tables: "true"
#database.connectionTimeZone: "US/Samoa"
#clickhouse.datetime.timezone: "UTC"
skip_replica_start: "true"
3 changes: 3 additions & 0 deletions sink-connector-lightweight/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- MYSQL_REPLICATION_MODE=master
- MYSQL_REPLICATION_USER=repl_user
- ALLOW_EMPTY_PASSWORD=yes
- TZ=US/Central
volumes:
- ./mysqld.cnf:/opt/bitnami/mysql/conf/my_custom.cnf
- ../sql/init_mysql.sql:/docker-entrypoint-initdb.d/init_mysql.sql
Expand Down Expand Up @@ -47,6 +48,7 @@ services:
- MYSQL_MASTER_PORT_NUMBER=3306
- MYSQL_MASTER_ROOT_PASSWORD=root
- ALLOW_EMPTY_PASSWORD=yes
- TZ=America/Samoa
volumes:
- ./mysqld-slave.cnf:/opt/bitnami/mysql/conf/my_custom.cnf
healthcheck:
Expand Down Expand Up @@ -77,6 +79,7 @@ services:
hard: "262144"
volumes:
- ../clickhouse/users.xml:/etc/clickhouse-server/users.xml
- ../clickhouse/config.xml:/etc/clickhouse-server/config.d/config.xml
depends_on:
zookeeper:
condition: service_healthy
Expand Down
15 changes: 11 additions & 4 deletions sink-connector-lightweight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>0.0.4</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.debezium>2.5.0.Alpha1</version.debezium>
Expand All @@ -23,7 +23,7 @@
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>2.14.0.Final</quarkus.platform.version>
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<sink-connector-library-version>0.0.4</sink-connector-library-version>
<sink-connector-library-version>0.0.5</sink-connector-library-version>
</properties>
<dependencyManagement>
<dependencies>
Expand All @@ -44,9 +44,16 @@
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
<version>6.0.0</version>
</dependency>

<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>2.0.1</version>
</dependency>


<!-- REST API SERVER -->
<dependency>
<groupId>io.javalin</groupId>
Expand Down
Loading
Loading