Search code examples
apache-kafkaksqldb

KSQL Persisent Query not writing data to KSQL Table


I have two KSQL Tables each having the same key. I am running the following query on them

CREATE TABLE TEMP1 AS SELECT
    b.MFG_DATE,
    b.rowtime as bd_rowtime,
    s.rowtime as sd_rowtime,
    b.EXPIRY_DATE as EXP_DATE,
    b.BATCH_NO as BATCH_NO,
    s.rowkey as SD_ID
FROM GR_SD4 s
    INNER JOIN GR_BD4 b ON b.rowkey = s.rowkey;
PARTITION BY s.rowkey;

The resulting table does not get populated with data but when I run the select query separately it populates the data. I am confused on what could be the reason for the table not being populated with data.


Solution

  • The issue may be related to the PARTITION BY clause in your query. Since you are joining two tables, the resulting table will have a composite primary key (rowkey, s.rowkey). The PARTITION BY clause should be updated to reflect this, i.e. PARTITION BY rowkey, s.rowkey. This should ensure that the data is correctly partitioned and can be inserted into the table.