Skip to main content

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 CLI#

  1. In the Hex project, save your API Key as a Secret by navigating in the left sidebar to Variables โ€”> Secrets โ€”> Add.

  2. In the Hex project, add a Python cell using Add Cell โ€”> Python at the bottom of your project.

  3. In the Python cell, install the transform package:

!pip install transform
  1. Setup your connection to the mql server:
!mql setup -k "$api_key_secret_name"
  1. 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 Package#

  1. In the Hex project, save your API Key as a Secret by navigating in the left sidebar to Variables โ€”> Secrets โ€”> Add.

  2. In the Hex project, add a Python cell using Add Cell โ€”> Python at the bottom of your project.

  3. In the Python cell, install the transform package:

!pip install transform
  1. Import the MQLClient from the transform package and use the API Secret to connect to the mql server:
from transform.mql import MQLClientmql = MQLClient(api_key_secret_name)
  1. Query using Transform's Python interface:
from transform import mql
df = mql.query(metrics=["orders"], dimensions=["ds"], where="is_large")

Installation Steps JDBC#

Transform's JDBC connector uses Apache Calcite Avatica, the same interface as Apache Druid.

  1. In Hex, setup a new Data connection in the Admin -> Workspace assets panel.

  2. Select + Connection and chose the Transform connection.

  3. Transform will send you the host and port information of your Avatica server over Slack or Email.

  4. 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.

  5. 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.

  6. 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>)