Skip to content

Commit

Permalink
Support Postgres partitioned table; confluentinc/kafka-connect-jdbc#1092
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim te Beek committed Jan 19, 2022
1 parent 348e49f commit 7e6e26a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ target/
.idea/
.ipr

# Eclipse IDE
.project
.classpath
.checkstyle
.settings/

# Documentation build output
/docs/_build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,9 @@ public enum PrimaryKeyMode {
private static final String TABLE_TYPES_DOC =
"The comma-separated types of database tables to which the sink connector can write. "
+ "By default this is ``" + TableType.TABLE + "``, but any combination of ``"
+ TableType.TABLE + "`` and ``" + TableType.VIEW + "`` is allowed. Not all databases "
+ "support writing to views, and when they do the the sink connector will fail if the "
+ TableType.TABLE + "``, ``" + TableType.PARTITIONED_TABLE + "`` and ``"
+ TableType.VIEW + "`` is allowed. Not all databases support writing to views, "
+ "and when they do the sink connector will fail if the "
+ "view definition does not match the records' schemas (regardless of ``"
+ AUTO_EVOLVE + "``).";

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/confluent/connect/jdbc/util/TableType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

public enum TableType {

TABLE("TABLE", "Table"), VIEW("VIEW", "View");
TABLE("TABLE", "Table"),
PARTITIONED_TABLE("PARTITIONED TABLE", "Partitioned Table"),
VIEW("VIEW", "View");

private final String value;
private final String capitalCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ public void shouldCreateConfigWithTableOnly() {
assertTableTypes(TableType.TABLE);
}

@Test
public void shouldCreateConfigWithPartitionedTableOnly() {
props.put("table.types", "partitioned table");
createConfig();
assertTableTypes(TableType.PARTITIONED_TABLE);
}

@Test
public void shouldCreateConfigWithViewAndTable() {
props.put("table.types", "view,table");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class TableTypeTest {

private static EnumSet<TableType> TABLE_ONLY = types(TableType.TABLE);
private static EnumSet<TableType> PARTITIONED_TABLE_ONLY = types(TableType.PARTITIONED_TABLE);
private static EnumSet<TableType> VIEW_ONLY = types(TableType.VIEW);
private static EnumSet<TableType> TABLE_AND_VIEW = types(TableType.TABLE, TableType.VIEW);

Expand Down Expand Up @@ -56,6 +57,7 @@ public void shouldParseTypeStringWithWhitespace() {
public void shouldComputeJdbcTypeArray() {
assertArrayEquals(array("TABLE"), TableType.asJdbcTableTypeArray(TABLE_ONLY));
assertArrayEquals(array("VIEW"), TableType.asJdbcTableTypeArray(VIEW_ONLY));
assertArrayEquals(array("PARTITIONED TABLE"), TableType.asJdbcTableTypeArray(PARTITIONED_TABLE_ONLY));
assertArrayEquals(array("TABLE", "VIEW"), TableType.asJdbcTableTypeArray(TABLE_AND_VIEW));
}

Expand Down

0 comments on commit 7e6e26a

Please sign in to comment.