Skip to content

Generated SQL tab throwing an error in the UI #9589

@UsmanYasin

Description

@UsmanYasin

Describe the bug
The Generated SQL tab in the playground is throwing an error in the UI. The API call does succeed but while rendering the SQL query, the UI breaks.

To Reproduce
Steps to reproduce the behavior:

  1. Build a valid query in the cube.dev playground
  2. Run the query to verify correct execution and results.
  3. Click on the Generated SQL tab
  4. See error

Expected behavior
The Generated SQL tab should show the query returned by the /sql API call instead of erroring out and breaking UI

Screenshots

Image

Minimally reproducible Cube Schema

cube(`Orders`, {
  sql: `
  select 1 as id, 100 as amount, 'new' status
  UNION ALL
  select 2 as id, 200 as amount, 'new' status
  UNION ALL
  select 3 as id, 300 as amount, 'processed' status
  UNION ALL
  select 4 as id, 500 as amount, 'processed' status
  UNION ALL
  select 5 as id, 600 as amount, 'shipped' status
  `,
  measures: {
    count: {
      type: `count`,
    },
    totalAmount: {
      sql: `amount`,
      type: `sum`,
    },
    toRemove: {
      type: `count`,
    },
  },
  dimensions: {
    status: {
      sql: `status`,
      type: `string`,
    },
  },
});

Version:
v1.3.16 - Generated SQL UI is working fine on previous versions e.g. 1.3.15

Additional context
I have investigated the reason for the issue, seems to be the latest commit replacing packages/cubejs-client-core/src/SqlQuery.js file with packages/cubejs-client-core/src/SqlQuery.ts. Happy to contribute with a PR.

packages/cubejs-client-core/src/SqlQuery.js:
rawQuery() {
return this.sqlQuery .sql;
}
packages/cubejs-client-core/src/SqlQuery.ts:
public rawQuery(): SqlData {
return this.sqlQuery;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close