Skip to content

Conversation

@KSDaemon
Copy link
Member

@KSDaemon KSDaemon commented Apr 15, 2025

Previously it was impossible to call sql() or other functions of other cubes.
Now it's fixed!

So you can do for example this in yaml models:

cubes:
  - name: simple_orders
    sql: >
      SELECT 1 AS id, 100 AS amount, 'new' status, now() AS created_at

...

  - name: simple_orders_sql_ext

    sql: >
      SELECT * FROM {simple_orders.sql()}                <<<<<< this <<<<<<
      WHERE status = 'processed'

....

Fixes #7484

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 58.46%. Comparing base (0a8cf07) to head (fff648e).
Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #9473       +/-   ##
===========================================
+ Coverage   48.16%   58.46%   +10.29%     
===========================================
  Files         171      167        -4     
  Lines       21454    14927     -6527     
  Branches     3724     2955      -769     
===========================================
- Hits        10334     8727     -1607     
+ Misses      10692     5854     -4838     
+ Partials      428      346       -82     
Flag Coverage Δ
cube-backend 58.46% <100.00%> (+10.29%) ⬆️

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 13:19
@KSDaemon KSDaemon requested a review from a team as a code owner April 15, 2025 13:19
@KSDaemon KSDaemon merged commit 61ef9da into master Apr 16, 2025
59 checks passed
@KSDaemon KSDaemon deleted the fix/sql-in-yaml branch April 16, 2025 16:13
marianore-muttdata pushed a commit to MuttData/cube that referenced this pull request Jun 17, 2025
…cks (cube-js#9473)

* fix(schema-compiler): Allow calling cube functions in yaml python blocks

* regenerate antlr

* exclude antlr auto generated code from coverage

* add tests

* Add docs and YAML examples

* some fixes in tests

---------

Co-authored-by: Igor Lukanin <[email protected]>
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.

{cube.sql()} is not supported in YAML/Python

4 participants