Skip to content

Conversation

@Tankilevitch
Copy link
Owner

Description

Oracle database does not support the AS keyword for table/subquery aliasing, while other databases like PostgreSQL and MySQL do. The existing BaseQuery implementation hardcoded as in subquery alias generation, causing Oracle queries with multiple subqueries to fail.

Changes

  • BaseQuery.js: Replaced hardcoded 'as' with asSyntaxJoin property in subquery alias generation
    • Line 1383: INNER JOIN clause now uses asSyntaxJoin
    • Line 1384: Comma-separated subquery now uses asSyntaxJoin
    • Line 1413: Main FROM clause now uses asSyntaxJoin
  • OracleQuery.ts: Already returns empty string for asSyntaxJoin (no AS keyword)
  • PostgreSQL/MySQL: Continue to return 'AS' (maintains existing behavior)

Test Coverage

New Tests

  • oracle-query.test.ts (NEW): Comprehensive Oracle query test suite
    • Basic query validation
    • Rolling window measures (single and multiple)
    • Subquery alias validation (ensures NO AS keyword)
    • Year-over-year style measures
    • FETCH NEXT syntax validation

Regression Tests

  • postgres-query.test.ts (UPDATED): Added regression test ensuring PostgreSQL still correctly uses AS keyword

Problem Solved

Before (Invalid Oracle SQL)

SELECT ... 
FROM (...) as q_0 
INNER JOIN (...) as q_1 ON ...

After (Valid Oracle SQL)

SELECT ... 
FROM (...) q_0 
INNER JOIN (...) q_1 ON ...

Testing

cd packages/cubejs-schema-compiler
yarn test oracle-query.test.ts
yarn test postgres-query.test.ts

All tests pass ✅

Impact

  • Oracle users: Fixes queries with rolling windows and multiple subqueries
  • Other databases: No behavior change (PostgreSQL, MySQL, etc. continue using AS)
  • Breaking changes: None

Checklist

  • Code follows project style guidelines
  • Tests added for new functionality
  • Regression tests added to prevent future issues
  • All existing tests pass
  • No breaking changes
  • Documentation not required (internal query generation)

KSDaemon and others added 30 commits September 15, 2025 14:06
* add convertedToJs flag

* pass toCompile to compileCubeFiles()

* refactored compileYamlFile() to not call compileJsFile directly

* moved yaml transpilation to transpile phase

* removed dataSchemaCompiler from YamlCompiler's deps

* renaming

* simplified code

* add PerfTracker

* inject perTracker measures in dataschemacompiler

* update CubePropContextTranspiler to support string keys

* replace original content with js on first phase

* update arrow func expression instead of blind copying

+ correct path collection

* fix grammar

* more types

* Preload Jinja templates to the engine

* remove perf logging

* simplified compileFile

* avoid mutating original repository files

* linter fix

* filter out files we don't transpile/compile

* move PerfTracker to backend-shared

* Refactor doCompile() to avoid content mutation

* refactor: split first and later compile/transpile stages

* improve transpilationNative
…9929)

* extracted yaml and jinja transpilation in separate functions

* implement yaml transpilation in worker threads

* fix to allow use threads and native in parallel

* just code polish

* small fix

* remove speed test as it is flacky

* introduce compiledYamlCache
* Prepare transpileYaml in native + schema compiler

* fix test

fix/sync error message

* fix test
* reuse yaml transpilation flow for jinja files

* remove perf logging

* introduce compiledJinjaCache

* add a comment
Bumps [axios](https://github.com/axios/axios) from 1.8.4 to 1.12.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](axios/axios@v1.8.4...v1.12.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.12.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ovr and others added 30 commits October 14, 2025 16:09
 | Stage | Description | Stack Size | Reduction | binary_expr |
 |-------|-------------|------------|-----------|-------------|
 | 1 | Original `Result<Expr>` | 11,429 bytes | baseline | - |
 | 2 | `Result<Box<Expr>>` | 8,206 bytes | -28.2% | - |
 | 3 | `grouping_set_normalize` opt | 7,990 bytes | -30.1% | 5,054 bytes |
 | **4** | **binary_expr optimize** | **7,990 bytes** | **-30.1%** | **3,918 bytes** |
Signed-off-by: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com>
…construction (cube-js#10039)

* add tests

* enable view join tests for tesseract

* fix test

* temp comment out tests

* correct additional hints

predecessors comparator

OMG! Is it really working?!

everything works besides loop detection

correct additional hints: everything works besides loop detection

* trying to adopt loop test

fix actually incorrect tests

* linter fix

* small fix in error handling

* add test case for join maps test

* implement join maps

* update snapshot

* refactor tests

* add more tests

* return back loop for join resolution

* fix typo

* join map in tesseract

* enable view join tests for tesseract

* cargo fmt

* uncomment test

* remove println!

* remove unneeded rootOfJoin

* refactor tests

* fix linter warning

* refactor allJoinHints()

* refactor: extract inlined isJoinTreesEqual()

* remove unused

* add support for transitive joins in tesseract

* uncomment transitive joins tests for tesseract

* cargo fmt
… for Oracle compatibility

Oracle database does not support the AS keyword for table/subquery aliasing,
while other databases like PostgreSQL and MySQL do. The existing BaseQuery
implementation hardcoded 'as' in subquery alias generation, causing Oracle
queries to fail.

This change:
- Replaces hardcoded 'as' with asSyntaxJoin property in BaseQuery
- Oracle returns empty string for asSyntaxJoin (no AS keyword)
- PostgreSQL/MySQL return 'AS' (maintains existing behavior)
- Adds comprehensive Oracle query test suite validating AS syntax removal
- Adds PostgreSQL regression test ensuring AS keyword is still present

This fixes queries with rolling windows and multiple subqueries on Oracle,
which previously generated invalid SQL like:
  SELECT ... FROM (...) as q_0 INNER JOIN (...) as q_1 ON ...

Now Oracle correctly generates:
  SELECT ... FROM (...) q_0 INNER JOIN (...) q_1 ON ...
- Fix AS keyword in subquery aliases (Oracle doesn't support it)
- Handle time dimensions without granularity to prevent TypeError
- Implement Oracle-specific interval arithmetic using ADD_MONTHS and NUMTODSINTERVAL
- Add comprehensive test suite for Oracle query generation

These changes enable Oracle users to execute queries with:
- Time dimension filters without granularity specification
- Rolling windows and time-based calculations
- Multiple subqueries with proper aliasing

All changes maintain backward compatibility with other database adapters.
…lower) (cube-js#10070)

Allowing filters to be pushed down with `DATE_PART('year', ?column) = ?year AND DATE_PART('quarter', ?column) = ?quarter` by pushing it as inDateRange. Now, such queries will be accelerated with pre-aggregations.

I am re-using code that we have for tablea, but without usage of `Trunc` as wrapper. I've added ability to merge date range with `quarter`.
…ubeScan (cube-js#10068)

Signed-off-by: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com>
… Z` for date and timestamp (cube-js#9970)

* fix(schema-compiler): use TO_TIMESTAMP_TZ for ISO 8601 with Z; keep index-friendly casts; add Oracle unit test

* fix lint

* fix

* fix(schema-compiler): Update Oracle test to expect both date range parameters

* fix

* cr comments fixes

---------

Co-authored-by: Konstantin Burkalev <KSDaemon@gmail.com>
…week') (cube-js#10071)

Allow to merge the week granularity date_part filter into the inDateRange. After that, it's possible to push down a complex filter: 

WHERE DATE_PART('year', "order_date") = 2019 AND 
              DATE_PART('quarter', "order_date") = 2 AND 
              DATE_PART('month', "order_date") = 4 AND 
              DATE_PART('week', "order_date") = 15

We are using such filters in the MDX API
* fix(tesseract): Fix member name case conversion

Prepend "_" even to the first UPPERCASE letter in the name

* add tests

* fix tests

* cargo fmt
…e-js#10081)

Signed-off-by: Alex Qyoun-ae <4062971+MazterQyou@users.noreply.github.com>
cube-js#10063)

* chore(ci): Increase jest timeout for redshift tests to be able to pass

* set CUBEJS_DB_MAX_POOL for Redshift Tests

* add delays between pre-aggs build

* decrease CUBEJS_DB_MAX_POOL

* decrease CUBEJS_DB_MAX_POOL

* add delay between create tables queries

* more delays for redshift

* more timeout adjustments

* increase timeouts

* comment put heavy tests

* skip tests for tesseract
…n Tesseract (cube-js#10078)

* fix formatInterval() as MySQL doesn't support milliseconds

* more types

* add ilike templates for tesseract

* add time_series_* templates

* update snapshots

* add mysql + tesseract tests in CI

* skip some tests for tesseract

* cast as TIMESTAMP

* skip some tests for tesseract

* fix templates

* skip some tests for tesseract

* fix templates

* update snapshots

* fix skip tests
…be-js#9972)

* add cache option to the query

* Pass CacheMode from /cubesql to backend

* imject CacheMode into more places

* update normalizeQuery with cache mode

* pass cache mode within graphql

* pass new cache mode in sqlApiLoad in API GW

* fix types imports

* update preAggs to use cache option instead of renewQuery

* code polish

* comments with types

* fix query type

* set default  cacheMode = 'stale-if-slow' in normalize()

* more types and polish

* backbone code for 'stale-if-slow' & 'stale-while-revalidate'

* make query cache aware of queryBody.cache === 'must-revalidate'

* First attempt to implement 'no-cache' scenario

* add cache to open api spec and regenerate rust client

* pass cache mode to cubeScan

* cargo clippy/fmt

* Implement background refresh

* add cache mode descriptions

* remove query cache mode from normalize query

* pass cacheMode to getSqlResponseInternal

* remove obsolete

* add cacheMode as input param in orchestratorApi

* open api spec fix

* fix cubesql after introducing cacheMode

* rename cache → cacheMode

* clean up obsolete

* pass cache_mode from SqlApiLoadPayload

* fix important

* move 'no-cache' variant into queryCache.cachedQueryResult()

* remove cacheMode from client query body types (it's incorrect)

* switch RefreshScheduler to use cacheMode instead of renewQuery

* remove obsolete continueWait flag

* fix refresh scheduler

* add fallback to renewQuery in api gw

* fix tests

* Docs

* Deprecation

* refactor api gw: move copy/paste into this.normalizeCacheMode()

* fix tests snapshots

* return cacheMode into query object

* fix tests

* some cleanup (removed renewQuery)

* update cacheMod in graphql

* return back cache as public prop in query

* fix

* lint fix

# Conflicts:
#	packages/cubejs-api-gateway/package.json

* fix subscribe()

* remove cache from subscribe

* fix CacheMode serialization

* refactor: move normalizeQueryCacheMode to normalize

---------

Co-authored-by: Igor Lukanin <igor@cube.dev>
…re-aggregations (cube-js#10020)

* feat(schema-compiler): Support joins for proxied time dimensions in pre-aggregations

* add tests
Oracle's custom groupByClause() was incorrectly including time dimensions
without granularity in the GROUP BY clause, causing SQL errors when time
dimensions were used solely for filtering (no grouping).

Changes:
- Update OracleQuery.groupByClause() to check selectColumns() before
  including dimensions in GROUP BY
- Time dimensions without granularity return null from selectColumns(),
  so they are now properly excluded
- Add comprehensive tests for both PostgreSQL and Oracle covering:
  * Time dimensions without granularity (filtering only)
  * Time dimensions with granularity (grouping and filtering)
- Remove unnecessary guard in BaseQuery.dimensionTimeGroupedColumn()
  as it's no longer needed with the Oracle-specific fix

The fix aligns Oracle's behavior with PostgreSQL, which already handles
this correctly through its base implementation.
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.