cube icon indicating copy to clipboard operation
cube copied to clipboard

Allow Data Blending with matching dateRange and empty `granularities`

Open rongfengliang opened this issue 4 years ago • 10 comments

Problem

from docs && source code i known cube.js support Data Blending .but current has one limit must contains granularities(gateway source code ) i think this maybe not necessary. offen we need run multi query with one request. if delete this limit query maybe more flexible. (delete gateway code from 380-389)

protected async getNormalizedQueries(query, context: RequestContext): Promise<any> {
    query = this.parseQueryParam(query);
    let queryType = QUERY_TYPE.REGULAR_QUERY;

    if (!Array.isArray(query)) {
      query = this.compareDateRangeTransformer(query);
      if (Array.isArray(query)) {
        queryType = QUERY_TYPE.COMPARE_DATE_RANGE_QUERY;
      }
    } else {
      queryType = QUERY_TYPE.BLENDING_QUERY;
    }

    const queries = Array.isArray(query) ? query : [query];
    const normalizedQueries = await Promise.all(
      queries.map((currentQuery) => this.queryTransformer(normalizeQuery(currentQuery), context))
    );

    if (normalizedQueries.find((currentQuery) => !currentQuery)) {
      throw new Error('queryTransformer returned null query. Please check your queryTransformer implementation');
    }
    // delete this  cube.js multi query maybe more flexible
    // if (queryType === QUERY_TYPE.BLENDING_QUERY) {
    //   const queryGranularity = getQueryGranularity(normalizedQueries);
    //
    //   if (queryGranularity.length > 1) {
    //     throw new UserError('Data blending query granularities must match');
    //   }
    //   if (queryGranularity.filter(Boolean).length === 0) {
    //     throw new UserError('Data blending query without granularity is not supported');
    //   }
    // }

    return [queryType, normalizedQueries];
  }

rongfengliang avatar Apr 20 '21 15:04 rongfengliang

@rongfengliang Hey Rong! I agree that conditions may be too strict. We should check that granularities match in a broad sense: both should be empty or the same. Also blending query is not the same as multi querying. Blending queries should be against the same date interval. Current API doesn't support generic batch multi querying as of right now.

paveltiunov avatar Apr 21 '21 06:04 paveltiunov

If you are interested in working on this issue, please leave a comment below and we will be happy to assign the issue to you. If this is the first time you are contributing a Pull Request to Cube.js, please check our contribution guidelines. You can also post any questions while contributing in the #contributors channel in the Cube.js Slack.

github-actions[bot] avatar Apr 21 '21 06:04 github-actions[bot]

Hey @paveltiunov I looked around a bit and didn't see anything else about supporting multi-querying so I'll ask here. Is there a specific reason multi-querying is not supported? Or has it just not been implemented yet? To me the decision to have an array of queries not be a multi query is strange. I'm actually not sure what the purpose is of calling it 'Data Blending' in the client libraries since by the description in the docs:

Another use case of the Data Blending approach would be when you want to chart some measures (business related) together and see how they correlate.

it seems like you are just describing multi queries. But maybe I'm misunderstanding the terms so if I'm wrong please correct me.

tchell avatar Aug 20 '21 20:08 tchell

Are there any updates on this? Are there any plans for allowing multi-queries?

omrihaber avatar Jan 29 '24 11:01 omrihaber

@paveltiunov its an old issue i think multi query feature is much needed.

kodeine avatar Aug 15 '24 21:08 kodeine