Skip to content
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

Merged
merged 24 commits into from
Jul 5, 2021

Conversation

DoNotPanicUA
Copy link
Contributor

@DoNotPanicUA DoNotPanicUA commented Jun 15, 2021

What

Provide a common abstract class for non-JDBC source implementation.

How

Move all non-JDBC-specific stuff to a superclass.

Recommended reading order

  1. AbstractRelationalDbSource.java
  2. AbstractJdbcSource.java
  3. Others

Pre-merge Checklist

Expand the checklist which is relevant for this PR.

Connector checklist

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • Unit & integration tests added as appropriate (and are passing)
    • Community members: please provide proof of this succeeding locally e.g: screenshot or copy-paste acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • /test connector=connectors/<name> command as documented here is passing.
    • Community members can skip this, Airbyters will run this for you.
  • Code reviews completed
  • Credentials added to Github CI if needed and not already present. instructions for injecting secrets into CI.
  • Build is successful
  • No major blockers
  • PR merged into master branch
  • Follow up tickets have been created
  • Associated tickets have been closed & stakeholders notified

@github-actions github-actions bot added area/connectors Connector related issues area/protocol labels Jun 15, 2021
@DoNotPanicUA DoNotPanicUA force-pushed the aleonets/4024-abstract-source branch from 4bd5c6b to 214da08 Compare June 15, 2021 14:55
@DoNotPanicUA DoNotPanicUA linked an issue Jun 17, 2021 that may be closed by this pull request
@DoNotPanicUA DoNotPanicUA changed the title Aleonets/4024 abstract source 🎉 Abstract level for SQL relational database sources Jun 17, 2021
Copy link
Contributor

@yaroslav-hrytsaienko yaroslav-hrytsaienko left a 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);
Copy link
Contributor

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')
Copy link
Contributor

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) {
Copy link
Contributor

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

@DoNotPanicUA DoNotPanicUA force-pushed the aleonets/4024-abstract-source branch from 98c4f5e to 18e86d8 Compare June 22, 2021 19:17
@DoNotPanicUA DoNotPanicUA marked this pull request as ready for review June 22, 2021 21:00
@subodh1810
Copy link
Contributor

Reviewing this

…act-source

# Conflicts:
#	airbyte-integrations/connectors/source-mysql/src/main/java/io/airbyte/integrations/source/mysql/MySqlSource.java
Copy link
Contributor

@subodh1810 subodh1810 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thoughts

  1. I am not sure around the usage of interfaces vs abstract classes. I think we can have
  2. 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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jun 30, 2021

/test connector=source-oracle

🕑 source-oracle https://github.com/airbytehq/airbyte/actions/runs/986980860
❌ source-oracle https://github.com/airbytehq/airbyte/actions/runs/986980860

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jun 30, 2021

/test connector=destination-snowflake

🕑 destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/986981345
❌ destination-snowflake https://github.com/airbytehq/airbyte/actions/runs/986981345

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jun 30, 2021

/test connector=source-oracle

🕑 source-oracle https://github.com/airbytehq/airbyte/actions/runs/988040712
✅ source-oracle https://github.com/airbytehq/airbyte/actions/runs/988040712

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 2, 2021

/test connector=source-cockroachdb

🕑 source-cockroachdb https://github.com/airbytehq/airbyte/actions/runs/994041119
✅ source-cockroachdb https://github.com/airbytehq/airbyte/actions/runs/994041119

Copy link
Contributor

@subodh1810 subodh1810 left a 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.

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-oracle

🕑 source-oracle https://github.com/airbytehq/airbyte/actions/runs/1001067971
✅ source-oracle https://github.com/airbytehq/airbyte/actions/runs/1001067971

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-clickhouse

🕑 source-clickhouse https://github.com/airbytehq/airbyte/actions/runs/1001070441
✅ source-clickhouse https://github.com/airbytehq/airbyte/actions/runs/1001070441

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-postgres

🕑 source-postgres https://github.com/airbytehq/airbyte/actions/runs/1001071413
✅ source-postgres https://github.com/airbytehq/airbyte/actions/runs/1001071413

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-jdbc

🕑 source-jdbc https://github.com/airbytehq/airbyte/actions/runs/1001072023
✅ source-jdbc https://github.com/airbytehq/airbyte/actions/runs/1001072023

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-mysql

🕑 source-mysql https://github.com/airbytehq/airbyte/actions/runs/1001072486
✅ source-mysql https://github.com/airbytehq/airbyte/actions/runs/1001072486

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-db2

🕑 source-db2 https://github.com/airbytehq/airbyte/actions/runs/1001085196
✅ source-db2 https://github.com/airbytehq/airbyte/actions/runs/1001085196

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-mssql

🕑 source-mssql https://github.com/airbytehq/airbyte/actions/runs/1001085792
❌ source-mssql https://github.com/airbytehq/airbyte/actions/runs/1001085792

@DoNotPanicUA
Copy link
Contributor Author

DoNotPanicUA commented Jul 5, 2021

/test connector=source-redshift

🕑 source-redshift https://github.com/airbytehq/airbyte/actions/runs/1001089267
❌ source-redshift https://github.com/airbytehq/airbyte/actions/runs/1001089267

@DoNotPanicUA
Copy link
Contributor Author

/test connector=source-mssql

clock2 source-mssql https://github.com/airbytehq/airbyte/actions/runs/1001085792
x source-mssql https://github.com/airbytehq/airbyte/actions/runs/1001085792

This error is in the master state. Reproduced at master:
https://github.com/airbytehq/airbyte/actions/runs/1001189702

@DoNotPanicUA
Copy link
Contributor Author

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.

The corresponding ticket is created #4547. I will take this ticket into the work after the BigQuery source.

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

Successfully merging this pull request may close these issues.

🎉 New level of abstraction for relational database sources
4 participants