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

🐛 Source CockroachDB: Fix cockroach Datatypes #7819

Merged
merged 10 commits into from
Nov 12, 2021

Conversation

alexandertsukanov
Copy link
Contributor

@alexandertsukanov alexandertsukanov commented Nov 10, 2021

What

SQLException appears in some cases during parsing of Cockroach DB datatypes. Fixed such cases.

How

Override methods from JdbcSourceOperations.java. Created custom CockroachJdbcSourceOperations.java class.

Recommended reading order

  1. x.java

Pre-merge Checklist

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and 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.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/SUMMARY.md
    • docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
    • docs/integrations/README.md
    • airbyte-integrations/builds.md
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the connector is published, connector added to connector index as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and 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.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Connector Generator

  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed.

@github-actions github-actions bot added the area/connectors Connector related issues label Nov 10, 2021
@jrhizor jrhizor temporarily deployed to more-secrets November 10, 2021 15:29 Inactive
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Nov 10, 2021
@alexandertsukanov alexandertsukanov temporarily deployed to more-secrets November 10, 2021 15:31 Inactive
@alexandertsukanov
Copy link
Contributor Author

alexandertsukanov commented Nov 11, 2021

/test connector=connectors/source-cockroachdb

🕑 connectors/source-cockroachdb https://github.com/airbytehq/airbyte/actions/runs/1447970172
✅ connectors/source-cockroachdb https://github.com/airbytehq/airbyte/actions/runs/1447970172
No Python unittests run

@alexandertsukanov alexandertsukanov temporarily deployed to more-secrets November 11, 2021 08:38 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets November 11, 2021 08:39 Inactive
Copy link
Contributor

@alexandr-shegeda alexandr-shegeda left a comment

Choose a reason for hiding this comment

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

LGTM

@alexandr-shegeda alexandr-shegeda marked this pull request as ready for review November 11, 2021 15:11
if ("numeric".equalsIgnoreCase(columnType)) {
final double value = resultSet.getDouble(index);
node.put(columnName, value);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be an else branch here? Otherwise the result may be ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added else statement and handling of SQLException as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know what types may go to the else branch or give a SQLException? Depending on what type it can be, defaulting to null may or may not be the best solution.

@@ -315,25 +302,21 @@ protected void initTests() {
.addExpectedValues("a", "abc", "Миші йдуть;", "櫻花分店", "", null, "\\xF0\\x9F\\x9A\\x80")
.build());

// TODO https://github.com/airbytehq/airbyte/issues/4408
// JdbcUtils-> DATE_FORMAT is set as ""yyyy-MM-dd'T'HH:mm:ss'Z'"" for both Date and Time types.
// So Time only (04:05:06) would be represented like "1970-01-01T04:05:06Z" which is incorrect
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is still relevant since the returned value still have 1970-01-01 in the full date string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Returned back the comment, regarding the DateTime format. However, all java source connectors will send full DateTime in JSON for now. As we need standardization for all related DateTime formats.
Please, see:

public static final String DATE_FORMAT_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";

So this behavior will be changed when we will sure all destination connectors are able to parse date and time formats.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Make sense.

.addNullExpectedValue()
.build());

// https://github.com/airbytehq/airbyte/issues/4408
// TODO JdbcUtils-> DATE_FORMAT is set as ""yyyy-MM-dd'T'HH:mm:ss'Z'"" for both Date and Time types.
// So Time only (04:05:06) would be represented like "1970-01-01T04:05:06Z" which is incorrect
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for this comment.

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 same is related to this one.

@alexandertsukanov alexandertsukanov temporarily deployed to more-secrets November 12, 2021 09:31 Inactive
@alexandertsukanov alexandertsukanov temporarily deployed to more-secrets November 12, 2021 09:33 Inactive
@alexandertsukanov
Copy link
Contributor Author

alexandertsukanov commented Nov 12, 2021

/test connector=connectors/source-cockroachdb

🕑 connectors/source-cockroachdb https://github.com/airbytehq/airbyte/actions/runs/1452544817
✅ connectors/source-cockroachdb https://github.com/airbytehq/airbyte/actions/runs/1452544817
No Python unittests run

@jrhizor jrhizor temporarily deployed to more-secrets November 12, 2021 09:56 Inactive
@alexandertsukanov
Copy link
Contributor Author

alexandertsukanov commented Nov 12, 2021

/publish connector=connectors/source-cockroachdb

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

@jrhizor jrhizor temporarily deployed to more-secrets November 12, 2021 10:09 Inactive
@alexandertsukanov alexandertsukanov merged commit b295868 into master Nov 12, 2021
@alexandertsukanov alexandertsukanov deleted the otsukanov/4408_fix_cockroach_datatypes branch November 12, 2021 10:19
@alexandertsukanov alexandertsukanov temporarily deployed to more-secrets November 12, 2021 10:20 Inactive
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
* BUG-4408: Fix cockroach connectors.

* BUG-4408: Handling of spacial DB datatype for Cockroach DB.

* BUG-4408: Documentation updates.

* BUG-4408: Fix unit test.

* BUG-4408: Fixed comments.

* BUG-4408: Reformat.

* BUG-4408: Bumped spec.
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.

Source CockroachDB: Connector provides wrong values for some datatypes
5 participants