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

Non-data fields - Metadata fields to Kafka Connector #765

Merged
merged 42 commits into from
Oct 30, 2024

Conversation

vaibhawvipul
Copy link
Contributor

enabling users to query using the following syntax -

create table users (
    id TEXT,
    name TEXT,
    offset BIGINT GENERATED ALWAYS AS (metadata('offset_id')) STORED
) with (
    connector = 'kafka',
    ...
);

Demo -
Screenshot 2024-10-24 at 11 21 10 AM

@vaibhawvipul vaibhawvipul marked this pull request as draft October 24, 2024 05:51
@vaibhawvipul vaibhawvipul marked this pull request as ready for review October 27, 2024 17:31
crates/arroyo-operator/src/connector.rs Outdated Show resolved Hide resolved
crates/arroyo-operator/src/context.rs Outdated Show resolved Hide resolved
crates/arroyo-operator/src/context.rs Outdated Show resolved Hide resolved
crates/arroyo-operator/src/context.rs Outdated Show resolved Hide resolved
crates/arroyo-planner/src/tables.rs Outdated Show resolved Hide resolved
crates/arroyo-planner/src/tables.rs Outdated Show resolved Hide resolved
crates/arroyo-connectors/src/kafka/source/mod.rs Outdated Show resolved Hide resolved
crates/arroyo-formats/src/de.rs Outdated Show resolved Hide resolved
@vaibhawvipul vaibhawvipul requested a review from mwylde October 28, 2024 11:40
Copy link
Member

@mwylde mwylde left a comment

Choose a reason for hiding this comment

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

Great progress on the PR!

A few remaining issues.

We're now validating metadata names (although the key/value are switched), but we're missing two types of validations for the user:

  • Data types, which if the user sets the wrong type they get a runtime error, for example if they declare
    offset_id INT GENERATED ALWAYS AS (metadata('offset_id')) STORED

and we're not validating that the metadata columns have only a metadata function in them, so this plans:

    offset_id BIGINT GENERATED ALWAYS AS (concat(metadata('offset_id'), '1')) STORED

Beyond that, I'd like to see some tests, both for the deserialization logic and for planning. It might also be worth modifying the kafka tests to use metadata fields.

crates/arroyo-connectors/src/kafka/mod.rs Outdated Show resolved Hide resolved
crates/arroyo-connectors/src/kafka/source/mod.rs Outdated Show resolved Hide resolved
crates/arroyo-formats/src/de.rs Outdated Show resolved Hide resolved
crates/arroyo-formats/src/de.rs Outdated Show resolved Hide resolved
crates/arroyo-formats/src/de.rs Outdated Show resolved Hide resolved
crates/arroyo-formats/src/de.rs Outdated Show resolved Hide resolved
@vaibhawvipul
Copy link
Contributor Author

@mwylde can you please trigger the CI again? I am asking because my last commit ran successfully, the failed CI is on master merge.

Copy link
Member

@mwylde mwylde left a comment

Choose a reason for hiding this comment

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

Thanks, this is a great contribution!

@mwylde mwylde enabled auto-merge (squash) October 30, 2024 15:54
@mwylde mwylde merged commit 28360fe into ArroyoSystems:master Oct 30, 2024
3 checks passed
@vaibhawvipul vaibhawvipul deleted the kafka-metadata branch October 30, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants