-
Notifications
You must be signed in to change notification settings - Fork 108
py: kafka connector #1807
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
Merged
py: kafka connector #1807
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ docs/feldera.rst | |
| docs/feldera.rest.rst | ||
| build | ||
| feldera.egg-info | ||
| UNKNOWN.egg-info | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| from feldera.rest.client import Client as FelderaClient | ||
| from feldera.rest.feldera_client import FelderaClient | ||
| from feldera.sql_context import SQLContext | ||
| from feldera.sql_schema import SQLSchema |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| from typing import Optional | ||
| from typing_extensions import Self | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class JSONUpdateFormat(Enum): | ||
| """ | ||
| Supported JSON data change event formats. | ||
|
|
||
| Each element in a JSON-formatted input stream specifies | ||
| an update to one or more records in an input table. We support | ||
| several different ways to represent such updates. | ||
|
|
||
| https://www.feldera.com/docs/api/json/#the-insertdelete-format | ||
| """ | ||
|
|
||
| InsertDelete = 1 | ||
| """ | ||
| Insert/delete format. | ||
|
|
||
| Each element in the input stream consists of an "insert" or "delete" | ||
| command and a record to be inserted to or deleted from the input table. | ||
|
|
||
| Example: `{"insert": {"id": 1, "name": "Alice"}, "delete": {"id": 2, "name": "Bob"}}` | ||
| Here, `id` and `name` are the columns in the table. | ||
| """ | ||
|
|
||
| Raw = 2 | ||
| """ | ||
| Raw input format. | ||
|
|
||
| This format is suitable for insert-only streams (no deletions). | ||
| Each element in the input stream contains a record without any | ||
| additional envelope that gets inserted in the input table. | ||
|
|
||
| Example: `{"id": 1, "name": "Alice"}` | ||
| Here, `id` and `name` are the columns in the table. | ||
| """ | ||
|
|
||
| def __str__(self): | ||
| match self: | ||
| case JSONUpdateFormat.InsertDelete: | ||
| return "insert_delete" | ||
| case JSONUpdateFormat.Raw: | ||
| return "raw" | ||
|
|
||
|
|
||
| class JSONFormat: | ||
| """ | ||
| Used to represent data ingested and output from Feldera in the JSON format. | ||
| """ | ||
|
|
||
| def __init__(self, config: Optional[dict] = None): | ||
| """ | ||
| Creates a new JSONFormat instance. | ||
|
|
||
| :param config: Optional. Configuration for the JSON format. | ||
| """ | ||
|
|
||
| self.config: dict = config or { | ||
| "array": False, | ||
| } | ||
|
|
||
| def with_update_format(self, update_format: JSONUpdateFormat) -> Self: | ||
| """ | ||
| Specifies the format of the data change events in the JSON data stream. | ||
| """ | ||
|
|
||
| self.config["update_format"] = update_format.__str__() | ||
| return self | ||
|
|
||
| def with_array(self, array: bool) -> Self: | ||
ryzhyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| Set to `True` if updates in this stream are packaged into JSON arrays. | ||
|
|
||
| Example: `[{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]` | ||
| """ | ||
|
|
||
| self.config["array"] = array | ||
| return self | ||
|
|
||
| def to_dict(self): | ||
| """ | ||
| Serialize to a dict to be used in the API request. | ||
|
|
||
| :meta private: | ||
| """ | ||
| return { | ||
| "name": "json", | ||
| "config": self.config | ||
| } | ||
|
|
||
|
|
||
| class CSVFormat: | ||
| """ | ||
| Used to represent data ingested and output from Feldera in the CSV format. | ||
|
|
||
| https://www.feldera.com/docs/api/csv | ||
| """ | ||
|
|
||
| def to_dict(self) -> dict: | ||
| """ | ||
| Serialize to a dict to be used in the API request. | ||
|
|
||
| :meta private: | ||
| """ | ||
| return { | ||
| "name": "csv" | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ | |
|
|
||
| """ | ||
|
|
||
| from feldera.rest.client import Client | ||
| from feldera.rest.feldera_client import FelderaClient | ||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.