# Path: regenesis/core.py
# def get_catalog(catalog_name):
# 
# Path: regenesis/database.py
# def get_fact_table(cube_name):
# def load_cube(cube, update=False):
# 
# Path: regenesis/queries.py
# def get_cubes(cube_name=None):
#     ct = cube_table.table.alias('cube')
#     st = statistic_table.table.alias('statistic')
#     q = ct.join(st, st.c.name==ct.c.statistic_name)
#     q = q.select(use_labels=True)
#     if cube_name is not None:
#         q = q.where(ct.c.name==cube_name)
#     return list(engine.query(q))
# 
# def get_dimensions(cube_name):
#     rt = reference_table.table.alias('ref')
#     dt = dimension_table.table.alias('dim')
#     q = rt.join(dt, rt.c.dimension_name==dt.c.name)
#     q = q.select(use_labels=True)
#     q = q.where(rt.c.cube_name==cube_name)
#     res = engine.query(q)
#     return list(res)


from pprint import pprint 
from regenesis.core import app, engine
from regenesis.database import statistic_table, cube_table, reference_table
from regenesis.queries import get_cubes, get_dimensions


def find_denormalized():
    res = {}
    for cube in get_cubes():
        statistic = cube.get('statistic_name')
        if not statistic in res:
            res[statistic] = {}
        cube_name = cube.get('cube_name')

# Path: regenesis/core.py
# def get_catalog(catalog_name):
# 
# Path: regenesis/database.py
# def get_fact_table(cube_name):
# def load_cube(cube, update=False):
# 
# Path: regenesis/queries.py
# def get_cubes(cube_name=None):
#     ct = cube_table.table.alias('cube')
#     st = statistic_table.table.alias('statistic')
#     q = ct.join(st, st.c.name==ct.c.statistic_name)
#     q = q.select(use_labels=True)
#     if cube_name is not None:
#         q = q.where(ct.c.name==cube_name)
#     return list(engine.query(q))
# 
# def get_dimensions(cube_name):
#     rt = reference_table.table.alias('ref')
#     dt = dimension_table.table.alias('dim')
#     q = rt.join(dt, rt.c.dimension_name==dt.c.name)
#     q = q.select(use_labels=True)
#     q = q.where(rt.c.cube_name==cube_name)
#     res = engine.query(q)
#     return list(res)


# Path: regenesis/analysis.py
from pprint import pprint 
from regenesis.core import app, engine
from regenesis.database import statistic_table, cube_table, reference_table
from regenesis.queries import get_cubes, get_dimensions



def find_denormalized():
    res = {}
    for cube in get_cubes():
        statistic = cube.get('statistic_name')
        if not statistic in res:
            res[statistic] = {}
        cube_name = cube.get('cube_name')

        dimensions = get_dimensions(cube_name)