Hex
This guide walks you through the steps required to use the collaborative data notebook Hex with Materialize.
Create an integration
-
Sign in to Hex.
-
Go to an existing project or create a new one.
-
Go to Data Sources > +Add > Create data connection… > Materialize.
-
Search and click the Materialize option.
-
Enter the connection fields as follows:
Field Value Name Materialize. Description A description you prefer. Host & Port Materialize host name, and 6875 for the port. Database materialize Authentication type Choose the Password option. Username Materialize user. Password App-specific password. -
Click the Create connection button.
Configure a custom cluster
To direct queries to a specific cluster, set the cluster at the role level using the following SQL statement:
ALTER ROLE <your_user> SET CLUSTER = <custom_cluster>;
Replace <your_user>
with the name of your Materialize role and <custom_cluster>
with the name of the cluster you want to use.
Once set, all new sessions for that user will automatically run in the specified cluster, eliminating the need to manually specify it in each query or connection.
Execute and visualize a query
-
Create a new SQL cell.
-
Inside the cell, select the new Materialize connection and paste the following query:
SELECT number, row_num FROM ( SELECT power(series_number, 2) AS number, row_number() OVER (ORDER BY series_number ASC, series_number DESC) AS row_num FROM ( SELECT generate_series(0, 1000) AS series_number ) AS subquery );
This query generates a series of 1000 numbers squared and assigns row numbers to each.
-
Click the Run button.
-
Inside the cell, click the Chart button and configure as follows:
- In the X Axis options, select the row_num column.
- In the Y Axis options, select the number column.
Related pages
For more information about Hex and data connections, visit their documentation.