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

feat(airbyte-cdk): CSV decoder #47131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

feat(airbyte-cdk): CSV decoder #47131

wants to merge 2 commits into from

Conversation

natikgadzhi
Copy link
Contributor

What

This PR adds CSV decoder to the declarative schema, and implements the decoder itself.

TODO

  • A review from @pnilan
  • End to end tests that parse the manifest and run the CSV decoder component
  • Frontend

Copy link

vercel bot commented Oct 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview Oct 21, 2024 6:00pm

@octavia-squidington-iii octavia-squidington-iii added the CDK Connector Development Kit label Oct 21, 2024
@natikgadzhi
Copy link
Contributor Author

natikgadzhi commented Oct 21, 2024

/format-fix

Format-fix job started... Check job output.

✅ Changes applied successfully. (2d4df36)

@natikgadzhi
Copy link
Contributor Author

I'll do mypy in a bit, too.

@natikgadzhi natikgadzhi requested a review from a team October 21, 2024 17:57
@natikgadzhi
Copy link
Contributor Author

mypy checks are on legacy to per partition state, not related to the CSVDecoder per se.

Copy link
Contributor

@aldogonzalez8 aldogonzalez8 left a comment

Choose a reason for hiding this comment

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

APPROVED

Copy link
Contributor

@pnilan pnilan left a comment

Choose a reason for hiding this comment

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

Approved. See one comment/question.


parameters: InitVar[Mapping[str, Any]]

def __post_init__(self, parameters: Mapping[str, Any]):
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 benefit to injecting the delimiter as a parameter property vs directly injecting as an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know! Give me a suggestion here, I have no idea how this is done or if it will actually work when instantiated from an actual manifest. It could easily be that this is not the right way.

Comment on lines +28 to +34
def is_stream_response(self) -> bool:
return False

def decode(self, response: requests.Response) -> Generator[MutableMapping[str, Any], None, None]:
try:
csv_content = io.StringIO(response.text)
reader = csv.reader(csv_content, delimiter=self.delimiter)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🚨This is a potential OOM🚨

  1. is_stream_response should be True
  2. I'd suggest to use pandas.read_csv and read response in chunks (see Salesforce as an example)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

!!111 you're right! Thank you kindly.

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

Successfully merging this pull request may close these issues.

5 participants