Esempio n. 1
0
    def test_load_files(self):
        ks_fh = filehandler(self.db)
        ks_fh.reset()
        company_id = 1
        register_raw_files("./tests/data2/Sales.csv", company_id, self.db)
        register_raw_files("./tests/data2/Currencyv2.csv", company_id, self.db)
        register_raw_files("./tests/data2/CountryRegion.csv", company_id, self.db)
        register_raw_files("./tests/data2/ComissionTax.csv",company_id, self.db)

        ks_precompute = precompute(self.db)
        ks_precompute.reset()
        precompute
        ks_merge = merge(self.db)
        load_precompute_normalize(company_id, self.db)

        ks_fh.registerFormula("", "Plus", "Plus", "Units+RoyaltyPrice", "sum")
        ks_fh.registerFormula("", "Mult", "Mult", "Units*RoyaltyPrice", "sum")

        plus_id = ks_fh.getMeasureID("Plus")
        mult_id = ks_fh.getMeasureID("Mult")
        units_id = ks_fh.getMeasureID("Units")
        royality_id = ks_fh.getMeasureID("RoyaltyPrice")

        # MEASURE DATA DEMO raw_facts + measures with formulas
        print(measure_data(self.db, company_id, [plus_id,mult_id,units_id,royality_id],"day","2014-06-01","2014-06-01"))

        # MEASURE DATA DEMO raw_facts group by
        print(measure_data(self.db, company_id, [units_id, royality_id],"day","2014-06-01","2014-06-01","Region"))

        self.db.commit()
Esempio n. 2
0
 def get(self):
     _INSTANCE_NAME = 'ks-sqlengine:test'
     self.response.write("<p> Merge Demo </p>")
     if (os.getenv('SERVER_SOFTWARE') and
         os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')):
         db = MySQLdb.connect(unix_socket='/cloudsql/' + _INSTANCE_NAME, db='source', user='******')
     else:
         db = MySQLdb.connect(host='127.0.0.1', db='source', user='******', passwd='1193')
     #ks_merge = merge(db)
     #ks_merge.reset()
     #sales_blob_key = "AMIfv955UlTWfs9d8HWHPM6vPbnHKX_GiYzLREhpOSAlOzYXg-aO2fN0N2sugsJ15GeVRhISJmeTmpV5zlblU1gpkGcctwFH7ip4mg4eR18Y1hVLXNlvffj1ysaR3e4tdsoIkhFncmw9dpZ6eyP4E7xvy8KjjNEUtg"
     #cur_blob_key = "AMIfv959qauL3R-9UnuE9ox14Sic-IJwTx0zAD3qvDRCksANuuyXGz-W8amx5HbCC6iEsbK3igrvc-8CP6vZSy53mcZwXeDKRTYYwj4xTYs1sSGOwpHYV20twBsUhLcTcLwFgYC8sJ6DYFljXWpt64LzDWpcYNFalA"
     #country_blob_key = "AMIfv94wNLrpPOXsKChvzkpmJ5_HS6GZqQj0psFVhCCn_5CI-onYvZdmURUCaUv9vH_db8m9LtvzmJ0oz66_58wYR9rtvOPc7CIW3u7shECsIoLuZqWvMqcPColYizekx3wESBnYHUVfj1yZ3fH_mQfGIGSLD6iRbg"
     #com_blob_key = "AMIfv94--LDpjvIbXCGcSxpnixVXDtz4X1LURYZ31NUnSjvxEpACa4q4LUvnZaBzXfPPgg5LHlO-50VFOdeJbOs6T9lWdxjvogz2FbRVpOojqo2ZOaxMVrbDQjT37oXd8JveQD02Yf3WM63satu3JqmVYvU5duc29w"
     #ks_merge.addTableBlob(sales_blob_key,"Sales")
     #ks_merge.addTableBlob(cur_blob_key,"Currencyv2")
     #ks_merge.addTableBlob(country_blob_key,"CountryRegion")
     #ks_merge.addTableBlob(com_blob_key,"ComissionTax")
     #ks_merge.automaticMerge()
     
     ks_fh = filehandler(db)
     #ks_fh.reset()
     measures = ks_fh.getAllMeasures()
     self.response.write(measures)
     
     db.close()
Esempio n. 3
0
def register_raw_files(file_path, company_name, db):
    ks_fh = filehandler(db)
    file_name = os.path.basename(file_path)
    pre_fix, post_fix = file_name.split(".")
    table_name = pre_fix
    ks_fh.addTable(table_name, company_name, file_path)
    ks_fh.updateMeasureTable(file_path, company_name)
def load_precompute_normalize_URL(company_name, db):
    ks_fh = filehandler(db)
    rows = ks_fh.getLatestTablesByCompany(company_name)
    ks_merge = merge(db)
    ks_merge.reset()
    for row in rows:
        table_name =row[1]
        file_path = row[2]
        ks_merge.addTableURL(file_path, table_name)

    ks_merge.automaticMerge()

    mergeBigTable = ks_merge.getTables()
    ks_precompute = precompute(db)
    meta_data = ks_merge.getMetaDataFromTable(mergeBigTable[0])
    ks_precompute.reset()
    ks_precompute.addBigTable(meta_data,mergeBigTable[0],company_name)

    id = ks_precompute.getMaxBigTableIdForCompany(company_name)


    metaData = ks_merge.getMetaDataFromTable(mergeBigTable[0])

    ks_analytics = analytics(db)
    newBigTable = "BigTable"+ str(ks_precompute.getMaxBigTableIdForCompany(company_name))
    ks_analytics.reset()
    ks_analytics.addBigTable(mergeBigTable[0], newBigTable, metaData)
Esempio n. 5
0
    def setUpClass(cls):
        #----------------------
        # set up db
        #----------------------
        cls.db = MySQLdb.connect(
                ks_db_settings.setting('host'), 
                ks_db_settings.setting('user'), 
                ks_db_settings.setting('password'), 
                ks_db_settings.setting('database'))


        cls.ks_fh = filehandler(cls.db)
        cls.ks_fh.reset()
        cls.company_id = 1
        register_raw_files("./tests/data2/Sales.csv", cls.company_id, cls.db)
        register_raw_files("./tests/data2/Currencyv2.csv", cls.company_id, cls.db)
        register_raw_files("./tests/data2/CountryRegion.csv", cls.company_id, cls.db)
        register_raw_files("./tests/data2/ComissionTax.csv",cls.company_id, cls.db)
    
        ks_precompute = precompute(cls.db)
        ks_precompute.reset()
        precompute
        ks_merge = merge(cls.db)
        load_precompute_normalize_URL(cls.company_id, cls.db)


        
        id = ks_precompute.getMaxBigTableIdForCompany(cls.company_id)
        ks_merge = merge(cls.db)
        mergeBigTable = ks_merge.getTables()
        metaData = ks_merge.getMetaDataFromTable(mergeBigTable[0])
                
        cls.ks_analytics = analytics(cls.db)
        newBigTable = "BigTable"+ str(ks_precompute.getMaxBigTableIdForCompany(cls.company_id))
        cls.ks_analytics.reset()
        cls.ks_analytics.addBigTable(mergeBigTable[0], newBigTable, metaData)
        
        #clean up
        sql ="update %s set TaxRate = TaxRate/100;"%("analytics."+newBigTable)
        cls.db.cursor().execute(sql)
        # ProductType changed from D to M see documentation of test case
        sql ="update %s set ProductType = 'M' where VendorId='0268_20140114_SOFA_ENGLIS' and DownloadDate='6/1/14';"%("analytics."+newBigTable)
        cls.db.cursor().execute(sql)
        
        cls.ks_analytics.addFactUsingBinaryOpAPI("NET_REVENUE", "Units", "RoyaltyPrice", "*", newBigTable) 
        cls.ks_analytics.addFactUsingBinaryOpAPI("TAXES", "NET_REVENUE","TaxRate","*", newBigTable)
        cls.ks_analytics.addFactUsingBinaryOpAPI("REVENUE_AFTER_TAX", "NET_REVENUE","TAXES","-", newBigTable)
        
        
        cls.ks_fh.registerFormula("", "Plus", "Plus", "Units+RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "Mult", "Mult", "Units*RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "Individual_Tax", "Individual_Tax", "RoyaltyPrice*TaxRate", "sum")
        cls.ks_fh.registerFormula("", "NET_REVENUE", "NET_REVENUE", "Units*RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "SumPlus", "SumPlus", "Sum(Units)+Sum(RoyaltyPrice)", "sum")
        cls.ks_fh.registerFormula("", "SumMult", "SumMult", "Sum(Units)*Sum(RoyaltyPrice)", "sum")
        cls.ks_fh.registerFormula("", "Individual_TaxSum", "Individual_TaxSum", "Sum(RoyaltyPrice)*Sum(TaxRate)", "sum")
        cls.ks_fh.registerFormula("", "NonsenseSum", "Individual_Tax", "Sum(RoyaltyPrice)+Sum(TaxRate)", "sum")
        cls.ks_fh.registerFormula("", "Nonsense", "Individual_Tax", "RoyaltyPrice+TaxRate", "sum")
        cls.ks_fh.registerFormula("", "REVENUE_AFTER_TAX", "REVENUE_AFTER_TAX", "", "sum")
Esempio n. 6
0
    def setUpClass(cls):
        #----------------------
        # set up db
        #----------------------
        cls.db = ks_db_settings.connect()

        cls.ks_fh = filehandler(cls.db)
        cls.ks_fh.reset()
        cls.company_id = 1
        
        register_raw_filesCsvPy("Sales_new_version",cls.company_id, cls.db)
        register_raw_filesCsvPy("CurrencyV2",cls.company_id, cls.db)
        register_raw_filesCsvPy("ComissionTax_new_version",cls.company_id, cls.db)
        register_raw_filesCsvPy("CountryRegion",cls.company_id, cls.db)
                
        sql = 'update files set file_name = "./tests/data2/version/Sales.csv" where file_name = "./tests/data2/Sales.csv"'
        cls.db.cursor().execute(sql)
        sql = 'update files set file_name = "./tests/data2/version/ComissionTax.csv" where file_name = "./tests/data2/ComissionTax.csv"'
        cls.db.cursor().execute(sql)
    
    
        ks_precompute = precompute(cls.db)
        ks_precompute.reset()
        #precompute
        load_precompute_normalize_CsvPy(cls.company_id, cls.db)
        newBigTable = "BigTable"+ str(ks_precompute.getMaxBigTableIdForCompany(cls.company_id))
        cls.ks_analytics = analytics(cls.db)
        
        #clean up
        sql ="update %s set TaxRate = TaxRate/100;"%("analytics."+newBigTable)
        cls.db.cursor().execute(sql)
        # ProductType changed from D to M see documentation of test case
        sql ="update %s set ProductType = 'M' where VendorId='0268_20140114_SOFA_ENGLIS' and DownloadDate='6/1/14';"%("analytics."+newBigTable)
        cls.db.cursor().execute(sql)
        
        cls.ks_analytics.addFactUsingBinaryOpAPI("NET_REVENUE", "Units", "RoyaltyPrice", "*", newBigTable) 
        cls.ks_analytics.addFactUsingBinaryOpAPI("TAXES", "NET_REVENUE","TaxRate","*", newBigTable)
        cls.ks_analytics.addFactUsingBinaryOpAPI("REVENUE_AFTER_TAX", "NET_REVENUE","TAXES","-", newBigTable)
        
        
        cls.ks_fh.registerFormula("", "Plus", "Plus", "Units+RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "Mult", "Mult", "Units*RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "Individual_Tax", "Individual_Tax", "RoyaltyPrice*TaxRate", "sum")
        cls.ks_fh.registerFormula("", "NET_REVENUE", "NET_REVENUE", "Units*RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "SumPlus", "SumPlus", "Sum(Units)+Sum(RoyaltyPrice)", "sum")
        cls.ks_fh.registerFormula("", "SumMult", "SumMult", "Sum(Units)*Sum(RoyaltyPrice)", "sum")
        cls.ks_fh.registerFormula("", "Individual_TaxSum", "Individual_TaxSum", "Sum(RoyaltyPrice)*Sum(TaxRate)", "sum")
        cls.ks_fh.registerFormula("", "NonsenseSum", "Individual_Tax", "Sum(RoyaltyPrice)+Sum(TaxRate)", "sum")
        cls.ks_fh.registerFormula("", "Nonsense", "Individual_Tax", "RoyaltyPrice+TaxRate", "sum")
        cls.ks_fh.registerFormula("", "REVENUE_AFTER_TAX", "REVENUE_AFTER_TAX", "", "sum")
Esempio n. 7
0
    def get(self):
        _INSTANCE_NAME = 'ks-sqlengine:test'
        self.response.write("<p> API Demo </p>")
        if (os.getenv('SERVER_SOFTWARE') and
            os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')):
            db = MySQLdb.connect(unix_socket='/cloudsql/' + _INSTANCE_NAME, db='source', user='******')
        else:
            db = MySQLdb.connect(host='173.194.87.126', db='source', user='******', passwd='ZVYZM KMGYH')
        
        # reset DB
        ks_fh = filehandler(db)
        #ks_fh.reset()
        #ks_merge = merge(db)
        #ks_merge.reset()
        #ks_precompute = precompute(db)
        #ks_precompute.reset()
        
        company_id = "1"
        #sales_table = "AMIfv955UlTWfs9d8HWHPM6vPbnHKX_GiYzLREhpOSAlOzYXg-aO2fN0N2sugsJ15GeVRhISJmeTmpV5zlblU1gpkGcctwFH7ip4mg4eR18Y1hVLXNlvffj1ysaR3e4tdsoIkhFncmw9dpZ6eyP4E7xvy8KjjNEUtg"
        #currency_table = "AMIfv959qauL3R-9UnuE9ox14Sic-IJwTx0zAD3qvDRCksANuuyXGz-W8amx5HbCC6iEsbK3igrvc-8CP6vZSy53mcZwXeDKRTYYwj4xTYs1sSGOwpHYV20twBsUhLcTcLwFgYC8sJ6DYFljXWpt64LzDWpcYNFalA"
        #country_table = "AMIfv94wNLrpPOXsKChvzkpmJ5_HS6GZqQj0psFVhCCn_5CI-onYvZdmURUCaUv9vH_db8m9LtvzmJ0oz66_58wYR9rtvOPc7CIW3u7shECsIoLuZqWvMqcPColYizekx3wESBnYHUVfj1yZ3fH_mQfGIGSLD6iRbg"
        #comission_table = "AMIfv94--LDpjvIbXCGcSxpnixVXDtz4X1LURYZ31NUnSjvxEpACa4q4LUvnZaBzXfPPgg5LHlO-50VFOdeJbOs6T9lWdxjvogz2FbRVpOojqo2ZOaxMVrbDQjT37oXd8JveQD02Yf3WM63satu3JqmVYvU5duc29w"
        
        #register_raw_files2table(sales_table, company_id, "Sales", db)
        #register_raw_files2table(currency_table, company_id, "Currencyv2", db)
        #register_raw_files2table(country_table, company_id, "CountryRegion", db)
        #register_raw_files2table(comission_table, company_id, "ComissionTax", db)
        
        
        #load_precompute_normalize_blob(company_id, db)
        
        #self.response.write(measure_data(db, 1, [3,4],"day","0006-01-14","0006-01-14"))
        #self.response.write(measure_data(db, 1, [3,4],"day","0006-02-14","0006-02-14"))
        #self.response.write(measure_data(db, 1, [3,4],"day","0006-01-14","0006-02-14"))
        
        
        #self.response.write(measure_data(db, 1, [3,4],"day","0006-01-14","0006-02-14","Region"))
        #self.response.write(measure_data(db, 1, [3,4],"day","0006-01-14","0006-02-14","RightsHolder"))
        #self.response.write(measure_data(db, 1, [3,4],"day","0006-01-14","0006-02-14","CountryCode"))



        measure_id = ks_fh.getMeasureID("Units")
        measure_ids = []
        measure_ids.append(measure_id)
        result = measure_data(db, company_id, measure_ids, "day", "2014-06-01", "2014-06-01")
        self.response.write(result)
       
        db.close()
Esempio n. 8
0
    def setUpClass(cls):
        #----------------------
        # set up db
        #----------------------
        cls.db = ks_db_settings.connect()

        cls.ks_fh = filehandler(cls.db)
        cls.ks_fh.reset()
        cls.company_id = 1
        
        register_raw_filesCsvPy("Sales",cls.company_id, cls.db)
        register_raw_filesCsvPy("CurrencyV2",cls.company_id, cls.db)
        register_raw_filesCsvPy("ComissionTax",cls.company_id, cls.db)
        register_raw_filesCsvPy("CountryRegion",cls.company_id, cls.db)
    
        ks_precompute = precompute(cls.db)
        ks_precompute.reset()
        #precompute
        load_precompute_normalize_CsvPy(cls.company_id, cls.db)
        newBigTable = "BigTable"+ str(ks_precompute.getMaxBigTableIdForCompany(cls.company_id))
        cls.ks_analytics = analytics(cls.db)
        cls.ks_fh.registerFormula("", "UnitsSUM", "UnitsSUM", "sum(Units)", "sum")
    def setUpClass(cls):
        #----------------------
        # set up db
        #----------------------
        cls.db = ks_db_settings.connect()

        cls.ks_fh = filehandler(cls.db)
        cls.ks_fh.reset()
        cls.company_id = 1
        
        register_raw_filesCsvPy("Salesfreq",cls.company_id, cls.db)
        #register_raw_filesCsvPy("CurrencyV2",cls.company_id, cls.db)
        register_raw_filesCsvPy("ComissionTax",cls.company_id, cls.db)
        register_raw_filesCsvPy("CountryRegion",cls.company_id, cls.db)
    
        ks_precompute = precompute(cls.db)
        ks_precompute.reset()
        #precompute
        load_precompute_normalize_CsvPy(cls.company_id, cls.db)
        newBigTable = "BigTable"+ str(ks_precompute.getMaxBigTableIdForCompany(cls.company_id))
        cls.ks_analytics = analytics(cls.db)
        
        cls.ks_analytics.addFactUsingBinaryOpAPI("NET_REVENUE", "Units", "RoyaltyPrice", "*", newBigTable) 
        cls.ks_analytics.addFactUsingBinaryOpAPI("TAXES", "NET_REVENUE","TaxRate","*", newBigTable)
        cls.ks_analytics.addFactUsingBinaryOpAPI("REVENUE_AFTER_TAX", "NET_REVENUE","TAXES","-", newBigTable)
        
        
        cls.ks_fh.registerFormula("", "Plus", "Plus", "Units+RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "Mult", "Mult", "Units*RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "Individual_Tax", "Individual_Tax", "RoyaltyPrice*TaxRate", "sum")
        cls.ks_fh.registerFormula("", "NET_REVENUE", "NET_REVENUE", "Units*RoyaltyPrice", "sum")
        cls.ks_fh.registerFormula("", "SumPlus", "SumPlus", "Sum(Units)+Sum(RoyaltyPrice)", "sum")
        cls.ks_fh.registerFormula("", "SumMult", "SumMult", "Sum(Units)*Sum(RoyaltyPrice)", "sum")
        cls.ks_fh.registerFormula("", "Individual_TaxSum", "Individual_TaxSum", "Sum(RoyaltyPrice)*Sum(TaxRate)", "sum")
        cls.ks_fh.registerFormula("", "NonsenseSum", "Individual_Tax", "Sum(RoyaltyPrice)+Sum(TaxRate)", "sum")
        cls.ks_fh.registerFormula("", "Nonsense", "Individual_Tax", "RoyaltyPrice+TaxRate", "sum")
        cls.ks_fh.registerFormula("", "REVENUE_AFTER_TAX", "REVENUE_AFTER_TAX", "", "sum")
Esempio n. 10
0
 def getMeasureData(self, measure_ids, company_id, start_date, end_date):
     self.cursor.execute("use precompute")
     sql_version = "select max(big_table_version_id) from ks_fact where company_id = %s"%(company_id)
     self.cursor.execute(sql_version)
     rows = self.cursor.fetchall()
     row = rows[0]
     version = row[0]
     data = {}
     for measure_id in measure_ids:
         ks_fh = filehandler(self.db)
         measure_data = ks_fh.getMeasureDataByID(measure_id)
         if len(measure_data["formula"])>0:
             formula_data = {}
             formula_tree = parse(measure_data["formula"])
             facts = tree_names(formula_tree)
             formula_data["op"] = formula_tree[0]
             formula_data["rhs"] = ks_fh.getMeasureID(list(facts)[0])
             formula_data["lhs"] = ks_fh.getMeasureID(list(facts)[1])
             formula_data["agg_type"] = measure_data["agg_type"]
             data[measure_id] = self.getRawDataFormula(formula_data,version,  measure_id, start_date, end_date)
             
         else:
             data[measure_id] = self.getRawData(version, measure_id, start_date, end_date)
     return data
Esempio n. 11
0
 def __init__(self,db):
     self.db = db
     self.cursor = self.db.cursor()
     self.ks_fh = filehandler(db)
Esempio n. 12
0
from load_precompute_normalize import load_precompute_normalize_CsvPy


def MeasureName2MeasureIds(name):
        measure_id = ks_fh.getMeasureID(name)
        measure_ids = []
        measure_ids.append(measure_id)
        return measure_ids


#----------------------
# set up db
#----------------------
db = ks_db_settings.connect()

ks_fh = filehandler(db)
ks_fh.reset()
company_id = 1

register_raw_filesCsvPy("Sales",company_id, db)
register_raw_filesCsvPy("CurrencyV2",company_id, db)
register_raw_filesCsvPy("ComissionTax",company_id, db)
register_raw_filesCsvPy("CountryRegion",company_id, db)

ks_precompute = precompute(db)
ks_precompute.reset()
#precompute
load_precompute_normalize_CsvPy(company_id, db)
newBigTable = "BigTable"+ str(ks_precompute.getMaxBigTableIdForCompany(company_id))
ks_analytics = analytics(db)
Esempio n. 13
0
def registerFormula(company_id, formula_name, alias, formula, db, agg_type):
    ks_fh = filehandler(db)
    ks_fh.registerFormula(company_id, formula_name, alias, formula, agg_type)
Esempio n. 14
0
def register_raw_filesCsvPy(table_name, company_name, db):
    ks_fh = filehandler(db)
    ks_fh.addTable(table_name, company_name, table_name)
    ks_fh.updateMeasureTableCsvPy(table_name, company_name)
Esempio n. 15
0
def register_raw_files2table(file_path, company_name, table_name, db):
    ks_fh = filehandler(db)
    ks_fh.addTable(table_name, company_name, file_path)
    ks_fh.updateMeasureTableBlob(file_path, company_name)
Esempio n. 16
0
 def test_precompute(self):
     ks_fh = filehandler(self.db)
     # ks_fh.reset()
     company = "company 1"
     first_table = "./tests/data2/Sales.csv"
     ks_fh.updateMeasureTable(first_table, company)
Esempio n. 17
0
    def setUpClass(cls):
        #----------------------
        # set up db
        #----------------------
        cls.db = MySQLdb.connect(
                ks_db_settings.setting('host'), 
                ks_db_settings.setting('user'), 
                ks_db_settings.setting('password'), 
                ks_db_settings.setting('database'))


        #----------------------
        # filehandler
        #----------------------
        file_handler = filehandler(cls.db)
        file_handler.reset()
        file_handler.addTable("Sales", "1","Sales.csv")
        file_handler.addTable("Sales", "2","SalesCustomerTwo.csv")

        file_handler.addTable("ComissionTax", "1","ComissionTax.csv")
        file_handler.addTable("ComissionTax","2","ComissionTaxCustomerTwo.csv")

        file_handler.addTable("CountryRegion", "1","CountryRegion.csv")
        file_handler.addTable("CountryRegion","2","CountryRegionCustomerTwo.csv")

        file_handler.addTable("Currency2","1","Currencyv2.csv")
        time.sleep(1)
        file_handler.addTable("Sales", "1","SalesNewVersion.csv")
        print(file_handler.getLatestTable("Sales", "2"))

        #----------------------
        # merge
        #----------------------
        ks_merge = merge(cls.db)
        ks_merge.reset()
        ks_merge.addTable("./ks_filehandler/ks_filehandler/data/Sales.csv","Sales")
        ks_merge.addTable("./ks_filehandler/ks_filehandler/data/CountryRegion.csv","CountryRegion")
        ks_merge.addTable("./ks_filehandler/ks_filehandler/data/ComissionTax.csv","ComissionTax")
        sql_BigTable = "CREATE TABLE BigTable(id INT PRIMARY KEY AUTO_INCREMENT, \
             VendorId VARCHAR(25), \
             ProductType VARCHAR(25), \
             Units FLOAT, \
             RoyaltyPrice FLOAT, \
             DownloadDate VARCHAR(25), \
             CustomerCurrency VARCHAR(25), \
             CountryCode VARCHAR(25), \
             Region VARCHAR(25), \
             RightsHolder VARCHAR(25), \
             ComissionRate VARCHAR(25), \
             TaxRate VARCHAR(25))"
        

        sql_join = "insert into BigTable select S.id,S.VendorId,S.ProductType, "\
            "S.Units, S.RoyaltyPrice, S.DownloadDate, S.CustomerCurrency, "\
            "S.CountryCode, C.Region, T.RightsHolder, T.ComissionRate, "\
            "T.TaxRate from Sales S Inner Join CountryRegion C on "\
            "S.CountryCode=C.CountryCode Inner join ComissionTax T on " \
            "S.VendorId = T.VendorId and C.Region = T.Region;"
            
        ks_merge.join(sql_join, sql_BigTable)
        
        #----------------------
        # clean up
        #----------------------
        cursor = cls.db.cursor()
        sql = "use merge;"
        cursor.execute(sql)        
        sql = "ALTER TABLE BigTable change ComissionRate ComissionRate FLOAT;"
        cursor.execute(sql)
        sql = "ALTER TABLE BigTable change TaxRate TaxRate FLOAT;"
        cursor.execute(sql)
        sql ="update BigTable set TaxRate = TaxRate/100;"
        cursor.execute(sql)
        
        
        #----------------------
        # analytics
        #----------------------
        cls.ks_analytics = analytics(cls.db)
        cls.ks_analytics.addFactUsingBinaryOp("NET_REVENUE", "Units", "RoyaltyPrice", "*") 
        cls.ks_analytics.addFactUsingBinaryOp("TAXES", "NET_REVENUE","TaxRate","*")
        cls.ks_analytics.addFactUsingBinaryOp("REVENUE_AFTER_TAX", "NET_REVENUE","TAXES","-")