Skip to content

Commit

Permalink
Merge pull request #851 from Altinity/847-add-integration-test-to-inc…
Browse files Browse the repository at this point in the history
…lude-point-data-type-in-mysql

Added Integration test for testing POINT data type in MySQL
  • Loading branch information
subkanthi authored Oct 2, 2024
2 parents 837b765 + ea42f39 commit a4abaa9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.altinity.clickhouse.debezium.embedded.ddl.parser;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Constants {

public static final String ALIAS = "MATERIALIZED";
Expand Down Expand Up @@ -53,5 +57,10 @@ public class Constants {
public static final String NEW_REPLACING_MERGE_TREE_VERSION = "23.2";


// There are certain Data types where Nullable is not supported.
// For example, Point, Geometry, Enum, Array, Map, Decimal, UUID, DateTime64, Date, Time, DateTime, Nullable(DateTime), Nullable(Date), Nullable(Time), Nullable(DateTime64), Nullable(UUID)
// Create a set of these data types.
public static final Set<String> NULLABLE_NOT_SUPPORTED_DATA_TYPES = new HashSet<>(Arrays.asList("point"));


}
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ private void parseColumnDefinitions(ParseTree subtree, StringBuilder orderByColu
continue;
}

if(isNullColumn) {
// Nullable should not be added for POINT data type
String lowerCaseDataType = colDataType.toLowerCase();
if(!Constants.NULLABLE_NOT_SUPPORTED_DATA_TYPES.contains(lowerCaseDataType) && isNullColumn) {
this.query.append(Constants.NULLABLE).append("(").append(colDataType)
.append(")").append(",");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public void stopContainers() {
@CsvSource({
"clickhouse/clickhouse-server:latest"
})
@DisplayName("Test that validates that the offset table is created and records are inserted into it.")
public void testAutoCreateTable(String clickHouseServerVersion) throws Exception {
@DisplayName("Test that validates that the REST API is working.")
public void testRESTAPI(String clickHouseServerVersion) throws Exception {

Thread.sleep(5000);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.altinity.clickhouse.debezium.embedded.ddl.parser;

import com.altinity.clickhouse.debezium.embedded.ITCommon;
import com.altinity.clickhouse.debezium.embedded.cdc.DebeziumChangeEventCapture;
import com.altinity.clickhouse.debezium.embedded.parser.SourceRecordParserService;
import com.altinity.clickhouse.sink.connector.ClickHouseSinkConnectorConfig;
Expand All @@ -25,7 +26,8 @@
import java.util.concurrent.atomic.AtomicReference;

@Testcontainers
@DisplayName("Integration test that tests replication of data types and validates datetime, date limits with no timezone values set on CH and MySQL")
@DisplayName("Integration test that tests replication of data types and validates datetime," +
" date limits with no timezone values and MySQL Point Data typek set on CH and MySQL")
public class CreateTableDataTypesIT extends DDLBaseIT {

@BeforeEach
Expand Down Expand Up @@ -262,6 +264,34 @@ public void testCreateTable() throws Exception {
break;
}

// validate POINT data type
// Create a new table with POINT data type
// Crate a new table on MySQL with POINT data type
String createTableWithPoint = "CREATE TABLE employees.point_table (id int not null PRIMARY KEY, c1 int, c2 int, c3a POINT, c3b POINT, f1 float(10), f2 decimal(8,4))";
ITCommon.connectToMySQL(mySqlContainer).createStatement().execute(createTableWithPoint);

// Sleep for 10 seconds to allow the table to be replicated
Thread.sleep(10000);

// Insert a new row into the table
ITCommon.connectToMySQL(mySqlContainer).createStatement().execute("INSERT INTO employees.point_table (id, c1, c2, c3a, c3b, f1, f2) values (1, 123, 456, POINT(1.0,2.0), POINT(3.0,4.0), 100.20, 100.20)");

Thread.sleep(10000);
ResultSet rs = writer.executeQueryWithResultSet("select * from employees.point_table");
boolean pointResultValidated = false;
while(rs.next()) {
pointResultValidated = true;
String c3a = rs.getString("c3a");
String c3b = rs.getString("c3b");
Assert.assertTrue(c3a.equalsIgnoreCase("(1.0,2.0)"));
Assert.assertTrue(c3b.equalsIgnoreCase("(3.0,4.0)"));
}
Assert.assertTrue(pointResultValidated);



Thread.sleep(5000);

if(engine.get() != null) {
engine.get().stop();
}
Expand Down

0 comments on commit a4abaa9

Please sign in to comment.