Introduction
Transform's command-line interface, Python package, and JDBC driver enables you to collaborate and publish interactive data apps in Hex. If your team uses Transform + Hex, you can be confident that the queries you are executing are coming from a single source of truth that you defined in Transform.
#
Requirements CLI and Python package- Hex
- Hosted Transform Deployment
#
Requirements JDBC in Hex- Hex
- Admin access in Hex to connect to the data source
- Hosted Transform Deployment with JDBC enabled
#
Installation Steps CLIIn the Hex project, save your API Key as a Secret by navigating in the left sidebar to Variables โ> Secrets โ> Add.
In the Hex project, add a Python cell using Add Cell โ> Python at the bottom of your project.
In the Python cell, install the
transform
package:
!pip install transform
- Setup your connection to the mql server:
!mql setup -k "$api_key_secret_name"
- You can now use any CLI commands just by preceding the command with
!
:
!mql list-metrics!mql query --metrics orders --dimensions ds__week,user_id__country --limit 10
#
Installation Steps Python PackageIn the Hex project, save your API Key as a Secret by navigating in the left sidebar to Variables โ> Secrets โ> Add.
In the Hex project, add a Python cell using Add Cell โ> Python at the bottom of your project.
In the Python cell, install the
transform
package:
!pip install transform
- Import the
MQLClient
from thetransform
package and use the API Secret to connect to the mql server:
from transform.mql import MQLClientmql = MQLClient(api_key_secret_name)
- Query using Transform's Python interface:
from transform import mql
df = mql.query(metrics=["orders"], dimensions=["ds"], where="is_large")
#
Installation Steps JDBCTransform's JDBC connector uses Apache Calcite Avatica, the same interface as Apache Druid.
In Hex, setup a new Data connection in the Admin -> Workspace assets panel.
Select + Connection and chose the Transform connection.
Transform will send you the host and port information of your Avatica server over Slack or Email.
Once you receive your host and port information from Transform, give your connection a Name and a Description. Fill in the Host and Port information that you received from Transform. Add your Hex user to the Username and Password. Click Update connection at the bottom of the setup page.
In the Hex project, add a SQL cell using Add Cell โ> SQL at the bottom of your project. In the Source dropdown, select the Transform Data source you just created.
Query using Transform's JDBC interface:
select * from MQL_QUERY(<messages BY ds, user_id__country>) where user_id__country = 'United States'
select ds, private_messages * 1.0 / messages as pct_private from MQL_QUERY(<messages, private_messages BY ds>)