Insight Functions

Insight functions provide the syntax and descriptions of the classes, methods, attributes, and parameters of the application programming interface to the Insight tool in Data Studio suite of tools. Generation of insight is performed in background and requires checking for the completion.

Get Request List Procedure

Returns the list of request names and their parameters

Syntax

Insight.get_request_list(owner)

Parameters:

  • owner: This field displays the owner of the object. If this field is missing, the tool uses the current schema owner.

Example

In this example, you can list jobs of insights:

adp.Insight.get_request_list()
 
// Output
 
 [
  ... 
  {
    "owner": "ADMIN",
    "request_name": "REQUEST_INSIGHT_1",
    "request_type": "TABLE_INSIGHT",
    "source_object": "SALES",
    "source_owner": "ADMIN",
    "request_metadata": "{\"targets\":[\"ACTUAL\"],\"appName\":\"INSIGHTS\"}",
    "created": "2022-10-31T08:03:26.634Z",
    "updated": "2022-10-31T08:03:26.634Z",
    "request_job_setting": "{\"EXTRACTION\":{\"selectionRule\":{\"value\":\"MAX_DIFFERENCE\"},\"fittedShareConvergence\":{\"value\":\"LAX\"},\"maxNumExtractionDims\":{\"value\":10000},\"insightValueType\":{\"value\":\"MEMBER\"},\"excludeZero\":{\"value\":\"YES\"},\"minXAxisCount\":{\"value\":2}},\"sessionId\":null,\"applicationName\":\"INSIGHTS\",\"insightTypes\":[\"FITTED_SHARE_COMPARISON\"]}",
    "max_num_insights": 20
  },
  ...
]
Get Insight List Procedure

Returns the list of insights. Each insight has the following fields: insight_name, visualization_id, insight_column, insight_value, insight_dimension, dimension

Syntax

Insight.get_insights_list(request_name)

Parameters:

  • request_name: The name of the request.

Example

In this example, you can list insights:

adp.Insight.get_insights_list('REQUEST_INSIGHT_1')
 
// Output:
[
  {
    "insight_name": "INSIGHT_62",
    "visualization_id": 199,
    "insight_column": "ACTUAL",
    "insight_value": "COUNTRY.2",
    "insight_dimension": "COUNTRY",
    "dimension": "FORECST"
  },..
]
Drop Insight Procedure

Drop insight request

Syntax
Insight.drop(request_name)

Parameters:

  • request_name: The name of the request.

Example

In this example, you can drop the request:
adp.Insight.drop('REQUEST_INSIGHT_1')
Generate Insight Procedure

Generate insight of the measure for the Analytic view.

Syntax

Insight.generate(av_name, measure, job_owner,
                      source_owner)

Parameters:

  • av_name: The name of the Analytic View.
  • measure: The measure.
  • job_owner: This field displays the owner of the job. If this field is missing, the tool uses the current schema owner.
  • source_owner: This field displays the owner of the object. If this field is missing, the tool uses the current schema owner.

Example

In this example, you can generate insights for the Analytic View:
adp.Insight.generate('COSTS_AV', 'UNIT_COST')
 
// Output
 {
  "object_owner": "ADMIN",
  "request_name": "REQUEST_INSIGHT_1",
  "max_insight_count": 20,
  "source_object": "COSTS_AV",
  "source_owner": "COSTS_AV",
  "request_metadata": "{\"targets\":[\"UNIT_COST\"],\"appName\":\"INSIGHTS\"}",
  "default_job_settings": "{\"insightTypes\":[\"FITTED_SHARE_COMPARISON\"]}",
  "new_request": "true"
}
Get Job Status

Get the status of the job specified be Request Name. The generation of insights is finished when field insight_job_status is COMPLETED.

Syntax

Insight.get_job_status(request_name, owner)

Parameters:

  • request_name: The name of Request.
  • owner: This field displays the owner of the object. If this field is missing, the tool uses the current schema owner.

Example

In this example, you can display job status:

adp.Insight.get_job_status('REQUEST_INSIGHT_1')
 
// Output
{
  "insight_job_status": "COMPLETED",
  "progress_msg": " ",
  "error_msg": null
}
Get Graph Details Procedure

Returns json dictionary of data that may be plotted.

Results consists of two fields:

item contains overall information from the insight: description, XAXIS, measure, insight_type_label, visualization_condition, source_object

query contains information for plotting and has three lists: labels, actuals and estimates

Syntax
Insight.get_graph_details(name, id, count, query_manipulation,
                          owner)

Parameters:

  • name: The name of the Insight.
  • id: The visualization id.
  • count: number of displayed values
  • query_manipulation: If it is not None, add cursor type and grand totals fields to the query.
  • owner: This field displays the owner of the object. If this field is missing, the tool uses the current schema owner.

Example

In this example, you can get data to plot the graph:

adp.Insight.get_graph_details("INSIGHT_62", 199, 5, True)
 
 Output:
{
  "items": {
    "description": "COUNTRY.2",
    "XAXIS": "FORECST",
    "measure": "ACTUAL",
    "insight_type_label": "Expected",
    "visualization_condition": "COUNTRY.2",
    "source_object": "C0"
  },
  "query": {
    "labels": [
      "01:[66.7-1590]",
      "02:[829-2350]",
      "04:[2350-3870]",
      "06:[3870-5390]",
      "07:[4630-6150]"
    ],
    "actuals": [
      2200,
      6200,
      24600,
      26600,
      14200
    ],
    "estimates": [
      2671.105013588167,
      4830.820533674098,
      7135.506976989193,
      24772.963909661587,
      22121.48462234561
    ]
  }
}