cube icon indicating copy to clipboard operation
cube copied to clipboard

graphQL 、 RestFul ===》 Query different(timezone: "Asia/Shanghai")。

Open TaoPanfeng opened this issue 1 year ago • 2 comments

Problem graphQL 、 RestFul ===》 Query different(timezone: "Asia/Shanghai")。 The return time is inconsistent: for example: rest "store.stats_date":"2023-05-10T00:00:00.000" graphQL "stats_date":{"value":"2023-05-09T16:00:00.000Z"}

How do I get them back on the same page, like the REST?


** rest **

{
  "measures": [
    "store.sales_qty"
  ],
  "order": {
    "store.sales_qty": "desc"
  },
  "dimensions": [
    "store.store_id",
    "store.stats_date"
  ],
  "timezone": "Asia/Shanghai",
  "filters": [
    {
      "member": "store.store_id",
      "operator": "equals",
      "values": [
        "1668"
      ]
    },
    {
      "member": "store.stats_date",
      "operator": "inDateRange",
      "values": [
        "2023-05-10",
        "2023-05-11"
      ]
    }
  ]
}





"data":[{"store.store_id":"1668","store.stats_date":"2023-05-10T00:00:00.000","store.sales_qty":"12"},{"store.store_id":"1668","store.stats_date":"2023-05-11T00:00:00.000","store.sales_qty":"10"}]

** graphQL **

query CubeQuery  { 
  cube(
    where: {store: {store_id: {equals: 1668 } , stats_date: {inDateRange: ["2023-05-10", "2023-05-11"]}}}
    timezone: "Asia/Shanghai"
  ) {
    store(orderBy: {sales_qty: desc}) {
      sales_qty
      store_id
      stats_date {
        value
      }
    }
  }
}



{"data":{"cube":[{"store":{"sales_qty":12,"store_id":1668,"stats_date":{"value":"2023-05-09T16:00:00.000Z"}}},{"store":{"sales_qty":10,"store_id":1668,"stats_date":{"value":"2023-05-10T16:00:00.000Z"}}}]}}

TaoPanfeng avatar Jan 08 '24 03:01 TaoPanfeng

Hey @TaoPanfeng, could you please try to use timeDimensions for the REST API query format? Cube will automatically convert timezones for timeDimensions fields in queries.

igorlukanin avatar Jan 08 '24 13:01 igorlukanin

It's been a week. Please, look at this problem. (已经过去一周了,求求您,看一下这个问题。)

https://github.com/cube-js/cube/issues/7666

TaoPanfeng avatar Jan 25 '24 11:01 TaoPanfeng