Skip to main content

Materializing Metrics using CLI

Materializations are invoked through the command line and scheduled to run at a cadence. The configuration for the materialization must already exist in your Transform configurations in order for you to run this command. For more information on Materializations, see here.

Usage

Run the following to see all options

mql materialize --help
    /opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/fuzzywuzzy/fuzz.py:11: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning
warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
Usage: mql materialize [OPTIONS]

Create a new MQL materialization query, polls for completion and returns
materialized table id

Options:
--materialization-name TEXT Name of materialization to materialize
[required]
--end-time TEXT Optional iso8601 timestamp to constraint the
end time of the data (inclusive) (eg.,
'2020-01-04')
--start-time TEXT Optional iso8601 timestamp to constraint the
start time of the data (inclusive) (eg.,
'2020-01-04')
--output-table TEXT Write materialized result to specified table of
format '<schema>.<table_name>'
-f, --force
-t, --timeout INTEGER Sets the timeout to wait for query completion.
Pass 0 to remove any timeout.
--detach BOOLEAN Returns the created query ID to allow for
asynchronous querying.
--web Open the MQL server logs on the web
--debug Enable showing query log in the terminal for
debugging purpose
--help Show this message and exit.

Examples

The materialization-name should map to the one committed in your Transform directory. If you don't provide a start and end-time, the materialization will run across all available data, which can be very expensive.

mql materialize --materialization-name my_materialization

Providing a start and end time will bound the data for the materialization.

mql materialize --materialization-name my_materialization --start-time 2020-01-01 --end-time 2020-01-31

By default, the materialization will write to the Transform schema and any other location you've specified in the destinations for your configuration. Optionally provide a specific schema and table to write the materialization to. Note this won't be managed by Transform once it's written outside our cache.

mql materialize --materialization-name my_materialization --start-time 2020-01-01 --end-time 2020-01-31 --output-table my_schema.my_table