-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎉 Abstract level for SQL relational database sources #4123
Conversation
4bd5c6b
to
214da08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do minor fixes and move it forward
@@ -126,10 +126,10 @@ protected void setupEnvironment(TestDestinationEnv environment) throws Exception | |||
config.get("database").asText()), | |||
ClickHouseSource.DRIVER_CLASS); | |||
|
|||
final String table1 = JdbcUtils.getFullyQualifiedTableName(SCHEMA_NAME, STREAM_NAME); | |||
final String table1 = JdbcSourceUtils.getFullyQualifiedTableName(SCHEMA_NAME, STREAM_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JdbcSourceUtils -> SourceJdbcUtils
@@ -38,7 +36,7 @@ dependencies { | |||
testFixturesImplementation project(':airbyte-protocol:models') | |||
testFixturesImplementation project(':airbyte-db') | |||
testFixturesImplementation project(':airbyte-integrations:bases:base-java') | |||
testFixturesImplementation project(':airbyte-integrations:connectors:source-jdbc') | |||
// testFixturesImplementation project(':airbyte-integrations:connectors:source-jdbc') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
throw new RuntimeException(e); | ||
@Override | ||
protected Map<String, List<String>> discoverPrimaryKeys(JdbcDatabase database, | ||
List<TableInfo<CommonField<JDBCType>>> tableInfos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add some info logging
s not an abstract class. + add default implementation for `AbstractRelationalDbSource.getFullyQualifiedTableName`
98c4f5e
to
18e86d8
Compare
Reviewing this |
…act-source # Conflicts: # airbyte-integrations/connectors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlSource.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts
- I am not sure around the usage of interfaces vs abstract classes. I think we can have
- I dont understand the differentiation between AbstractRelationalDbSource and AbstractJdbcSource.
Can you run the integration tests for all the sources that this change is impacting
import java.sql.SQLException; | ||
import java.util.stream.Stream; | ||
|
||
public abstract class SqlDatabase implements AutoCloseable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this an abstract class? Why not an interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a result of the decision to use setters for configs and private variables.
|
||
public abstract class SqlDatabase implements AutoCloseable { | ||
|
||
private JsonNode sourceConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sourceConfig
and databaseConfig
should be final plus should be initialised in a constructor and not via setter methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I used setter instead of the obvious constructor here - it's massive signature changes in the existing classes.
I agree that it's technical depth and should be improved in the future. But I decided that it will be too much for this change.
What do you think about a new issue for that?
@@ -36,21 +39,22 @@ | |||
/** | |||
* Database object for interacting with a JDBC connection. | |||
*/ | |||
public interface JdbcDatabase extends AutoCloseable { | |||
public abstract class JdbcDatabase extends SqlDatabase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change to an abstract class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The superclass SqlDatabase
is an abstract class. If we decide to have an abstract class there, we can't use the interface here.
/test connector=source-oracle
|
/test connector=destination-snowflake
|
/test connector=source-oracle
|
/test connector=source-cockroachdb
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve but I still think that using setters for
private JsonNode sourceConfig;
private JsonNode databaseConfig;
in SqlDatabase
is not a good idea. They should be final and initialised in constructors.
Please make sure to test this thoroughly before merging/deploying.
/test connector=source-oracle
|
/test connector=source-clickhouse
|
/test connector=source-postgres
|
/test connector=source-jdbc
|
/test connector=source-mysql
|
/test connector=source-db2
|
/test connector=source-mssql
|
/test connector=source-redshift
|
This error is in the master state. Reproduced at master: |
The corresponding ticket is created #4547. I will take this ticket into the work after the BigQuery source. |
What
Provide a common abstract class for non-JDBC source implementation.
How
Move all non-JDBC-specific stuff to a superclass.
Recommended reading order
AbstractRelationalDbSource.java
AbstractJdbcSource.java
Pre-merge Checklist
Expand the checklist which is relevant for this PR.
Connector checklist
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
./test connector=connectors/<name>
command as documented here is passing.