Skip to content

Conversation

@KSDaemon
Copy link
Member

@KSDaemon KSDaemon commented Apr 15, 2025

Previously it was not possible for example to define a JSON literal in sql property of cube or do similar things.
Now it's fixed!
So you can do for example this in yaml models:

cubes:
  - name: ActiveUsers
    sql: > 
          SELECT 1 as user_id, 
                         '2022-01-01'::TIMESTAMP as timestamp, 
                         CAST('\{"key":"value"\}'::JSON AS TEXT) AS json_col

    dimensions:
      - name: time
        sql: "{CUBE}.timestamp"
        type: time
      - name: json_col
        sql: json_col
        type: string

And if you query it:

{
      dimensions: ['ActiveUsers.time', 'ActiveUsers.json_col'],
}

You'll get an expected result:

      [{
        active_users__time: '2022-01-01T00:00:00.000Z',
        active_users__json_col: '{"key":"value"}',
      }]

This closes #8250

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

@codecov
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.16%. Comparing base (e7901a7) to head (6610b26).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9469      +/-   ##
==========================================
+ Coverage   48.03%   48.16%   +0.13%     
==========================================
  Files         171      171              
  Lines       21449    21454       +5     
  Branches     3723     3724       +1     
==========================================
+ Hits        10303    10334      +31     
+ Misses      10714    10692      -22     
+ Partials      432      428       -4     
Flag Coverage Δ
cube-backend 48.16% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@KSDaemon KSDaemon marked this pull request as ready for review April 15, 2025 12:33
@KSDaemon KSDaemon requested a review from a team as a code owner April 15, 2025 12:33
@KSDaemon KSDaemon merged commit 0a8cf07 into master Apr 16, 2025
55 checks passed
@KSDaemon KSDaemon deleted the fix/curly-in-yaml branch April 16, 2025 14:41
marianore-muttdata pushed a commit to MuttData/cube that referenced this pull request Jun 17, 2025
…ube-js#9469)

* fix(schema-compiler): Allow escaping of curly braces in yaml models

* add tests

* remove obsolete

* Add docs

---------

Co-authored-by: Igor Lukanin <igor@cube.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{ in sql would not allow the data model to compile

4 participants