gpt4 book ai didi

Python Cubes Olap 框架 Date PointCut

转载 作者:太空宇宙 更新时间:2023-11-03 15:11:27 25 4
gpt4 key购买 nike

所以我正在尝试使用 Python Cubes Framework 实现一些 BI,但我遇到了一些问题。

基本上我正在尝试做一个“简单的”PointCut/切片和骰子,但我没有任何运气。我在 PostGis 中使用 PostgreSQL 数据库。

我的 model.json 是:

{
"dimensions": [
{"name": "user", "attributes": ["id", "username"]},
{"name": "resources", "attributes": ["id", "resource_simple_name"]},
{"name":"created_on", "role": "time"}
],
"cubes": [
{
"name": "users_resources_likes",
"dimensions": ["user", "resources", "created_on"],
"mappings": {
"user.id": "auth_user.id",
"user.username": "auth_user.username",
"resources.id": "resources.id",
"resources.resource_simple_name": "resources.resource_simple_name",
"created_on": "created_on"
},
"joins": [
{
"master": "user_id",
"detail": "auth_user.id"
},
{
"master": "resource_id",
"detail": "resources.id"
}
]
}

]
}

如果我尝试在切片器上做一个带日期的切入点

aggregate?drilldown=created_on&cut=created_on:2012

我得到一个DataError: (DataError) invalid input syntax for type timestamp with time zone: "2012"

搜索了一段时间后,我了解到这可能是因为我的 postgresql 数据库有一个时间戳:

created_on timestamp with time zone NOT NULL DEFAULT '2014-02-10 00:00:00+00'::timestamp with time zone,

所以我尝试这样做:

?drilldown=created_on&cut=created_on:2012-09-15T09:37:59+00:00

我得到一个:

{
error: "unknown_user_error",
message: "Wrong dimension cut string: 'created_on:2012-09-15T09:37:59 00:00'"
}

我做错了什么?我的 model.json 有问题吗?

最佳答案

我发现在模型中向日期添加更多信息可以解决问题:

    {
"name": "created_on",
"label": "Date Created",
"role": "time",
"info": {
"cv-datefilter": true,
"cv-datefilter-hierarchy": "weekly"
},
"levels": [
{
"name":"year",
"label":"Year",
"info": { "cv-datefilter-field": "year" }
},
{
"name":"quarter",
"label":"Quarter"
},
{
"name":"month",
"label":"Month"
},
{
"name":"week",
"label":"Week",
"info": { "cv-datefilter-field": "week" }
}
],
"hierarchies": [
{
"name": "weekly",
"label": "Weekly",
"levels": [ "year", "week"]
},
{
"name": "monthly",
"label": "Monthly",
"levels": [ "year", "quarter", "month"]

}
]
}

和映射:

        "mappings": {
"created_on.year": {"column":"created_on", "extract":"year"},
"created_on.month": {"column":"created_on", "extract":"month"},
"created_on.week": {"column":"created_on", "extract":"week"},
"created_on.day": {"column":"created_on", "extract":"day"},
"created_on.quarter": {"column":"created_on", "extract":"quarter"}
}

关于Python Cubes Olap 框架 Date PointCut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26058844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com