Joins
This page describes joining data in Kafka with Lenses SQL Studio.
Joins
Lenses allows you to combine records from two tables. A query can contain zero, one or multiple JOIN operations.
Create an orders table and insert some data into it:
CREATE TABLE orders(
_key INT
, orderDate STRING
, customerId STRING
, amount DOUBLE
)
FORMAT(int, avro);
INSERT INTO orders (
_key
, orderDate
, customerId
, amount
)
VALUES
(1, '2018-10-01', '1', 200.50),
(2, '2018-10-11', '1', 813.00),
(3, '2018-10-11', '3', 625.20),
(4, '2018-10-11', '14', 730.00),
(5, '2018-10-11', '10', 440.00),
(6, '2018-10-11', '9', 444.80);With these tables in place, join them to get more information about an order by combining it with the customer information found in the customer table:
Lateral Joins
With lateral joins, Lenses allows you to combine records from a table with the elements of an array expression.
We are going to see in more detail what lateral joins are with an example.
Create a batched_readings table and insert some data into it:
You now can use a LATERAL join to inspect, extract and filter the single elements of the readings array, as if they were a normal field:
Running that query we will get the values:
1
100
1
95
1
91
2
93
1
92
1
94
You can use multiple LATERAL joins, one inside the other, if you want to extract elements from a nested array:
Running the following query we will obtain the same records of the previous example:
Last updated
Was this helpful?

