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

Left join doesn't work as advertised #443

Closed
burnayev-co opened this issue Nov 8, 2017 · 6 comments
Closed

Left join doesn't work as advertised #443

burnayev-co opened this issue Nov 8, 2017 · 6 comments
Labels

Comments

@burnayev-co
Copy link

burnayev-co commented Nov 8, 2017

Trying to wrap my mind around KSQL joins with KSQL 0.1... Always getting null on the right side.

Here's an example:

  1. Create a stream, a table, and a continuous query:
CREATE STREAM pageviews (userid varchar, pageid varchar) WITH (kafka_topic='pageviews', value_format='DELIMITED');
CREATE TABLE users (regionid varchar, userid varchar) WITH (kafka_topic='users', value_format='DELIMITED');
CREATE STREAM pageviews_with_users AS SELECT pageviews.userid AS userid, pageid, regionid FROM pageviews LEFT JOIN users ON pageviews.userid = users.userid;
  1. Setup the observation:
SELECT * FROM pageviews;
SELECT * FROM users;
SELECT * FROM pageviews_with_users;
  1. Post a few messages:
    u_abc123,p_xyz890 - to pageviews
    US,u_abc123 - to users
    u_abc123,p_xyz890 - to pageviews

  2. Watch the queries:

ksql> select * from pageviews;
1510088750070 | abc123 | u_abc123 | p_xyz890
1510088873623 | abc123 | u_abc123 | p_xyz890

ksql> select * from users;
1510088814659 | abc123 | US | u_abc123

ksql> select * from pageviews_with_users;
1510088750070 | u_abc123 | u_abc123 | p_xyz890 | null
_1510088873623 | u_abc123 | u_abc123 | p_xyz890 | **null**_

According to https://docs.confluent.io/current/streams/developer-guide.html#streams-developer-guide-dsl-joins I'd expect to see a non-null value in the highlighted row above.

Am I doing something wrong?

@miguno miguno added the question label Nov 8, 2017
@bluemonk3y
Copy link

Hi @burnayev-co - Can you confirm that your table data is published with a key? (how are you publishing it?)

@burnayev-co
Copy link
Author

val producer = KafkaProducer<String, ByteArray>(getKafkaProperties())
File("users.txt").forEachLine { line ->
    val serialized = line.toByteArray()
    val record = ProducerRecord<String, ByteArray>("users", "abc123", serialized)
    producer.send(record)
}
producer.close()

All the messages are published with the same key abc123

It's Kotlin if you wonder

@bluemonk3y
Copy link

hi @burnayev-co - I believe we have a fix. Either pick up the latest 4.0.x branch or wait for the new release tomorrow.

@apurvam
Copy link
Contributor

apurvam commented Nov 11, 2017

This is fixed by #450 . Closing this ticket out. Please repoen if you can reproduce with the latest commits on 4.0.x

@apurvam apurvam closed this as completed Nov 11, 2017
@chengang2
Copy link

@burnayev-co I have the same problem, how to solve。left join tableb but the column of tableb value is null

@burnayev-co
Copy link
Author

@chengang2 In my testing everything worked as advertised with the 0.4 release

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

No branches or pull requests

5 participants