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

SAT: check records to comply jsonschema format field #5661

Merged
merged 4 commits into from
Sep 1, 2021

Conversation

avida
Copy link
Contributor

@avida avida commented Aug 26, 2021

What

Resolves #5477 issue

How

Describe the solution

Recommended reading order

  1. x.java
  2. y.python

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
    • 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
  • Connector added to connector index like described here

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

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
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions
  • Connector version bumped like described here

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

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.

@avida avida force-pushed the drezchykov/5477-SAT-check-records-format branch from 220ff9a to 4d01696 Compare August 26, 2021 09:18
Copy link
Contributor

@Zirochkaa Zirochkaa left a comment

Choose a reason for hiding this comment

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

lgtm

@pytest.mark.parametrize(
"record, configured_catalog, valid",
[
# time
Copy link
Contributor

Choose a reason for hiding this comment

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

You have tests only for time and date-time. What about date? Could you please add tests for date format also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -38,7 +38,7 @@ def verify_records_schema(
"""
validators = {}
for stream in catalog.streams:
validators[stream.stream.name] = Draft4Validator(stream.stream.json_schema)
validators[stream.stream.name] = Draft7Validator(stream.stream.json_schema, format_checker=FormatChecker())
Copy link
Member

Choose a reason for hiding this comment

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

For sanity check: what happens you send null data to format_checker?

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 would generate an error, added this case to unittests.

@avida avida requested a review from sherifnada August 27, 2021 12:45
@avida avida requested a review from marcosmarxm August 27, 2021 16:01
@sherifnada sherifnada requested a review from Phlair August 27, 2021 18:00
@sherifnada
Copy link
Contributor

@Phlair adding you as a reviewer since it's a CDK related

@sherifnada sherifnada removed their request for review August 27, 2021 23:19
Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

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

lgtm, left one comment with Q and suggestion on adding detail to docs

Comment on lines +34 to +38
timestamp_regex = re.compile(("^\d{4}-\d?\d-\d?\d" # date
"(\s|T)" # separator
"\d?\d:\d?\d:\d?\d(.\d+)?" # time
".*$" #timezone
))
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a standard (e.g. ISO 8601) that this regex is based on?

Whether based on a standard or custom, it would be useful to add a description in the docs (somewhere on this page perhaps) so that date/time format requirements of a connector are clear when building one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, its based on bigquery timestamp format (https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type) as its most strict of sql timestamp formats we are supporting

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, so we're lining it up to our most strict destination to ensure compatibility. Makes sense. Small piece in creating connector docs explaining that (with some examples) would be great.

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Sep 1, 2021
@avida avida merged commit 4717257 into master Sep 1, 2021
@avida avida deleted the drezchykov/5477-SAT-check-records-format branch September 1, 2021 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SAT: verify that records conform to format: date-time, format: date, and format:time are validated
6 participants