Skip to content

Conversation

@pmdevers
Copy link
Owner

@pmdevers pmdevers commented Jul 1, 2025

Adds the ability to perform inner joins in stream processing.

  • Introduces an InnerJoin method to StreamBuilder to allow for creating inner joins.
  • Modifies JoinByKeyIntoBuilder to only process records when both the left and right streams have a value, effectively implementing an inner join.

Summary by CodeRabbit

  • New Features

    • Added support for inner joins, allowing users to explicitly perform inner joins in stream processing.
    • Introduced a new method to perform inner joins alongside the existing join functionality.
  • Bug Fixes

    • Improved handling of join results to ensure correct filtering based on the selected join type.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

Walkthrough

The changes introduce an innerJoin boolean parameter to the join builder logic in the Kafka stream processing code. This parameter is propagated through constructors and methods, enabling explicit selection between standard and inner joins. The API is extended with a new InnerJoin method, and conditional handling is applied based on the join type.

Changes

File(s) Change Summary
.../Stream/Internals/JoinBuilder.cs Added innerJoin parameter to constructor; passed to JoinByKeyIntoBuilder; adjusted logic.
.../Stream/Internals/JoinByKeyIntoBuilder.cs Added innerJoin parameter to constructor; changed null-check logic in Handle based on flag.
.../Stream/Internals/StreamBuilder.cs Modified Join to pass false for innerJoin; added InnerJoin method passing true.
.../Stream/IStreamBuilder.cs Added InnerJoin method to interface; simplified Join method documentation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StreamBuilder
    participant JoinBuilder
    participant JoinByKeyIntoBuilder

    User->>StreamBuilder: Join(topic) / InnerJoin(topic)
    StreamBuilder->>JoinBuilder: new JoinBuilder(..., innerJoin)
    JoinBuilder->>JoinByKeyIntoBuilder: new JoinByKeyIntoBuilder(..., innerJoin)
    JoinByKeyIntoBuilder->>JoinByKeyIntoBuilder: Handle(tuple)
    Note right of JoinByKeyIntoBuilder: Behavior changes based on innerJoin flag
Loading

Poem

In the fields of Kafka, joins now align,
With inner or outer, you choose the design.
Builders now listen for the join you declare,
With a flag in their pocket, they process with care.
Rabbits rejoice as the streams intertwine—
Hopping through logic, both yours and mine! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/MinimalKafka/Stream/Internals/JoinBuilder.cs (1)

10-11: Consider extending inner join support to predicate-based joins.

The predicate-based On method creates JoinIntoBuilder without inner join support, while the key-based On method supports inner joins. This creates inconsistent functionality where inner joins only work with key-based joins.

Consider whether JoinIntoBuilder should also support inner join functionality for consistency.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 668a688 and d449e40.

📒 Files selected for processing (3)
  • src/MinimalKafka/Stream/Internals/JoinBuilder.cs (2 hunks)
  • src/MinimalKafka/Stream/Internals/JoinByKeyIntoBuilder.cs (2 hunks)
  • src/MinimalKafka/Stream/Internals/StreamBuilder.cs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/MinimalKafka/Stream/Internals/JoinBuilder.cs (1)
src/MinimalKafka/Stream/Internals/JoinByKeyIntoBuilder.cs (1)
  • JoinByKeyIntoBuilder (6-75)
src/MinimalKafka/Stream/Internals/StreamBuilder.cs (2)
src/MinimalKafka/Stream/Internals/JoinBuilder.cs (1)
  • JoinBuilder (5-16)
src/MinimalKafka/Stream/IStreamBuilder.cs (1)
  • IJoinBuilder (20-21)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze
🔇 Additional comments (6)
src/MinimalKafka/Stream/Internals/JoinByKeyIntoBuilder.cs (2)

10-10: LGTM! Constructor parameter addition is correct.

The innerJoin parameter properly enables differentiation between join types in the constructor.


44-44: LGTM! Inner join logic correctly implemented.

The conditional logic properly implements join semantics:

  • Regular joins (innerJoin=false): Skip only when left value is null (left join behavior)
  • Inner joins (innerJoin=true): Skip when either left OR right value is null (inner join behavior)

This correctly filters records based on the join type.

src/MinimalKafka/Stream/Internals/JoinBuilder.cs (2)

5-5: LGTM! Constructor parameter addition is correct.

The innerJoin parameter is properly added to enable join type differentiation.


15-15: LGTM! Parameter propagation is correct.

The innerJoin parameter is properly passed to JoinByKeyIntoBuilder to enable conditional join behavior.

src/MinimalKafka/Stream/Internals/StreamBuilder.cs (2)

14-15: LGTM! Join method correctly maintains existing behavior.

The explicit false parameter ensures backward compatibility by preserving the existing left join behavior for the regular Join method.


17-21: LGTM! InnerJoin method provides clear API distinction.

The new InnerJoin method with explicit true parameter provides a clean API for inner join functionality while maintaining consistency with the existing Join method signature.

Comment on lines +17 to 21
public IJoinBuilder<TKey, TValue, K2, V2> InnerJoin<K2, V2>(string topic)
where K2 : notnull
{
return new JoinBuilder<TKey, TValue, K2, V2>(builder, _topic, topic, true);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify interface definition includes InnerJoin method.

The new InnerJoin method is added to the concrete StreamBuilder class. Ensure that the IStreamBuilder<TKey, TValue> interface is updated to include this method, otherwise users won't be able to access inner join functionality when working with the interface.


🏁 Script executed:

#!/bin/bash
# Description: Check if IStreamBuilder interface includes InnerJoin method
# Expected: InnerJoin method should be declared in the interface

echo "Searching for IStreamBuilder interface definition..."
rg -A 10 "interface IStreamBuilder" --type cs

echo -e "\nSearching for InnerJoin method in interface files..."
rg "InnerJoin" --type cs -g "**/I*.cs"

Length of output: 1610


Add InnerJoin to IStreamBuilder interface

The concrete StreamBuilder now exposes an InnerJoin<K2, V2>(string topic) method, but the IStreamBuilder<TKey, TValue> interface lacks this signature. Users programming against the interface won’t see or be able to call InnerJoin until it’s declared.

• File to update: src/MinimalKafka/Stream/IStreamBuilder.cs
• Insert alongside the existing join methods, for example after the current Join declaration:

 public interface IStreamBuilder<K1, V1> : IIntoBuilder<K1, V1>
 {
     /// <summary>
     /// Creates a join operation between the current stream and another stream specified by the given topic.
     /// </summary>
     IJoinBuilder<K1, V1, K2, V2> Join<K2, V2>(string topic)
         where K2 : notnull;

+    /// <summary>
+    /// Creates an inner-join operation between the current stream and another stream specified by the given topic.
+    /// </summary>
+    IJoinBuilder<K1, V1, K2, V2> InnerJoin<K2, V2>(string topic)
+        where K2 : notnull;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public IJoinBuilder<TKey, TValue, K2, V2> InnerJoin<K2, V2>(string topic)
where K2 : notnull
{
return new JoinBuilder<TKey, TValue, K2, V2>(builder, _topic, topic, true);
}
// File: src/MinimalKafka/Stream/IStreamBuilder.cs
public interface IStreamBuilder<K1, V1> : IIntoBuilder<K1, V1>
{
/// <summary>
/// Creates a join operation between the current stream and another stream specified by the given topic.
/// </summary>
IJoinBuilder<K1, V1, K2, V2> Join<K2, V2>(string topic)
where K2 : notnull;
/// <summary>
/// Creates an inner-join operation between the current stream and another stream specified by the given topic.
/// </summary>
IJoinBuilder<K1, V1, K2, V2> InnerJoin<K2, V2>(string topic)
where K2 : notnull;
}
🤖 Prompt for AI Agents
In src/MinimalKafka/Stream/IStreamBuilder.cs around the lines where join methods
are declared, add the method signature for InnerJoin<K2, V2>(string topic) to
the IStreamBuilder<TKey, TValue> interface. This will ensure that users
programming against the interface can see and call the InnerJoin method exposed
by the StreamBuilder class. Place the new method declaration alongside existing
join methods, preferably after the current Join method declaration.

Adds the ability to perform inner joins between streams,
allowing for records with matching keys to be combined.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/MinimalKafka/Stream/IStreamBuilder.cs (1)

16-20: Consider enhancing the documentation for better clarity.

The new InnerJoin method addition looks good and maintains consistency with the existing Join method. However, the documentation could be more specific about inner join semantics - consider explaining how it differs from a regular join (e.g., "only returns results when both streams have matching keys").

 /// <summary>
-/// Creates an inner-join operation between the current stream and another stream specified by the given topic.
+/// Creates an inner-join operation between the current stream and another stream specified by the given topic.
+/// Returns results only when both streams have matching keys, filtering out null values from the right stream.
 /// </summary>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d449e40 and ae7ec35.

📒 Files selected for processing (1)
  • src/MinimalKafka/Stream/IStreamBuilder.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze

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