@malloydata/malloy 0.0.313 → 0.0.315
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.
|
@@ -291,25 +291,33 @@ class MySQLDialect extends dialect_1.Dialect {
|
|
|
291
291
|
sqlNowExpr() {
|
|
292
292
|
return 'LOCALTIMESTAMP';
|
|
293
293
|
}
|
|
294
|
-
// truncToUnit(sql, unit: string): string {
|
|
295
|
-
// return `EXTRACT(${unit} FROM ${sql})`;
|
|
296
|
-
// }
|
|
297
294
|
sqlTruncExpr(qi, trunc) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
truncThis = `DATE_SUB(${truncThis}, INTERVAL DAYOFWEEK(${truncThis}) - 1 DAY)`;
|
|
302
|
-
}
|
|
295
|
+
const truncThis = trunc.e.sql || 'internal-error-in-sql-generation';
|
|
296
|
+
const week = trunc.units === 'week';
|
|
297
|
+
// Only do timezone conversion for timestamps, not dates
|
|
303
298
|
if (malloy_types_1.TD.isTimestamp(trunc.e.typeDef)) {
|
|
304
299
|
const tz = (0, dialect_1.qtz)(qi);
|
|
305
300
|
if (tz) {
|
|
301
|
+
// Convert timestamp to the query timezone (civil time)
|
|
306
302
|
const civilSource = `(CONVERT_TZ(${truncThis}, 'UTC','${tz}'))`;
|
|
307
|
-
|
|
303
|
+
// For week truncation, we need to adjust to Sunday in the civil timezone
|
|
304
|
+
// DAYOFWEEK returns 1=Sunday, 2=Monday, etc., so subtract (DAYOFWEEK-1) days
|
|
305
|
+
const adjustedSource = week
|
|
306
|
+
? `DATE_SUB(${civilSource}, INTERVAL DAYOFWEEK(${civilSource}) - 1 DAY)`
|
|
307
|
+
: civilSource;
|
|
308
|
+
// Truncate to the appropriate unit in civil time
|
|
309
|
+
const civilTrunc = `${this.truncToUnit(adjustedSource, trunc.units)}`;
|
|
310
|
+
// Convert the truncated civil time back to UTC
|
|
308
311
|
const truncTsTz = `CONVERT_TZ(${civilTrunc}, '${tz}', 'UTC')`;
|
|
309
312
|
return `(${truncTsTz})`; // TODO: should it cast?
|
|
310
313
|
}
|
|
311
314
|
}
|
|
312
|
-
|
|
315
|
+
// For dates (civil time) or timestamps without query timezone
|
|
316
|
+
// do the week adjustment before truncating
|
|
317
|
+
const adjustedThis = week
|
|
318
|
+
? `DATE_SUB(${truncThis}, INTERVAL DAYOFWEEK(${truncThis}) - 1 DAY)`
|
|
319
|
+
: truncThis;
|
|
320
|
+
const result = `${this.truncToUnit(adjustedThis, trunc.units)}`;
|
|
313
321
|
return result;
|
|
314
322
|
}
|
|
315
323
|
truncToUnit(expr, units) {
|
package/dist/dialect/pg_impl.js
CHANGED
|
@@ -27,7 +27,7 @@ class PostgresBase extends dialect_1.Dialect {
|
|
|
27
27
|
const tz = (0, dialect_1.qtz)(qi);
|
|
28
28
|
if (tz) {
|
|
29
29
|
// get a civil version of the time in the query time zone
|
|
30
|
-
const civilSource = `(${truncThis}::TIMESTAMPTZ AT TIME ZONE '${tz}')`;
|
|
30
|
+
const civilSource = `((${truncThis})::TIMESTAMPTZ AT TIME ZONE '${tz}')`;
|
|
31
31
|
// do truncation in that time space
|
|
32
32
|
let civilTrunc = `DATE_TRUNC('${df.units}', ${civilSource})`;
|
|
33
33
|
if (week) {
|
|
@@ -160,7 +160,9 @@ class MalloyToQuery extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor
|
|
|
160
160
|
visitRunStatement(pcx) {
|
|
161
161
|
const defCx = pcx.topLevelAnonQueryDef();
|
|
162
162
|
const definition = this.getQueryDefinition(defCx.sqExpr());
|
|
163
|
-
const
|
|
163
|
+
const runAnnotations = this.getAnnotations(pcx.tags());
|
|
164
|
+
const defAnnotations = this.getAnnotations(pcx.topLevelAnonQueryDef().tags());
|
|
165
|
+
const annotations = this.combineAnnotations(runAnnotations, defAnnotations);
|
|
164
166
|
if (definition !== null) {
|
|
165
167
|
return {
|
|
166
168
|
annotations,
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.315";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.315';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.315",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@malloydata/malloy-filter": "0.0.
|
|
45
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
46
|
-
"@malloydata/malloy-tag": "0.0.
|
|
44
|
+
"@malloydata/malloy-filter": "0.0.315",
|
|
45
|
+
"@malloydata/malloy-interfaces": "0.0.315",
|
|
46
|
+
"@malloydata/malloy-tag": "0.0.315",
|
|
47
47
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
48
48
|
"assert": "^2.0.0",
|
|
49
49
|
"jaro-winkler": "^0.2.8",
|