Repository navigation
fix(file-based): skip empty CSV files during schema inference and honor ! glob exclusions - #1177
Closed
devin-ai-integration[bot] wants to merge 1 commit into
Closed
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…or `!` glob exclusions Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1790355270-file-based-empty-csv-and-glob-negation#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1790355270-file-based-empty-csv-and-glob-negationPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Contributor
Author
|
Closing at requester's request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two file-based CDK bugs surfaced by an Azure Blob Storage customer whose container (~1,100 CSVs, 10 sampled for discovery) regularly receives empty CSV files:
1. Empty CSV files fail the whole sync.
CsvParser.infer_schemaraisedEmptyFileSchemaInferenceErrorwhen a sampled file had no data rows, whichDefaultFileBasedStreamturned into a fatalSchemaInferenceError. Now an empty (0-byte or header-only) file logs a warning and contributes{}tomerge_schemas, so the schema comes from the non-empty sampled files. A 0-byte file also used to blow up earlier in_read_and_validate_headers/_auto_generate_headers(next(reader)→StopIteration), so those now return[]headers. If every sampled file is empty, the existingInvalidSchemaErrorstill fires, with the details message extended to say so. TheEmptyFileSchemaInferenceErrorclass is left in place for compatibility.2.
!patternglob exclusions were silently ignored.file_matches_globsevaluated each glob independently:Without wcmatch's
NEGATEflag,!inbound/.../x.csvis a literal pattern that never matches, so the customer's exclusions had no effect. Now:which is equivalent for positive-only lists and applies
!exclusions across the list.get_prefixes_from_globsskips!globs so we don't list under a bogus!inbound/...prefix, and theglobsfield description documents the syntax (spec snapshot incsv_scenarios.pyupdated accordingly).Tests added for both paths (parser-level empty/header-only files, stream-level merge with one empty file, glob negation + prefix handling).
unit_tests/sources/file_basedpasses except twotest_parse_start_datecases that fail identically onmain.Link to Devin session: https://app.devin.ai/sessions/99491084666f4c3dbb1596d660e1f7bc
Open in Devin Desktop: https://app.devin.ai/desktop/session/99491084666f4c3dbb1596d660e1f7bc?variant=devin