Skip to content

Commit

Permalink
Add string mapper case for IT (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
Deep1998 authored and dhercher committed Jul 30, 2024
1 parent cec8533 commit 89cee54
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ public class SourceDbToSpannerSimpleIT extends SourceDbToSpannerITBase {

private static final String SPANNER_DDL_RESOURCE = "SourceDbToSpannerSimpleIT/spanner-schema.sql";

private static final String TABLE = "SimpleTable";
private static final String TABLE1 = "SimpleTable";

private static final String TABLE2 = "StringTable";

private static final String ID = "id";

private static final String NAME = "name";

private JDBCResourceManager.JDBCSchema getMySQLSchema() {
private JDBCResourceManager.JDBCSchema getMySQLSchema(String idCol) {
HashMap<String, String> columns = new HashMap<>();
columns.put(ID, "INTEGER NOT NULL");
columns.put(NAME, "VARCHAR(200)");
return new JDBCResourceManager.JDBCSchema(columns, ID);
return new JDBCResourceManager.JDBCSchema(columns, idCol);
}

private List<Map<String, Object>> getMySQLData() {
Expand Down Expand Up @@ -101,8 +103,10 @@ public void cleanUp() {
@Test
public void simpleTest() throws IOException {
List<Map<String, Object>> mySQLData = getMySQLData();
mySQLResourceManager.createTable(TABLE, getMySQLSchema());
mySQLResourceManager.write(TABLE, mySQLData);
mySQLResourceManager.createTable(TABLE1, getMySQLSchema(ID));
mySQLResourceManager.createTable(TABLE2, getMySQLSchema(NAME));
mySQLResourceManager.write(TABLE1, mySQLData);
mySQLResourceManager.write(TABLE2, mySQLData);
createSpannerDDL(spannerResourceManager, SPANNER_DDL_RESOURCE);
jobInfo =
launchDataflowJob(
Expand All @@ -115,7 +119,9 @@ public void simpleTest() throws IOException {
null);
PipelineOperator.Result result = pipelineOperator().waitUntilDone(createConfig(jobInfo));
assertThatResult(result).isLaunchFinished();
SpannerAsserts.assertThatStructs(spannerResourceManager.readTableRecords(TABLE, ID, NAME))
SpannerAsserts.assertThatStructs(spannerResourceManager.readTableRecords(TABLE1, ID, NAME))
.hasRecordsUnorderedCaseInsensitiveColumns(mySQLData);
SpannerAsserts.assertThatStructs(spannerResourceManager.readTableRecords(TABLE2, ID, NAME))
.hasRecordsUnorderedCaseInsensitiveColumns(mySQLData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ CREATE TABLE IF NOT EXISTS SimpleTable (
id INT64 NOT NULL,
name STRING(200),
) PRIMARY KEY(id);

CREATE TABLE IF NOT EXISTS StringTable (
id INT64 NOT NULL,
name STRING(200),
) PRIMARY KEY(name);

0 comments on commit 89cee54

Please sign in to comment.