@cubejs-backend/schema-compiler 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.24.1](https://github.com/cube-js/cube.js/compare/v0.24.0...v0.24.1) (2020-11-27)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Specifying `dateRange` in time dimension should produce same result as `inDateRange` in filter ([a7603d7](https://github.com/cube-js/cube.js/commit/a7603d724732a51301227f68c39ba699333c0e06)), closes [#962](https://github.com/cube-js/cube.js/issues/962)
12
+
13
+
14
+
15
+
16
+
6
17
  # [0.24.0](https://github.com/cube-js/cube.js/compare/v0.23.15...v0.24.0) (2020-11-26)
7
18
 
8
19
 
@@ -132,7 +132,14 @@ class BaseFilter extends BaseDimension {
132
132
  }
133
133
 
134
134
  allocateTimestampParams() {
135
- return this.filterParams().map(p => this.allocateTimestampParam(p));
135
+ return this.filterParams().map((p, i) => {
136
+ if (i > 1) {
137
+ throw new Error(`Expected only 2 parameters for timestamp filter but got: ${this.filterParams()}`);
138
+ }
139
+ return this.allocateTimestampParam(
140
+ i === 0 ? this.inDbTimeZoneDateFrom(p) : this.inDbTimeZoneDateTo(p)
141
+ );
142
+ });
136
143
  }
137
144
 
138
145
  allParamsRepeat(basePart) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cubejs-backend/schema-compiler",
3
3
  "description": "Cube.js schema compiler",
4
4
  "author": "Cube Dev, Inc.",
5
- "version": "0.24.0",
5
+ "version": "0.24.1",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/cube-js/cube.js.git",
@@ -62,5 +62,5 @@
62
62
  "uuid": "^3.3.2"
63
63
  },
64
64
  "license": "Apache-2.0",
65
- "gitHead": "04d0fe148181b6e19cdfe53ef9f9cebc3b3ba766"
65
+ "gitHead": "0479050307f08ca69f4fdaee2d08d3e4f39453e6"
66
66
  }
@@ -138,6 +138,14 @@ describe('PreAggregations', function test() {
138
138
  granularity: 'hour',
139
139
  partitionGranularity: 'hour'
140
140
  },
141
+ partitionedHourlyForRange: {
142
+ type: 'rollup',
143
+ measureReferences: [checkinsTotal],
144
+ dimensionReferences: [source, createdAt],
145
+ timeDimensionReference: createdAt,
146
+ granularity: 'hour',
147
+ partitionGranularity: 'hour'
148
+ },
141
149
  ratio: {
142
150
  type: 'rollup',
143
151
  measureReferences: [checkinsTotal, uniqueSourceCount],
@@ -795,6 +803,54 @@ describe('PreAggregations', function test() {
795
803
  });
796
804
  }));
797
805
 
806
+ it('partitioned inDateRange', () => compiler.compile().then(() => {
807
+ const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
808
+ measures: [
809
+ 'visitors.checkinsTotal'
810
+ ],
811
+ dimensions: [
812
+ 'visitors.source'
813
+ ],
814
+ timezone: 'America/Los_Angeles',
815
+ preAggregationsSchema: '',
816
+ filters: [{
817
+ member: 'visitors.createdAt',
818
+ operator: 'inDateRange',
819
+ values: ['2016-12-30', '2017-01-05']
820
+ }],
821
+ order: [{
822
+ id: 'visitors.checkinsTotal'
823
+ }],
824
+ });
825
+
826
+ const queryAndParams = query.buildSqlAndParams();
827
+ console.log(queryAndParams);
828
+ const preAggregationsDescription = query.preAggregations.preAggregationsDescription();
829
+ console.log(JSON.stringify(preAggregationsDescription, null, 2));
830
+
831
+ const queries = tempTablePreAggregations(preAggregationsDescription);
832
+
833
+ console.log(JSON.stringify(queries.concat(queryAndParams)));
834
+
835
+ return dbRunner.testQueries(
836
+ queries.concat([queryAndParams]).map(q => replaceTableName(q, preAggregationsDescription, 12342))
837
+ ).then(res => {
838
+ console.log(JSON.stringify(res));
839
+ res.should.be.deepEqual(
840
+ [
841
+ {
842
+ 'visitors__source': 'google',
843
+ 'visitors__checkins_total': '1'
844
+ },
845
+ {
846
+ 'visitors__source': 'some',
847
+ 'visitors__checkins_total': '5'
848
+ }
849
+ ]
850
+ );
851
+ });
852
+ }));
853
+
798
854
  it('partitioned hourly', () => compiler.compile().then(() => {
799
855
  const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
800
856
  measures: [