lux.executor.SQLExecutor.SQLExecutor

class lux.executor.SQLExecutor.SQLExecutor[source]

Given a Vis objects with complete specifications, fetch and process data using SQL operations.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__() Initialize self.
compute_data_model(data_type)
compute_data_model_lookup(data_type)
compute_data_type(tbl) Function which the equivalent Pandas data type of each variable within the specified Lux DataFrame’s SQL table.
compute_dataset_metadata(tbl) Function which computes the metadata required for the Lux recommendation system.
compute_stats(tbl) Function which computes the min and max values for each variable within the specified Lux DataFrame’s SQL table.
create_where_clause([view])
execute(view_collection, tbl, approx) Given a VisList, fetch the data required to render the view 1) Generate Necessary WHERE clauses 2) Query necessary data, applying appropriate aggregation for the chart type 3) populates vis’ data with a DataFrame with relevant results
execute_2D_binning(view, tbl) Apply 2D binning (heatmap) to vis.data
execute_aggregate(view, tbl[, isFiltered]) Aggregate data points on an axis for bar or line charts :param vis: lux.Vis object that represents a visualization :type vis: lux.Vis :param tbl: LuxSQLTable with specified intent.
execute_binning(view, tbl) Binning of data points for generating histograms :param vis: lux.Vis object that represents a visualization :type vis: lux.Vis :param tbl: LuxSQLTable with specified intent.
execute_filter(view) Helper function to convert a Vis’ filter specification to a SQL where clause.
execute_preview(tbl[, preview_size])
execute_sampling(tbl)
execute_scatter(view, tbl) Given a scatterplot vis and a Lux Dataframe, fetch the data required to render the vis.
get_SQL_attributes(tbl) Retrieves the names of variables within a specified Lux DataFrame’s Postgres SQL table.
get_cardinality(tbl) Function which computes the cardinality for each variable within the specified Lux DataFrame’s SQL table.
get_filtered_size(tbl)
get_unique_values(tbl) Function which collects the unique values for each variable within the specified Lux DataFrame’s SQL table.
invert_data_type(data_type)
mapping(rmap)
reverseMapping(map)
compute_data_type(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which the equivalent Pandas data type of each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
compute_dataset_metadata(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which computes the metadata required for the Lux recommendation system. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
compute_stats(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which computes the min and max values for each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
static execute(view_collection: lux.vis.VisList.VisList, tbl: lux.core.sqltable.LuxSQLTable, approx: bool = False)[source]

Given a VisList, fetch the data required to render the view 1) Generate Necessary WHERE clauses 2) Query necessary data, applying appropriate aggregation for the chart type 3) populates vis’ data with a DataFrame with relevant results

static execute_2D_binning(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable)[source]

Apply 2D binning (heatmap) to vis.data

static execute_aggregate(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable, isFiltered=True)[source]

Aggregate data points on an axis for bar or line charts :param vis: lux.Vis object that represents a visualization :type vis: lux.Vis :param tbl: LuxSQLTable with specified intent. :type tbl: lux.core.frame :param isFiltered: boolean that represents whether a vis has had a filter applied to its data :type isFiltered: boolean

Returns:
Return type:None
static execute_binning(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable)[source]

Binning of data points for generating histograms :param vis: lux.Vis object that represents a visualization :type vis: lux.Vis :param tbl: LuxSQLTable with specified intent. :type tbl: lux.core.frame

Returns:
Return type:None
static execute_filter(view: lux.vis.Vis.Vis)[source]

Helper function to convert a Vis’ filter specification to a SQL where clause. Takes in a Vis object and returns an appropriate SQL WHERE clause based on the filters specified in the vis’ _inferred_intent.

Parameters:vis (lux.Vis) – lux.Vis object that represents a visualization
Returns:
  • where_clause (string) – String representation of a SQL WHERE clause
  • filter_vars (list of strings) – list of variables that have been used as filters
static execute_scatter(view: lux.vis.Vis.Vis, tbl: lux.core.sqltable.LuxSQLTable)[source]

Given a scatterplot vis and a Lux Dataframe, fetch the data required to render the vis. 1) Generate WHERE clause for the SQL query 2) Check number of datapoints to be included in the query 3) If the number of datapoints exceeds 10000, perform a random sample from the original data 4) Query datapoints needed for the scatterplot visualization 5) return a DataFrame with relevant results

Parameters:
  • vislist (list[lux.Vis]) – vis list that contains lux.Vis objects for visualization.
  • tbl (lux.core.frame) – LuxSQLTable with specified intent.
Returns:

Return type:

None

get_SQL_attributes(tbl: lux.core.sqltable.LuxSQLTable)[source]

Retrieves the names of variables within a specified Lux DataFrame’s Postgres SQL table. Uses these variables to populate the Lux DataFrame’s columns list.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose columns will be populated
Returns:
Return type:None
get_cardinality(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which computes the cardinality for each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None
get_unique_values(tbl: lux.core.sqltable.LuxSQLTable)[source]

Function which collects the unique values for each variable within the specified Lux DataFrame’s SQL table. Populates the metadata parameters of the specified Lux DataFrame.

Parameters:tbl (lux.LuxSQLTable) – lux.LuxSQLTable object whose metadata will be calculated
Returns:
Return type:None