Creating Materialized Views

After executing a SQL Stream job, you can set up the Materialized Views to have a snapshot of your queried data. You can use the URL Pattern from the Materialized View to visualize the generated data.

  • Make sure that PostgreSQL is installed and configured to SQL Stream Builder (SSB) to create Materialized Views.
  1. Navigate to the Streaming SQL Console.
    1. Go to your cluster in Cloudera Manager.
    2. Select SQL Stream Builder from the list of services.
    3. Click SQLStreamBuilder Console.
    The Streaming SQL Console opens in a new window.
  2. Click Create Job or select a previous job on the Getting Started page.
    You are redirected to the Console page. The Materialized View button will be available when you add a query to the SQL Editor.
  3. Click Materialized View.
  4. Switch Enable MV toggle.
  5. Select a Primary Key.
    If this list is empty, then no SQL is specified in the SQL Editor or the SQL query is invalid. Select a key as a primary key for the Materialized View. All data will be updated by this key.
  6. Select a Retention Period.
    Data not being mutated during this period is removed from the view.
  7. Enable or disable Recreate on Job Start.
    If enabled, the Materialized View is deleted when a job is started or restarted.
  8. Enable or disable Ignore NULLS.
    If enabled, NULL values will NOT update values that are non null - they are ignored.
  9. Select an API Key.
    In case there are no API Keys, click Add API key, or click Materialized Views from the main menu. The add API key window appears. Provide a name for the API key, and click Save Changes.
    To check your created API keys:
    1. Click Materialized Views from the main menu.

      The Materialized Views page appears.

    2. Select API Keys tab.
  10. Click Add New Query to create the Materialized View query.
    The Materialized View Query Configuration window appears.
  11. Provide a name in the URL Pattern field.
  12. Provide a description of the Materialized View Query, if needed.
  13. Customize the Materialized View in the Query Editor.
    1. Select the columns of the SQL job you want to use in the Materialized View Query.
      You can select every column in the table by clicking on the Select All button.
    2. Click Filters tab to apply computations and further enrichment of your data.
    3. Provide details of the filter by selecting the Field, Operator and Value.
      You can add more rules or set a ruleset for the query.
  14. Click Apply or Apply and Save Job.
    The URL for the Materialized View appears under the Queries header.
You can click the created REST endpoint to review the data, or copy it and visualize the queried data in a Business Intelligence tool, notebook, code and so on. You can also review the list of Materialized View and API keys on the Materialized View page.