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

KAFKA-6049: extend Kafka Streams Scala API for cogroup (KIP-150) #7847

Merged
merged 6 commits into from Jan 8, 2020

Conversation

mjsax
Copy link
Member

@mjsax mjsax commented Dec 18, 2019

More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.

Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@mjsax mjsax added the streams label Dec 18, 2019
@mjsax
Copy link
Member Author

mjsax commented Dec 18, 2019

Call for review @bbejeck @vvcephei @wcarlson5

* @return an instance of {@link SessionWindowedCogroupedKStream}
*/
SessionWindowedCogroupedKStream<K, VOut> windowedBy(final SessionWindows sessionWindows);

Copy link
Member Author

Choose a reason for hiding this comment

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

Just re-ordered this method to have the same ordering over multiple classes (time-window always before session-window)

implicit def wrapSessionWindowedKStream[K, V](inner: SessionWindowedKStreamJ[K, V]): SessionWindowedKStream[K, V] =
new SessionWindowedKStream[K, V](inner)

implicit def wrapTimeWindowedKStream[K, V](inner: TimeWindowedKStreamJ[K, V]): TimeWindowedKStream[K, V] =
new TimeWindowedKStream[K, V](inner)
Copy link
Member Author

Choose a reason for hiding this comment

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

Move this one up to get better overview/grouping. The three below are new

@@ -525,7 +525,7 @@ class KStream[K, V](val inner: KStreamJ[K, V]) {
* @see `org.apache.kafka.streams.kstream.KStream#join`
* @deprecated since 2.4. Use [[KStream#join(KStream, ValueJoiner, JoinWindows, StreamJoined)]] instead.
*/
@deprecated
@deprecated("use join(KStream, ValueJoiner, JoinWindows, StreamJoined) instead", "2.4")
Copy link
Member Author

Choose a reason for hiding this comment

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

Just a side fix -- got a warning about it

@@ -21,15 +21,18 @@ package org.apache.kafka.streams.scala
package kstream

import org.apache.kafka.streams.kstream.internals.KTableImpl
import org.apache.kafka.streams.kstream.{KTable => KTableJ, SessionWindowedKStream => SessionWindowedKStreamJ, _}
Copy link
Member Author

Choose a reason for hiding this comment

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

Only some side cleanup in this class

_
}
import org.apache.kafka.streams.scala.FunctionsCompatConversions._
import org.apache.kafka.streams.scala.ImplicitConversions._
Copy link
Member Author

Choose a reason for hiding this comment

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

IntelliJ complains that this is an unused import, but without it, it does not compile at command line -- what might I do wrong?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can explicitly import the implicit conversions that you're using. Actually, I would recommend not even using them implicitly, but just to explicitly invoke the relevant conversion methods when you need them. (i.e., implicit conversions are syntactic sugar for users of the public API, we should try to instead write explicit and maintainable code in our internal implementations)

It should be pretty obvious which ones you need if you just delete this line and see what fails to compile.

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on this commend, I did a proper cleanup PR: #7852

We should merge the cleanup PR first, and I can rebase this PR afterwards.

_
}
import org.apache.kafka.streams.scala.FunctionsCompatConversions._
import org.apache.kafka.streams.scala.ImplicitConversions._
Copy link
Member Author

Choose a reason for hiding this comment

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

Same question as above.

Copy link
Contributor

@vvcephei vvcephei left a comment

Choose a reason for hiding this comment

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

Hey @mjsax , thanks for adding this!

I answered your question. Otherwise, this looks reasonable, but I no longer test any Scala APIs that don't have "black box" tests... I.e., we need to write a test that uses the API just like users will to make sure it actually works the way we think it will.

_
}
import org.apache.kafka.streams.scala.FunctionsCompatConversions._
import org.apache.kafka.streams.scala.ImplicitConversions._
Copy link
Contributor

Choose a reason for hiding this comment

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

You can explicitly import the implicit conversions that you're using. Actually, I would recommend not even using them implicitly, but just to explicitly invoke the relevant conversion methods when you need them. (i.e., implicit conversions are syntactic sugar for users of the public API, we should try to instead write explicit and maintainable code in our internal implementations)

It should be pretty obvious which ones you need if you just delete this line and see what fails to compile.

@bbejeck
Copy link
Contributor

bbejeck commented Dec 19, 2019

@mjsax failures are relevant Execution failed for task ':spotlessScala'. scala formatting errors.

Copy link
Contributor

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @mjsax. Overall this LGTM. I agree with @vvcephei about adding a new test(s) for the additions.

import org.scalatest.{FlatSpec, Matchers}
import org.scalatestplus.junit.JUnitRunner
Copy link
Member Author

Choose a reason for hiding this comment

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

Some side cleanup. org.scalatest.junit.JUnitRunner is deprecated

@mjsax
Copy link
Member Author

mjsax commented Dec 21, 2019

Updated this PR (rebased, added tests). Call for review @bbejeck @vvcephei

@mjsax
Copy link
Member Author

mjsax commented Jan 6, 2020

@vvcephei @bbejeck Rebased to resolve merge conflict. Call for review.

Copy link
Contributor

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

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

Thanks for the updated PR @mjsax, LGTM

@bbejeck
Copy link
Contributor

bbejeck commented Jan 7, 2020

Java 8 failed with

kafka.admin.LeaderElectionCommandTest.testPathToJsonFile
kafka.api.PlaintextConsumerTest.testLowMaxFetchSizeForRequestAndPartition

Updated existing flaky test Jira tickets

Java 11 passed

retest this please

@mjsax
Copy link
Member Author

mjsax commented Jan 7, 2020

Java 8 failed (one overlapping test failure):

kafka.admin.TopicCommandWithAdminClientTest.testCreateAlterTopicWithRackAware
kafka.api.PlaintextConsumerTest.testLowMaxFetchSizeForRequestAndPartition

Java 11 passed.

Retest this please.

@mjsax
Copy link
Member Author

mjsax commented Jan 8, 2020

Java 11 passed.

Java 8 failed (different test):

org.apache.kafka.streams.integration.StandbyTaskCreationIntegrationTest.shouldCreateStandByTasksForMaterializedAndOptimizedSourceTables

Merging this.

@mjsax mjsax merged commit 1ccca5c into apache:trunk Jan 8, 2020
@mjsax mjsax deleted the kafka-6049-cogroup-scala branch February 11, 2020 22:56
@mjsax mjsax added the kip Requires or implements a KIP label Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kip Requires or implements a KIP streams
Projects
None yet
3 participants