I have written KSQL query to filter records whose country code is US.Below query is working fine however I have hardcoded the ADDRESSES[0], but in the where clause i dont want to hardcode [0] position
SELECT * FROM CustomerStream
WHERE uniqueIdentity->identityType = 'Passport'
and ADDRESSES[0]->COUNTRYCODE='US';
I should be able to fetch all the customers whose country code ='US' , below is sample message in the stream
{
"CUSTOMERID": "Cust01",
"FIRSTNAME": "ABC",
"LASTNAME": "DEF",
"GENDER": "NA",
"DATEOFBIRTH": 1706425538817,
"ADDRESSES": [
{
"ADDRESSTYPE": "Home",
"HOUSENUMBER": "123",
"POSTALCODE": "172612",
"COUNTRYCODE": "UK"
},
{
"ADDRESSTYPE": "Office",
"HOUSENUMBER": "123",
"POSTALCODE": "562317",
"COUNTRYCODE": "US"
}
],
"UNIQUEIDENTITY": {
"IDENTITYTYPE": "AWERT",
"IDENTITYNUMBER": "G5PIX",
"EXPIRYDATE": 1705600302337
}
}
I am afraid, that ksqldb does not support this type of nested where statements. What might work here is somehow flattering and then use flattered fields in where statement.