Skip to main content

class MQLClient:

Query Functions:#

# Make a synchronous query with Transform and returns a pandas dataframe of the resultquery(   metrics, dimensions, model_key_id=None, where=None, time_constraint=None,   time_granularity=None, order=None, limit=None, cache_mode=None, as_table=None,   allow_dynamic_cache=True, timeout=None) -> pandas.Dataframe
# Make an asynchronous query with Transform and returns a query status response objectcreate_query(   metrics, dimensions, model_key_id=None, where=None, time_constraint=None,   time_granularity=None, order=None, limit=None, cache_mode=None, as_table=None,   allow_dynamic_cache=True) -> MqlQueryStatusResp

Parameters:

  • metrics (List[str]) - list of metric names to query for
  • dimensions (List[str]) - list of dimension names to group by
  • model_key_id (Optional[int]) - provide model key to perform action on a specific config
  • where (Optional[str]) - SQL-like where statement provided as a string
  • time_constraint (Optional[str]) - set a time constraint on the query
  • time_granularity (Optional[str]) - modify the primary dimension time to a certain granularity (supported granularities: day/week/month/quarter/year)
  • order (Optional[str]) - columns to order by ("-" in front of a column means descending)
  • limit (Optional[str]) - Limit the number of rows out (Default: 100) using an int or 'inf' for no limit
  • cache_mode (Optional[str]) - set a cache option (supported inputs: r/rw/w/i)
  • as_table (Optional[str]) - write the results to a specific table
  • allow_dynamic_cache (bool) - 'False' to only allow for retrieving results from cache
  • timeout (int) - set a timeout value for max time to poll for completion (0 for no timeout)

Materialization Functions:#

# Asynchronous function for creating a materializationcreate_materialization(   materialization_name, start_time, end_time, model_key_id=None,   output_table=None, force=False) -> MqlMaterializeResp
# Synchronous function for creating a materializationmaterialize(   materialization_name, start_time, end_time, model_key_id=None,   output_table=None, force=False, timeout=None) -> MqlMaterializeResp
# Asynchronous function for dropping a materializationdrop_materialization(   materialization_name, start_time, end_time, model_key_id=None,   output_table=None) -> MqlMaterializeResp

Parameters:

  • materialization_name (str) - name of materialization to materialize
  • start_time (Optional[str]) - iso8601 timestamp to materialize from
  • end_time (Optional[str]) - iso8601 timestamp to materialize to
  • model_key_id (Optional[int]) - SQL-like where statement provided as a string
  • output_table (Optional[str]) - Write materialized result to specified table of format '{schema}.{table_name}'
  • timeout (Optional[int]) - set a timeout value for max time to poll for completion (0 for no timeout)
  • force (bool) - 'True' to ignore the current cache state and rerun the materialization

Observation Functions:#

list_queries(active_only, limit=None) -> Dict[str, Any]

Parameters:

  • active_only (bool) - 'True' to return active queries only
  • limit (Optional[int]) - max number of queries to return
# Returns a list of all metrics in a form of {<metric_name>: <Metric object>}list_metrics(model_key_id=None) -> Dict[str, Metric]

Parameters:

  • model_key_id (Optional[int]) - provide model key to perform action on a specific config
# Returns a single Metric object given a metric nameget_metric(metric_name, model_key_id=None) -> Metric

Parameters:

  • metric_name (str)
  • model_key_id (Optional[int]) - provide model key to perform action on a specific config
# Returns a list of all MQL servers within the organizationlist_servers() -> List[MQLServer]

Parameters:

  • No parameters required
# Returns a unique list of all dimensionlist_dimensions(model_key_id=None) -> Dict[str, Dimension] 

Parameters:

  • model_key_id (Optional[int]) - provide model key to perform action on a specific config
# Returns a list of all unique dimension values given a metric/dimension pairget_dimension_values(metric_name, dimension_name, model_key_id=None) -> List[str]

Parameters:

  • metric_name (str) - name of metric that has the dimension desired
  • dimension_name (str) - name of dimension to query values for
  • model_key_id (Optional[int]) - provide model key to perform action on a specific config
# Returns details on the latest MQL server imagelatest_mql_image() -> MQLServerImage

Parameters:

  • No parameters required
# Returns a UserState object that describes the authenticated useridentify() -> UserState

Parameters:

  • No parameters required
# Returns a response from pinging the selected MQL serverping() -> requests.Response

Parameters:

  • No parameters required
# Returns a detailed health report of each MQL server in the organizationhealth_report() -> List[ServerHealthReport]

Parameters:

  • No parameters required

Config Functions:#

# Commit yaml configs found in specified config directorycommit_configs(config_dir) -> ModelKey

Parameters:

  • config_dir (str) - path to directory containing Transform yaml models
# Validate yaml configs found in specified config directoryvalidate_configs(config_dir) -> Tuple[str, str, str]

Parameters:

  • config_dir (str) - path to directory containing Transform yaml models

Misc. Functions:#

# Drop the MQL cache. Only necessary if there is evidence cache corruptiondrop_cache()

Parameters:

  • No parameters required