Course: ksqlDB 101

Hands On: Push Queries and Pull Queries

2 min
Allison WaltherIntegration Architect (Course Presenter)
Robin MoffattStaff Developer Advocate (Course Author)

Hands On: Push Queries and Pull Queries

Push and pull queries are easier to understand if you view them in action.

This exercise continues with the PERSON_STATS table from Hands On: Stateful Aggregations (Materialized Views).

Run Push and Pull Queries

  1. Issue a pull query on the PERSON_STATS table:

    SELECT LATEST_LOCATION, LOCATION_CHANGES, UNIQUE_LOCATIONS
    FROM PERSON_STATS WHERE PERSON = 'Allison';

    Click Run query and view the returned LATEST_LOCATION, LOCATION_CHANGES, and UNIQUE_LOCATIONS.

  2. Now issue a push query on the PERSON_STATS table:

    SELECT LATEST_LOCATION, LOCATION_CHANGES, UNIQUE_LOCATIONS
    FROM PERSON_STATS WHERE PERSON = 'Allison' EMIT CHANGES;
  3. Next, in another window, or perhaps in the CLI, insert some more data into the MOVEMENTS stream on which the PERSON_STATS table is based:

    INSERT INTO MOVEMENTS VALUES ('Robin', 'York');
    INSERT INTO MOVEMENTS VALUES ('Robin', 'Leeds');
    INSERT INTO MOVEMENTS VALUES ('Allison', 'Denver');
    INSERT INTO MOVEMENTS VALUES ('Robin', 'Ilkley');
    INSERT INTO MOVEMENTS VALUES ('Allison', 'Boulder');

    You should see new entries, reflecting this new data, appearing in the results of the push query from step 2.

  4. Kill the query with Stop. Push queries will run until they're manually killed.

Use the promo code KSQLDB101 to get $101 of free Confluent Cloud usage

Be the first to get updates and new content

We will only share developer content and updates, including notifications when new content is added. We will never send you sales emails. 🙂 By subscribing, you understand we will process your personal information in accordance with our Privacy Statement.