Skip to content

Conversation

@darkmatter18
Copy link
Contributor

Fix

fixes #142

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Description

The Pull request fixes the connector issue, which doesn't support primary key-only tables.

In Cassandra, if there is any table with only primary key columns,

Ex,

CREATE TABLE source.results (
    uuid           text,
    value          int,
	PRIMARY KEY ((uuid, value))
)
WITH cdc = TRUE;

then the connector throws an error because of an error in the SQL select statement formation.

java.util.concurrent.CompletionException: com.datastax.oss.driver.api.core.servererrors.SyntaxError: line 1:7 no viable alternative at input 'FROM' (SELECT [FROM]...)
	at java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:412) ~[?:?]
	at java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2044) ~[?:?]
	at com.datastax.oss.pulsar.source.CassandraSource.batchRead(CassandraSource.java:574) ~[?:?]
	at com.datastax.oss.pulsar.source.CassandraSource.maybeBatchRead(CassandraSource.java:463) ~[?:?]
	at com.datastax.oss.pulsar.source.CassandraSource.read(CassandraSource.java:455) ~[?:?]

Considerations

There is confusion on the issue (#142) about what to push into the data topic when it's only a primary key table, and how to differentiate between a delete query and primary key-only table inserts.

To differentiate between the above-mentioned scenarios, we decided to send all the columns' data into the value field (including primary key columns) for insert and update for a primary key-only table.

The delete query data for all types of tables, including primary key-only tables, will have the value as null for AVRO and {} for JSON, as before.

What's added/changed

  • Database query statement is being resolved, which in turn fixes the above-mentioned issue.
  • Added the pk columns on the value schema in case of a primary key-only table.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.

…ment` to use primary key columns when the projection is empty. Improve Javadoc comments.
…alue converter logic and refine Javadoc comments
@darkmatter18
Copy link
Contributor Author

Closing this PR as #199 has the same implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[connector] CDC doesn't support primary key only tables

2 participants