我在两个不同的数据库中有两个表 ,如下所示。我想使用
实现这个场景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 :(得分:0)
实际上你已经在那里写过表名是
Table name: Customer_details
对于你在model.json中写的尺寸
.."name":"customer_details", ...
大小写可以解决你的问题..