@cubejs-backend/query-orchestrator
Advanced tools
Comparing version 0.17.3 to 0.17.5
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.17.5](https://github.com/cube-js/cube.js/compare/v0.17.4...v0.17.5) (2020-02-07) | ||
### Bug Fixes | ||
* Sanity check for silent truncate name problem during pre-aggregation creation ([e7fb2f2](https://github.com/cube-js/cube.js/commit/e7fb2f2)) | ||
## [0.17.3](https://github.com/cube-js/cube.js/compare/v0.17.2...v0.17.3) (2020-02-06) | ||
@@ -8,0 +19,0 @@ |
@@ -263,7 +263,9 @@ const crypto = require('crypto'); | ||
await this.loadCache.reset(this.preAggregation); | ||
return this.targetTableName( | ||
getVersionEntryByContentVersion( | ||
await this.loadCache.getVersionEntries(this.preAggregation) | ||
) | ||
const lastVersion = getVersionEntryByContentVersion( | ||
await this.loadCache.getVersionEntries(this.preAggregation) | ||
); | ||
if (!lastVersion) { | ||
throw new Error(`Pre-aggregation table is not found for ${this.preAggregation.tableName} after it was successfully created. It usually means database silently truncates table names due to max name length.`); | ||
} | ||
return this.targetTableName(lastVersion); | ||
}; | ||
@@ -270,0 +272,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "Statsbot, Inc.", | ||
"version": "0.17.3", | ||
"version": "0.17.5", | ||
"repository": { | ||
@@ -29,3 +29,3 @@ "type": "git", | ||
"license": "Apache-2.0", | ||
"gitHead": "f1b54bee9931f5f15be388297df7f292bdaee85b" | ||
"gitHead": "b81ae167550ace46f509c87acc073056f09b6f0f" | ||
} |
@@ -25,4 +25,8 @@ /* globals describe, it, should, before */ | ||
async loadPreAggregationIntoTable(preAggregationTableName) { | ||
this.tables.push(preAggregationTableName); | ||
this.tables.push(preAggregationTableName.substring(0, 100)); | ||
} | ||
async dropTable(tableName) { | ||
this.tables = this.tables.filter(t => t !== tableName.split('.')[1]); | ||
} | ||
} | ||
@@ -87,2 +91,28 @@ | ||
}); | ||
it('silent truncate', async () => { | ||
const query = { | ||
query: "SELECT \"orders__created_at_week\" \"orders__created_at_week\", sum(\"orders__count\") \"orders__count\" FROM (SELECT * FROM stb_pre_aggregations.orders_number_and_count_and_very_very_very_very_very_very_long20191101) as partition_union WHERE (\"orders__created_at_week\" >= ($1::timestamptz::timestamptz AT TIME ZONE 'UTC') AND \"orders__created_at_week\" <= ($2::timestamptz::timestamptz AT TIME ZONE 'UTC')) GROUP BY 1 ORDER BY 1 ASC LIMIT 10000", | ||
values: ["2019-11-01T00:00:00Z", "2019-11-30T23:59:59Z"], | ||
cacheKeyQueries: { | ||
renewalThreshold: 21600, | ||
queries: [["SELECT date_trunc('hour', (NOW()::timestamptz AT TIME ZONE 'UTC')) as current_hour", []]] | ||
}, | ||
preAggregations: [{ | ||
preAggregationsSchema: "stb_pre_aggregations", | ||
tableName: "stb_pre_aggregations.orders_number_and_count_and_very_very_very_very_very_very_long20191101", | ||
loadSql: ["CREATE TABLE stb_pre_aggregations.orders_number_and_count_and_very_very_very_very_very_very_long20191101 AS SELECT\n date_trunc('week', (\"orders\".created_at::timestamptz AT TIME ZONE 'UTC')) \"orders__created_at_week\", count(\"orders\".id) \"orders__count\", sum(\"orders\".number) \"orders__number\"\n FROM\n public.orders AS \"orders\"\n WHERE (\"orders\".created_at >= $1::timestamptz AND \"orders\".created_at <= $2::timestamptz) GROUP BY 1", ["2019-11-01T00:00:00Z", "2019-11-30T23:59:59Z"]], | ||
invalidateKeyQueries: [["SELECT date_trunc('hour', (NOW()::timestamptz AT TIME ZONE 'UTC')) as current_hour", []]], | ||
}], | ||
renewQuery: true | ||
}; | ||
let thrown = true; | ||
try { | ||
await queryOrchestrator.fetchQuery(query); | ||
thrown = false; | ||
} catch (e) { | ||
should(e.message).match(/Pre-aggregation table is not found/); | ||
} | ||
should(thrown).equal(true); | ||
}); | ||
}); |
101425
2008