【问题标题】:implementing Python OLAP cube with multiple storage实现具有多个存储的 Python OLAP 多维数据集
【发布时间】:2015-10-07 04:28:32
【问题描述】:

我有两个表在两个不同的数据库中,如下所示。我想使用

来实现这个场景

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"])

我得到错误 no such table customer_details

【问题讨论】:

    标签: python olap olap-cube


    【解决方案1】:

    其实你那边写的表名是

    Table name: Customer_details
    

    对于您在 model.json 中编写的尺寸

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

    大小写可以解决你的问题..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      相关资源
      最近更新 更多