2015-10-07 77 views
1

我有兩個表在兩個不同的數據庫如下所示。我想實現這個場景使用實現Python OLAP多維數據集存儲

Python OLAP立方體來獲得下面提到的輸出。

DB1 

Table name: Customer_details  

id name 

1 abc 

2 xyz 

DB 2 

Table Name : Bills 

id Customer_id amount 

1 1    500 

2 1    600 

3 2    300 

Output 

Name  Amount 

abc  1100 

xyz  300 

下面是一些代碼,我使用的是解決這個問題:

{ 
    "dimensions": [ 
     { 
      "name":"customer_details", 
      "levels":[ 
       { 
        "name":"customer", 
        "label":"Customer", 
        "attributes": ["id","name"]  
       } 

      ] 

     } 
    ], 
    "cubes": [ 
     { 
      "name": "bills", 
      "dimensions": ["customer_details"], 
      "measures": [ 
       {"name":"amount", "label":"Total"} 
      ], 
      "aggregates": [ 
        { 
         "name": "total", 
         "function": "sum", 
         "measure": "amount" 
        } 
       ], 
      "joins":[ 
       {"master":"bills.customer_id", "detail":"customer_details.id"}     
      ], 
      "mappings": { 
       "name": "customer_details.name"     
      } 
     } 
    ] 
} 




workspace = Workspace() 
workspace.register_store("store1", "sql", url="postgresql://...") 
workspace.register_store("store2", "sql", url="postgresql://...") 

workspace.import_model("model.json"), store="store1", namespace="default") 
workspace.import_model("model.json"), store="store2", namespace="default") 

browser = workspace.browser("bills") 
cubeData = browser.aggregate(drilldown=["customer_details"]) 

我沒有得到任何這樣的表customer_details

回答

0

其實你已經寫在那裏,表名是

錯誤
Table name: Customer_details 

對於您在model.json中編寫的尺寸

.."name":"customer_details", ... 

大小寫都可以解決您的問題..

相關問題