Skip to content

fix(tesseracrt): Fix filter params casting for BigQuery dialect #9720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -4133,11 +4133,14 @@ export class BaseQuery {
like_escape: '{{ like_expr }} ESCAPE {{ escape_char }}',
within_group: '{{ fun_sql }} WITHIN GROUP (ORDER BY {{ within_group_concat }})',
concat_strings: '{{ strings | join(\' || \' ) }}',
rolling_window_expr_timestamp_cast: '{{ value }}'
rolling_window_expr_timestamp_cast: '{{ value }}',
timestamp_literal: '{{ value }}'
},
tesseract: {
ilike: '{{ expr }} {% if negated %}NOT {% endif %}ILIKE {{ pattern }}', // May require different overloads in Tesseract than the ilike from expressions used in SQLAPI.
series_bounds_cast: '{{ expr }}'
series_bounds_cast: '{{ expr }}',
bool_param_cast: '{{ expr }}',
number_param_cast: '{{ expr }}',
},
filters: {
equals: '{{ column }} = {{ value }}{{ is_null_check }}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ export class BigqueryQuery extends BaseQuery {
templates.filters.like_pattern = 'CONCAT({% if start_wild %}\'%\'{% else %}\'\'{% endif %}, LOWER({{ value }}), {% if end_wild %}\'%\'{% else %}\'\'{% endif %})';
templates.tesseract.ilike = 'LOWER({{ expr }}) {% if negated %}NOT {% endif %} LIKE {{ pattern }}';
templates.tesseract.series_bounds_cast = 'TIMESTAMP({{ expr }})';
templates.tesseract.bool_param_cast = 'CAST({{ expr }} AS BOOL)';
templates.tesseract.number_param_cast = 'CAST({{ expr }} AS FLOAT64)';
templates.types.boolean = 'BOOL';
templates.types.float = 'FLOAT64';
templates.types.double = 'FLOAT64';
Expand Down
12 changes: 2 additions & 10 deletions packages/cubejs-testing-drivers/fixtures/athena.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@
"for the ECommerce.TimeAnalysisExternal",
"for the ECommerce.TimeAnalysisInternal",

"---------------------------------------",
"Full tests ",
"---------------------------------------",

"---------------------------------------",
"SKIPPED FOR ALL ",
"---------------------------------------",
Expand All @@ -143,18 +139,15 @@
"querying BigECommerce: partitioned pre-agg",
"querying BigECommerce: null sum",
"querying BigECommerce: null boolean",
"--------------------",
"querying BigECommerce: filtering with possible casts",

"---------------------------------------",
"Requires Tesseract. ",
"---------------------------------------",
"querying BigECommerce: rolling window by 2 day without date range",
"querying BigECommerce: rolling window by 2 month without date range",
"querying BigECommerce: rolling window YTD without date range",

"--------------------",
"week granularity is not supported for intervals",
"--------------------",
"querying BigECommerce: rolling window by 2 week",

"---------------------------------------",
Expand Down Expand Up @@ -185,8 +178,7 @@
"querying BigECommerce: partitioned pre-agg",
"querying BigECommerce: null sum",
"querying BigECommerce: null boolean",
"--------------------",

"querying BigECommerce: filtering with possible casts",

"querying BigECommerce: rolling window by 2 week",
"querying custom granularities ECommerce: count by three_months_by_march + no dimension",
Expand Down
1 change: 1 addition & 0 deletions packages/cubejs-testing-drivers/fixtures/clickhouse.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"querying BigECommerce: partitioned pre-agg",
"querying BigECommerce: null sum",
"querying BigECommerce: null boolean",
"querying BigECommerce: filtering with possible casts",

"---------------------------------------",
"Unsupported JOIN ON conditions. Unexpected 'big_e_commerce__order_date_month > subtractWeeks(date_to, 2)'",
Expand Down
29 changes: 29 additions & 0 deletions packages/cubejs-testing-drivers/src/tests/testQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,35 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
expect(response.rawData()).toMatchSnapshot();
});

execute('querying BigECommerce: filtering with possible casts', async () => {
const response = await client.load({
measures: [
'BigECommerce.totalSales',
],
filters: [
{
values: ['10'],
member: 'BigECommerce.sales',
operator: 'gte'
},
{
values: ['true'],
member: 'BigECommerce.returning',
operator: 'equals'
}
],
timeDimensions: [{
dimension: 'BigECommerce.orderDate',
granularity: 'month',
dateRange: ['2020-01-01', '2020-12-31'],
}],
order: {
'BigECommerce.orderDate': 'asc',
}
});
expect(response.rawData()).toMatchSnapshot();
});

execute('querying custom granularities ECommerce: count by half_year + no dimension', async () => {
const response = await client.load({
measures: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6260,6 +6260,21 @@ Array [
]
`;

exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;

exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: partitioned pre-agg 1`] = `
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15980,3 +15980,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15785,3 +15785,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure-prefix querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15980,3 +15980,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-gcs querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15785,3 +15785,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-gcs-prefix querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15980,3 +15980,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-s3 querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15785,3 +15785,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-s3-prefix querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15980,3 +15980,18 @@ Array [
},
]
`;

exports[`Queries with the @cubejs-backend/databricks-jdbc-driver querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 48.896,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 232.88,
},
]
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,21 @@ Array [
]
`;

exports[`Queries with the @cubejs-backend/mssql-driver querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": "488960",
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": "2328800",
},
]
`;

exports[`Queries with the @cubejs-backend/mssql-driver querying BigECommerce: partitioned pre-agg 1`] = `
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2566,6 +2566,61 @@ Array [
]
`;

exports[`Queries with the @cubejs-backend/mysql-driver querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": 210.98,
},
Object {
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
"BigECommerce.totalSales": 18.368,
},
Object {
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
"BigECommerce.totalSales": 2471.56,
},
Object {
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
"BigECommerce.totalSales": 36.672,
},
Object {
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
"BigECommerce.totalSales": 1284.45,
},
Object {
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
"BigECommerce.totalSales": 724.974,
},
Object {
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
"BigECommerce.totalSales": 2451.472,
},
Object {
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
"BigECommerce.totalSales": 2209.828,
},
Object {
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
"BigECommerce.totalSales": 5573.922,
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": 2073.63,
},
]
`;

exports[`Queries with the @cubejs-backend/mysql-driver querying BigECommerce: partitioned pre-agg with multi time dimension 1`] = `
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11116,6 +11116,21 @@ Array [
]
`;

exports[`Queries with the @cubejs-backend/postgres-driver querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": "48.89600",
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": "232.88000",
},
]
`;

exports[`Queries with the @cubejs-backend/postgres-driver querying BigECommerce: null boolean 1`] = `
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11108,6 +11108,21 @@ Array [
]
`;

exports[`Queries with the @cubejs-backend/redshift-driver export-bucket-s3 querying BigECommerce: filtering with possible casts 1`] = `
Array [
Object {
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
"BigECommerce.totalSales": "48.89600",
},
Object {
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
"BigECommerce.totalSales": "232.88000",
},
]
`;

exports[`Queries with the @cubejs-backend/redshift-driver export-bucket-s3 querying BigECommerce: null boolean 1`] = `
Array [
Object {
Expand Down
Loading
Loading