diff --git a/README.md b/README.md index 332be14..323ef72 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ gradle jar 3. Run the Jar ``` -java -jar build/libs/singlestore-fivetran-connector-0.0.2.jar +java -jar build/libs/singlestore-fivetran-connector-0.0.3.jar ``` ## Steps for running Java tests @@ -108,7 +108,7 @@ CREATE TABLE t(a INT PRIMARY KEY, b INT); wget -O src/main/proto/common.proto https://raw.githubusercontent.com/fivetran/fivetran_sdk/production/common.proto wget -O src/main/proto/connector_sdk.proto https://raw.githubusercontent.com/fivetran/fivetran_sdk/production/connector_sdk.proto gradle jar -java -jar build/libs/singlestore-fivetran-connector-0.0.2.jar +java -jar build/libs/singlestore-fivetran-connector-0.0.3.jar ``` 6. Update the `./tester/configuration.json` file with your credentials diff --git a/build.gradle b/build.gradle index 8f96fa8..75396a2 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ repositories { mavenCentral() } -version = '0.0.2' +version = '0.0.3' sourceCompatibility = 1.8 targetCompatibility = 1.8 diff --git a/src/main/java/com/singlestore/fivetran/connector/SingleStoreConnection.java b/src/main/java/com/singlestore/fivetran/connector/SingleStoreConnection.java index b326499..6871ac5 100644 --- a/src/main/java/com/singlestore/fivetran/connector/SingleStoreConnection.java +++ b/src/main/java/com/singlestore/fivetran/connector/SingleStoreConnection.java @@ -160,6 +160,15 @@ public SchemaList getSchema() throws Exception { } } + // If table doesn't have PK - add an internal id instead + if (primaryKeyColumns.isEmpty()) { + Column.Builder internalId = Column.newBuilder() + .setName("InternalId") + .setType(DataType.BINARY) + .setPrimaryKey(true); + columns.add(internalId.build()); + } + return SchemaList.newBuilder() .addSchemas( Schema.newBuilder() diff --git a/src/test/java/com/singlestore/fivetran/connector/SingleStoreConnectionTest.java b/src/test/java/com/singlestore/fivetran/connector/SingleStoreConnectionTest.java index a70d842..4249e94 100644 --- a/src/test/java/com/singlestore/fivetran/connector/SingleStoreConnectionTest.java +++ b/src/test/java/com/singlestore/fivetran/connector/SingleStoreConnectionTest.java @@ -1,5 +1,11 @@ package com.singlestore.fivetran.connector; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.google.common.collect.ImmutableMap; import com.google.protobuf.ByteString; import com.google.protobuf.Timestamp; import fivetran_sdk.Column; @@ -11,12 +17,6 @@ import fivetran_sdk.ValueType; import java.sql.SQLException; import java.sql.Statement; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -27,8 +27,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableMap; - public class SingleStoreConnectionTest extends IntegrationTestBase { @Test @@ -150,7 +148,7 @@ public void getSchema() throws Exception { assertEquals("getSchema", table.getName()); List columns = table.getColumnsList(); - assertEquals(44, columns.size()); + assertEquals(45, columns.size()); List columnNames = Arrays.asList( "boolColumn", @@ -196,7 +194,8 @@ public void getSchema() throws Exception { "geographyColumn", "geographypointColumn", "vectorColumn", - "bsonColumn" + "bsonColumn", + "InternalId" ); List decimalParameters = Arrays.asList( @@ -255,6 +254,7 @@ public void getSchema() throws Exception { DecimalParams.newBuilder().build(), DecimalParams.newBuilder().build(), DecimalParams.newBuilder().build(), + DecimalParams.newBuilder().build(), DecimalParams.newBuilder().build() ); @@ -302,6 +302,7 @@ public void getSchema() throws Exception { DataType.STRING, DataType.STRING, DataType.BINARY, + DataType.BINARY, DataType.BINARY ); @@ -310,7 +311,7 @@ public void getSchema() throws Exception { assertEquals(columnNames.get(i), column.getName()); assertEquals(decimalParameters.get(i), column.getDecimal()); assertEquals(types.get(i), column.getType()); - assertFalse(column.getPrimaryKey()); + assertEquals(column.getName().equals("InternalId"), column.getPrimaryKey()); } } @@ -868,7 +869,7 @@ public void observeVectorJson() throws Exception { assertEquals("observeVectorJson", table.getName()); List columns = table.getColumnsList(); - assertEquals(1, columns.size()); + assertEquals(2, columns.size()); Column column = columns.get(0); assertEquals("a", column.getName());