cube-js/cube

Support `compareDateRange` for data blending queries

Open

#2,380 opened on 2021年3月16日

GitHub で見る
 (3 comments) (0 reactions) (0 assignees)Rust (19,563 stars) (1,965 forks)batch import
backend:serverhelp wanted

説明

Bug Description

I'm using a react client to send in queries with the useCubeQuery hook to pass a query object. It has been working great so far. But as of last week, a need to blend data from 2 databases arose. As i learned, this is easily possible configuring a second cube to access the other database, while also passing in not a query object, but an array of query objects to the useCubeQuery call. Which is an awesome feature!

The problem is: any query that has a 'compareDateRange' property as a timeDimension range does not apply the range when generating the SQL statement.

So, let's say we have these 2 queries passed in:

[
  {
    "measures": [
      "TABLE.count"
    ],
    "dimensions": [],
    "segments": [],
    "timeDimensions": [
      {
        "dimension": "TABLE.dateStart",
        "granularity": "day",
        "compareDateRange": [
          [
            "2020-02-02T00:00",
            "2020-02-08T23:59"
          ]
        ]
      }
    ],
    "filters": [
      {
        "dimension": "TABLE.country",
        "operator": "equals",
        "values": [
          "1"
        ]
      }
    ],
    "timezone": "RELEVANT_TMZ"
  },
  {
    "measures": [
      "TABLE.count"
    ],
    "dimensions": [],
    "timeDimensions": [
      {
        "dimension": "TABLE.dateStart",
        "granularity": "day",
        "dateRange": [
          "2020-02-09T00:00",
          "2020-02-09T23:59"
        ]
      }
    ],
    "filters": [
      {
        "dimension": "TABLE.country",
        "operator": "equals",
        "values": [
          "1"
        ]
      }
    ],
  "timezone": "RELEVANT_TMZ"
  }
]

This will generate 2 SQL queries, one for each object. The problem is: the first query will not have the appropriate time range applied, while the second will. And if we pass in both objects with the compareDateRange attribute, neither will apply the appropriate range.

To Reproduce

Steps to reproduce the behavior:

  1. Call in a datablending query using an array of queries, making sure you pass in compareDateRange as your range on timeDimensions
  2. Observe the generated query - it will not have the seleted range generation.

Expected behavior Cube would generate the query with the correct time range applications and return a resultSet much like the one it returns when we pass in one query using the compareDateRange attribute.

Version:

  "@cubejs-backend/athena-driver": "^0.26.38",
  "@cubejs-backend/cubestore-driver": "^0.26.44",
  "@cubejs-backend/mysql-driver": "^0.26.45",
  "@cubejs-backend/server": "^0.26.44",

コントリビューターガイド