开发者社区> 问答> 正文

Python多维数据集Olap Framework日期PointCut

所以我试图用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"
                }
            ]
        }

    ]
}

如果我尝试在切片机上做一个日期的poincut

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吗?

展开
收起
祖安文状元 2020-02-22 17:50:59 601 0
1 条回答
写回答
取消 提交回答
  • 我发现向模型中的日期添加更多信息可以解决问题:

    {
        "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"]
    
            }
        ]
    }
    
    2020-02-22 17:51:06
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载