cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.85k stars 1.77k forks source link

Incorrect YAML data model generated for uppercase schema/table names #6656

Open taitung opened 1 year ago

taitung commented 1 year ago

Describe the bug

Screenshot 2023-05-26 at 9 23 04 AM

version Cube Store (0.33.14) Cube API server (0.33.14)

YAMLException: bad indentation of a mapping entry (3:16)

 1 | cubes:
 2 |   - name: c_a_m_p_a_i_g_n_emails
 3 |     sql_table: `ODS`.`CAMPAIGN_EMAILS`
--------------------^
 4 |     data_source: default
 5 | 

    at generateError (/cube/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/cube/node_modules/js-yaml/lib/loader.js:187:9)
    at readBlockMapping (/cube/node_modules/js-yaml/lib/loader.js:1182:7)
    at composeNode (/cube/node_modules/js-yaml/lib/loader.js:1441:12)
    at readBlockSequence (/cube/node_modules/js-yaml/lib/loader.js:1008:5)
    at composeNode (/cube/node_modules/js-yaml/lib/loader.js:1440:12)
    at readBlockMapping (/cube/node_modules/js-yaml/lib/loader.js:1164:11)
    at composeNode (/cube/node_modules/js-yaml/lib/loader.js:1441:12)
    at readDocument (/cube/node_modules/js-yaml/lib/loader.js:1625:3)
    at loadDocuments (/cube/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.load (/cube/node_modules/js-yaml/lib/loader.js:1714:19)
    at YamlCompiler.compileYamlFile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:36:26)
    at DataSchemaCompiler.compileFile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:175:25)
    at /cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:144:14
    at Array.forEach (<anonymous>)
    at DataSchemaCompiler.compileCubeFiles (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:143:8)
    at compilePhase (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:61:50)
    at /cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:63:16
    at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:58:26)
    at CompilerApi.metaConfig (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:203:13)
    at ApiGateway.meta (/cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:510:26)
    at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:315:11

To Reproduce After selecting the Data Model tab on the playground, I ticked some tables and then clicked Generate Data Model to generate the models with YAML format.

Screenshot 2023-05-26 at 9 17 20 AM. Then I select the tab Playground and the error of bad indentation pops up.

workaround Add double quotes to the string of sql_table. For example, sql_table: "`ODS`.`CAMPAIGN_EMAILS`"

paveltiunov commented 1 year ago

@taitung Thanks for posting this one! Was it generated this way?

taitung commented 1 year ago

The same error that is shown in the video was tested with version 0.33.15

https://github.com/cube-js/cube/assets/1073330/27e3ae80-02f8-4027-a330-e974dfdf62fb

taitung commented 1 year ago

@paveltiunov, sorry that I didn't mention the db I connected to. It is BigQuery

beatrizcm01 commented 1 year ago

I'm having the same problem, except mine wasn't generated with the quotes for the tables' names and adding the double quotes is giving the following error: Error: TypeError: Cannot convert undefined or null to object. Any suggestions on how I should proceed?

igorlukanin commented 2 weeks ago

I was able to reproduce this on the latest (v0.36.2) version of Cube, both in Cube Core and Cube Cloud.

It looks like Cube handles lowercase schema/table names just fine because it does not enclose them into quotes. However, in case of uppercase schema/table names, Cube encloses them in backticks and generates incorrect YAML:

Screenshot 2024-09-25 at 18 05 40 Screenshot 2024-09-25 at 18 05 53