fusetools.analytics_tools.SQL

class fusetools.analytics_tools.SQL[source]

Bases: object

Functions for running analytical SQL operations

Methods

sql_rs_wow_comp

Performs a week over week comparison.

sql_rs_yoy_cum_comp

Performs a cumulative aggregation over the year as well as provided dimensional columns OR if agg_func param is not provided.

classmethod sql_rs_wow_comp(tbl_name, time_col, fact_cols, dim_cols=False, date_join_tbl=False, date_join_col=False, date_join_time_start_col=False, date_join_time_end_col=False)[source]

Performs a week over week comparison.

Parameters
  • tbl_name – Table with data to perform calculation on

  • time_col – Column with sub-year time granularity to compare across years

  • fact_cols – List of KPI columns to calculate

  • dim_cols – List of dimensional columns to compare aggregation over (optional)

  • date_join_tbl – Table with date columns to join to (optional)

  • date_join_col – Column from date table to join on (optional)

  • date_join_time_start_col – Column from date table with time granularity start date

  • date_join_time_end_col – Column from date table with time granularity end date

Returns

Analytical SQL query

classmethod sql_rs_yoy_cum_comp(tbl_name, time_col, year_col, fact_cols, agg_func=False, dim_cols=False, date_join_tbl=False, date_join_col=False, date_join_time_start_col=False, date_join_time_end_col=False)[source]

Performs a cumulative aggregation over the year as well as provided dimensional columns OR if agg_func param is not provided.

Parameters
  • tbl_name – Table with data to perform calculation on

  • time_col – Column with sub-year time granularity to compare across years

  • year_col – Column with year time granularity

  • fact_cols – List of KPI columns to calculate

  • agg_func – Type of aggregation to perform, if not provided will just do a snapshot of current week vs current week

  • dim_cols – List of dimensional columns to compare aggregation over (optional)

  • date_join_tbl – Table with date columns to join to (optional)

  • date_join_col – Column from date table to join on (optional)

  • date_join_time_start_col – Column from date table with time granularity start date

  • date_join_time_end_col – Column from date table with time granularity end date

Returns

Analytical SQL query