Skip to content

πŸ› Source S3: fix datetime format string in FileStream - #23195

Merged
Evan Tahler (evantahler) merged 12 commits into
airbytehq:masterfrom
olivermeyer:fix-filestream-datetime-format-string
Mar 16, 2023
Merged

πŸ› Source S3: fix datetime format string in FileStream#23195
Evan Tahler (evantahler) merged 12 commits into
airbytehq:masterfrom
olivermeyer:fix-filestream-datetime-format-string

Conversation

@olivermeyer

@olivermeyer Oliver Meyer (olivermeyer) commented Feb 17, 2023

Copy link
Copy Markdown
Contributor

What

Fixes #22919

The FileStream has a datetime_format_string attribute which is used to format the cursor field (here). At some point during the sync, Airbyte seems to validate the format of this field, resulting in errors such as this:

errors: $: does not match the regex pattern ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+\-]\d{1,2}:\d{2})( BC)?$
2023-02-17 10:16:14 INFO i.a.v.j.JsonSchemaValidator(test):130 - JSON schema validation failed. 

The FileStream returns a datetime string formatted as 1970-01-01T00:00+0000, whereas the validation expects a string formatted as 1970-01-01T00:00Z.

How

Fix the datetime format string.

Pre-merge Checklist

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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here

@olivermeyer

Copy link
Copy Markdown
Contributor Author

Attaching the output of pytest unit_tests. The integration tests are failing because of Minio timeouts, perhaps they need to run somewhere else.
s3_unit_tests.txt

@natalyjazzviolin

This comment was marked as outdated.

@natalyjazzviolin

Nataly Merezhuk (natalyjazzviolin) commented Feb 27, 2023

Copy link
Copy Markdown
Contributor

/test connector=connectors/source-s3

πŸ•‘ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4283558051
❌ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4283558051
πŸ› https://gradle.com/s/7twltt2exnltu

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_core.py::TestBasicRead::test_read[inputs0] - Failed: Stream test:...
FAILED test_core.py::TestBasicRead::test_read[inputs1] - Failed: Stream test:...
FAILED test_core.py::TestBasicRead::test_read[inputs2] - Failed: Stream test:...
FAILED test_core.py::TestBasicRead::test_read[inputs3] - Failed: Stream test:...
FAILED test_core.py::TestBasicRead::test_read[inputs4] - Failed: Stream test:...
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs0]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs1]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs2]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs3]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs4]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs0]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs1]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs2]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs3]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs4]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs0]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs1]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs2]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs3]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs4]
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:98: The previous and actual specifications are identical.
SKIPPED [5] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:507: The previous and actual discovered catalogs are identical.
============= 20 failed, 75 passed, 6 skipped in 191.85s (0:03:11) =============

@olivermeyer

Copy link
Copy Markdown
Contributor Author

Nataly Merezhuk (@natalyjazzviolin) could you give this another run? I updated the integration tests.

@olivermeyer

Copy link
Copy Markdown
Contributor Author

Hi Nataly Merezhuk (@natalyjazzviolin), pinging you again as we're still seeing issues because of this. Do let me know if there's anything more I can do to get this merged.

@sh4sh

sunny (sh4sh) commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

/test connector=connectors/source-s3

πŸ•‘ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4358036985
❌ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4358036985
πŸ› https://gradle.com/s/n5qgumhhrvty4

Build Failed

Test summary info:

=========================== short test summary info ============================
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs0]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs1]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs2]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs3]
FAILED test_incremental.py::TestIncremental::test_two_sequential_reads[inputs4]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs0]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs1]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs2]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs3]
FAILED test_incremental.py::TestIncremental::test_read_sequential_slices[inputs4]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs0]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs1]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs2]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs3]
FAILED test_incremental.py::TestIncremental::test_state_with_abnormally_large_values[inputs4]
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:100: The previous and actual specifications are identical.
SKIPPED [5] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:509: The previous and actual discovered catalogs are identical.
============= 15 failed, 80 passed, 6 skipped in 190.94s (0:03:10) =============

@olivermeyer

Copy link
Copy Markdown
Contributor Author

The latest commit should fix the issue of comparing timezone-aware datetime objects with unaware objects. Attaching unit test logs for this commit.
unittests.log

@evantahler

Evan Tahler (evantahler) commented Mar 11, 2023

Copy link
Copy Markdown
Contributor

/test connector=connectors/source-s3

πŸ•‘ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4393762795
βœ… connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4393762795
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
source_s3/source_files_abstract/storagefile.py                       23      0   100%
source_s3/source_files_abstract/spec.py                              55      0   100%
source_s3/source_files_abstract/formats/parquet_spec.py               9      0   100%
source_s3/source_files_abstract/formats/jsonl_spec.py                13      0   100%
source_s3/source_files_abstract/formats/csv_spec.py                  16      0   100%
source_s3/source_files_abstract/formats/avro_spec.py                  5      0   100%
source_s3/source.py                                                  27      0   100%
source_s3/exceptions.py                                              10      0   100%
source_s3/__init__.py                                                 2      0   100%
source_s3/source_files_abstract/formats/parquet_parser.py            64      2    97%
source_s3/source_files_abstract/formats/abstract_file_parser.py      41      2    95%
source_s3/stream.py                                                  43      3    93%
source_s3/s3file.py                                                  41      3    93%
source_s3/source_files_abstract/formats/avro_parser.py               39      3    92%
source_s3/source_files_abstract/file_info.py                         26      2    92%
source_s3/source_files_abstract/formats/jsonl_parser.py              53      5    91%
source_s3/source_files_abstract/source.py                            39      5    87%
source_s3/source_files_abstract/stream.py                           264     45    83%
source_s3/source_files_abstract/formats/csv_parser.py               127     22    83%
source_s3/s3_utils.py                                                20      4    80%
source_s3/utils.py                                                   31     10    68%
-------------------------------------------------------------------------------------
TOTAL                                                               948    106    89%
Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
source_s3/source_files_abstract/formats/parquet_spec.py               9      0   100%
source_s3/source_files_abstract/formats/jsonl_spec.py                13      0   100%
source_s3/source_files_abstract/formats/csv_spec.py                  16      0   100%
source_s3/source_files_abstract/formats/avro_spec.py                  5      0   100%
source_s3/s3_utils.py                                                20      0   100%
source_s3/__init__.py                                                 2      0   100%
source_s3/source_files_abstract/storagefile.py                       23      1    96%
source_s3/stream.py                                                  43      3    93%
source_s3/source_files_abstract/stream.py                           264     19    93%
source_s3/s3file.py                                                  41      3    93%
source_s3/source_files_abstract/formats/abstract_file_parser.py      41      4    90%
source_s3/source.py                                                  27      4    85%
source_s3/source_files_abstract/file_info.py                         26      7    73%
source_s3/utils.py                                                   31     10    68%
source_s3/source_files_abstract/formats/csv_parser.py               127     46    64%
source_s3/exceptions.py                                              10      4    60%
source_s3/source_files_abstract/source.py                            39     16    59%
source_s3/source_files_abstract/spec.py                              55     31    44%
source_s3/source_files_abstract/formats/jsonl_parser.py              53     32    40%
source_s3/source_files_abstract/formats/avro_parser.py               39     25    36%
source_s3/source_files_abstract/formats/parquet_parser.py            64     44    31%
-------------------------------------------------------------------------------------
TOTAL                                                               948    249    74%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:100: The previous and actual specifications are identical.
SKIPPED [5] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:509: The previous and actual discovered catalogs are identical.
================== 95 passed, 6 skipped in 251.83s (0:04:11) ===================

@evantahler

Copy link
Copy Markdown
Contributor

sunny (@sh4sh) πŸ‘ from me, assuming the tests pass.
Edward Gao (@edgao) When double-checking the format of date-time, I found that https://docs.airbyte.com/understanding-airbyte/supported-data-types seems to only include the V2 types now. Can you confirm that this change is the right move for the current types?

@edgao Edward Gao (edgao) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this change switching the TZ from +0000 to Z? That seems right to me. Some destinations (e.g. snowflake) assume that the tz offset is either Z or +/- HH:MM (i.e. with a colon), e.g. https://github.com/airbytehq/oncall/issues/1476.

Comment on lines +1 to +2
{"stream": "test", "data": {"id": 0, "fullname_and_valid": {"fullname": "cfjwIzCRTL", "valid": false}, "_ab_additional_properties": {}, "_ab_source_file_last_modified": "2022-05-11T11:54:11Z", "_ab_source_file_url": "test_sample.avro"}, "emitted_at": 10000000}
{"stream": "test", "data": {"id": 1, "fullname_and_valid": {"fullname": "LYOnPyuTWw", "valid": true}, "_ab_additional_properties": {}, "_ab_source_file_last_modified": "2022-05-11T11:54:11Z", "_ab_source_file_url": "test_sample.avro"}, "emitted_at": 10000000}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yep! this looks like the change we want!

Comment thread docs/integrations/sources/s3.md Outdated

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:----------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------|
| 1.0.3 | 2023-03-06 | [23195](https://github.com/airbytehq/airbyte/pull/23195) | Fix datetime format string |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oliver Meyer (@olivermeyer) this PR is one file change away from being ready to merge - You also need to bump the version in the Dockerfile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@evantahler

Copy link
Copy Markdown
Contributor

Oh no Oliver Meyer (@olivermeyer) - we've got merge conflicts again. source-s3 just had v2 released. I'll settle the merge conflicts and re-run the tests. Looks like you are creating v2.0.1 now

@evantahler

Evan Tahler (evantahler) commented Mar 14, 2023

Copy link
Copy Markdown
Contributor

/test connector=connectors/source-s3

πŸ•‘ connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4420247186
βœ… connectors/source-s3 https://github.com/airbytehq/airbyte/actions/runs/4420247186
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
source_s3/source_files_abstract/storagefile.py                       23      0   100%
source_s3/source_files_abstract/spec.py                              55      0   100%
source_s3/source_files_abstract/formats/parquet_spec.py               9      0   100%
source_s3/source_files_abstract/formats/jsonl_spec.py                13      0   100%
source_s3/source_files_abstract/formats/csv_spec.py                  16      0   100%
source_s3/source_files_abstract/formats/avro_spec.py                  5      0   100%
source_s3/source.py                                                  27      0   100%
source_s3/exceptions.py                                              10      0   100%
source_s3/__init__.py                                                 2      0   100%
source_s3/source_files_abstract/formats/parquet_parser.py            64      2    97%
source_s3/source_files_abstract/formats/abstract_file_parser.py      41      2    95%
source_s3/stream.py                                                  43      3    93%
source_s3/s3file.py                                                  41      3    93%
source_s3/source_files_abstract/formats/avro_parser.py               39      3    92%
source_s3/source_files_abstract/formats/jsonl_parser.py              53      5    91%
source_s3/source_files_abstract/file_info.py                         26      3    88%
source_s3/source_files_abstract/source.py                            41      7    83%
source_s3/source_files_abstract/formats/csv_parser.py               127     22    83%
source_s3/source_files_abstract/stream.py                           198     39    80%
source_s3/s3_utils.py                                                20      4    80%
source_s3/utils.py                                                   31     10    68%
-------------------------------------------------------------------------------------
TOTAL                                                               884    103    88%
Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
source_s3/source_files_abstract/formats/parquet_spec.py               9      0   100%
source_s3/source_files_abstract/formats/jsonl_spec.py                13      0   100%
source_s3/source_files_abstract/formats/csv_spec.py                  16      0   100%
source_s3/source_files_abstract/formats/avro_spec.py                  5      0   100%
source_s3/s3_utils.py                                                20      0   100%
source_s3/__init__.py                                                 2      0   100%
source_s3/source_files_abstract/storagefile.py                       23      1    96%
source_s3/source_files_abstract/stream.py                           198     11    94%
source_s3/stream.py                                                  43      3    93%
source_s3/s3file.py                                                  41      3    93%
source_s3/source_files_abstract/formats/abstract_file_parser.py      41      4    90%
source_s3/source.py                                                  27      4    85%
source_s3/source_files_abstract/file_info.py                         26      8    69%
source_s3/utils.py                                                   31     10    68%
source_s3/source_files_abstract/formats/csv_parser.py               127     46    64%
source_s3/exceptions.py                                              10      4    60%
source_s3/source_files_abstract/source.py                            41     18    56%
source_s3/source_files_abstract/spec.py                              55     31    44%
source_s3/source_files_abstract/formats/jsonl_parser.py              53     32    40%
source_s3/source_files_abstract/formats/avro_parser.py               39     25    36%
source_s3/source_files_abstract/formats/parquet_parser.py            64     44    31%
-------------------------------------------------------------------------------------
TOTAL                                                               884    244    72%

Build Passed

Test summary info:

=========================== short test summary info ============================
SKIPPED [1] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:100: The previous and actual specifications are identical.
SKIPPED [5] ../usr/local/lib/python3.9/site-packages/connector_acceptance_test/tests/test_core.py:509: The previous and actual discovered catalogs are identical.
================== 95 passed, 6 skipped in 276.67s (0:04:36) ===================

@evantahler Evan Tahler (evantahler) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests passing, let's go!

@evantahler

Evan Tahler (evantahler) commented Mar 16, 2023

Copy link
Copy Markdown
Contributor

/publish connector=connectors/source-s3

πŸ•‘ Publishing the following connectors:
connectors/source-s3
https://github.com/airbytehq/airbyte/actions/runs/4440052085


Connector Did it publish? Were definitions generated?
connectors/source-s3 βœ… βœ…

if you have connectors that successfully published but failed definition generation, follow step 4 here ▢️

@evantahler
Evan Tahler (evantahler) merged commit 5975c32 into airbytehq:master Mar 16, 2023
Adrienne Vermorel (adriennevermorel) pushed a commit to adriennevermorel/airbyte that referenced this pull request Mar 17, 2023
* Fix datetime format string in FileStream

* Update changelog

* Fix integration tests

* Localize datetime objects

* Bump Dockerfile version

* auto-bump connector version

---------

Co-authored-by: Nataly Merezhuk <65251165+natalyjazzviolin@users.noreply.github.com>
Co-authored-by: sh4sh <6833405+sh4sh@users.noreply.github.com>
Co-authored-by: Evan Tahler <evan@airbyte.io>
Co-authored-by: Augustin <augustin@airbyte.io>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Ella Rohm-Ensing (erohmensing) pushed a commit that referenced this pull request Mar 22, 2023
* Fix datetime format string in FileStream

* Update changelog

* Fix integration tests

* Localize datetime objects

* Bump Dockerfile version

* auto-bump connector version

---------

Co-authored-by: Nataly Merezhuk <65251165+natalyjazzviolin@users.noreply.github.com>
Co-authored-by: sh4sh <6833405+sh4sh@users.noreply.github.com>
Co-authored-by: Evan Tahler <evan@airbyte.io>
Co-authored-by: Augustin <augustin@airbyte.io>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Ella Rohm-Ensing (erohmensing) pushed a commit that referenced this pull request Mar 22, 2023
* Fix datetime format string in FileStream

* Update changelog

* Fix integration tests

* Localize datetime objects

* Bump Dockerfile version

* auto-bump connector version

---------

Co-authored-by: Nataly Merezhuk <65251165+natalyjazzviolin@users.noreply.github.com>
Co-authored-by: sh4sh <6833405+sh4sh@users.noreply.github.com>
Co-authored-by: Evan Tahler <evan@airbyte.io>
Co-authored-by: Augustin <augustin@airbyte.io>
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S3 source throwing JsonSchemaValidator errors

8 participants