cube-js / cube-js/cube

Dynamic data models with Jinja and Python: Does not support joins

Open
#7,033 1 comment 0 reactions 2 assignees Claimed by @ovr View on GitHub
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

**Describe the bug**
Dynamic addition of SQL joins `sql: "{{ join.sql }}" ` enclosed in quotes fails. Without the quotes, it throws a character (=) error in YAML

cubes.yml.jinja file is as follow:

```
cubes:

{%- set data = load_data() %}
{%- if data is not none %}
{%- for cube in data["cubes"] %}

- name: {{ cube.object_name }}
sql: {{ cube.object_name }}

{%- if cube.joins is not none and cube.joins|length > 0 %}
joins:
{%- for join in cube.joins %}
- name: {{ join.name }}
type: {{ join.relationship }}
sql: "{{ join.sql }}"
{%- endfor %}
{%- endif %}

{%- if cube.dimensions is not none and cube.dimensions|length > 0 %}
dimensions:
{%- for dimension in cube.dimensions %}
- name: {{ dimension.name }}
type: {{ dimension.type }}
sql: {{ dimension.sql }}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}

```

Error:

```
cube | TypeError: js_yaml_1.default.stringify is not a function
cube | at /cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:281:74
cube | at Array.map ()
cube | at YamlCompiler.yamlArrayToObj (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:276:32)
cube | at YamlCompiler.transformYamlCubeObj (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:126:26)
cube | at YamlCompiler.transpileAndPrepareJsFile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:108:26)
cube | at /cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:93:39
cube | at Array.forEach ()
cube | at YamlCompiler.compileYamlFile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:92:31)
cube | at YamlCompiler.compileYamlWithJinjaFile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/YamlCompiler.ts:68:17)
cube | at DataSchemaCompiler.compileFile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:237:25)
cube | at /cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:205:14
cube | at Array.forEach ()
cube | at DataSchemaCompiler.compileCubeFiles (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:204:8)
cube | at compilePhase (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:100:46)
cube | at DataSchemaCompiler.doCompile (/cube/node_modules/@cubejs-backend/schema-compiler/src/compiler/DataSchemaCompiler.js:102:12)
cube | at CompilerApi.getCompilers (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:65:26)
cube | at CompilerApi.metaConfig (/cube/node_modules/@cubejs-backend/server-core/src/core/CompilerApi.js:215:13)
cube | at ApiGateway.meta (/cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:514:26)
cube | at /cube/node_modules/@cubejs-backend/api-gateway/src/gateway.ts:318:11

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.