@malloydata/malloy 0.0.310 → 0.0.311
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/dist/dialect/pg_impl.js +6 -2
- package/dist/dialect/postgres/postgres.js +2 -1
- package/dist/lang/ast/field-space/refined-space.js +1 -1
- package/dist/lang/ast/field-space/rename-space-field.d.ts +3 -2
- package/dist/lang/ast/field-space/rename-space-field.js +16 -4
- package/dist/lang/ast/source-properties/renames.d.ts +9 -4
- package/dist/lang/ast/source-properties/renames.js +16 -2
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +7 -5
- package/dist/lang/lib/Malloy/MalloyParser.js +1537 -1521
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +5 -5
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +3 -3
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/malloy-to-ast.js +7 -3
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +1 -1
- package/dist/model/filter_compilers.js +11 -7
- package/dist/model/malloy_types.d.ts +1 -0
- package/dist/model/query_model_impl.js +9 -3
- package/dist/model/sql_block.js +2 -0
- package/dist/model/stage_writer.d.ts +3 -0
- package/dist/model/stage_writer.js +11 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/dialect/pg_impl.js
CHANGED
|
@@ -22,17 +22,21 @@ class PostgresBase extends dialect_1.Dialect {
|
|
|
22
22
|
// adjusting for monday/sunday weeks
|
|
23
23
|
const week = df.units === 'week';
|
|
24
24
|
const truncThis = week ? `${df.e.sql} + INTERVAL '1' DAY` : df.e.sql;
|
|
25
|
+
// Only do timezone conversion for timestamps, not dates
|
|
25
26
|
if (malloy_types_1.TD.isTimestamp(df.e.typeDef)) {
|
|
26
27
|
const tz = (0, dialect_1.qtz)(qi);
|
|
27
28
|
if (tz) {
|
|
28
29
|
const civilSource = `(${truncThis}::TIMESTAMPTZ AT TIME ZONE '${tz}')`;
|
|
29
30
|
let civilTrunc = `DATE_TRUNC('${df.units}', ${civilSource})`;
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
if (week) {
|
|
32
|
+
civilTrunc = `(${civilTrunc} - INTERVAL '1' DAY)`;
|
|
33
|
+
}
|
|
34
|
+
// Convert the truncated civil time back to UTC by treating it as being IN the query timezone
|
|
32
35
|
const truncTsTz = `${civilTrunc} AT TIME ZONE '${tz}'`;
|
|
33
36
|
return `(${truncTsTz})::TIMESTAMP`;
|
|
34
37
|
}
|
|
35
38
|
}
|
|
39
|
+
// For dates (civil time) or timestamps without query timezone
|
|
36
40
|
let result = `DATE_TRUNC('${df.units}', ${truncThis})`;
|
|
37
41
|
if (week) {
|
|
38
42
|
result = `(${result} - INTERVAL '1' DAY)`;
|
|
@@ -193,8 +193,9 @@ class PostgresDialect extends pg_impl_1.PostgresBase {
|
|
|
193
193
|
sqlCreateFunction(id, funcText) {
|
|
194
194
|
return `CREATE FUNCTION ${id}(JSONB) RETURNS JSONB AS $$\n${(0, utils_1.indent)(funcText)}\n$$ LANGUAGE SQL;\n`;
|
|
195
195
|
}
|
|
196
|
+
//
|
|
196
197
|
sqlCreateFunctionCombineLastStage(lastStageName) {
|
|
197
|
-
return `SELECT JSONB_AGG(
|
|
198
|
+
return `SELECT JSONB_AGG(${lastStageName}) FROM ${lastStageName}\n`;
|
|
198
199
|
}
|
|
199
200
|
sqlFinalStage(lastStageName, _fields) {
|
|
200
201
|
return `SELECT row_to_json(finalStage) as row FROM ${lastStageName} AS finalStage`;
|
|
@@ -63,7 +63,7 @@ class RefinedSpace extends dynamic_space_1.DynamicSpace {
|
|
|
63
63
|
const renamed = renameMap.get(symbol);
|
|
64
64
|
if (renamed) {
|
|
65
65
|
if (value instanceof space_field_1.SpaceField) {
|
|
66
|
-
edited.setEntry(renamed.as, new rename_space_field_1.RenameSpaceField(value, renamed.as, renamed.location));
|
|
66
|
+
edited.setEntry(renamed.as, new rename_space_field_1.RenameSpaceField(value, renamed.as, renamed.location, undefined));
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
renamed.logTo.logError('cannot-rename-non-field', `Cannot rename \`${symbol}\` which is not a field`);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { DocumentLocation, FieldDef } from '../../../model/malloy_types';
|
|
1
|
+
import type { Annotation, DocumentLocation, FieldDef } from '../../../model/malloy_types';
|
|
2
2
|
import { SpaceField } from '../types/space-field';
|
|
3
3
|
export declare class RenameSpaceField extends SpaceField {
|
|
4
4
|
private readonly otherField;
|
|
5
5
|
private readonly newName;
|
|
6
6
|
private readonly location;
|
|
7
|
-
|
|
7
|
+
private note;
|
|
8
|
+
constructor(otherField: SpaceField, newName: string, location: DocumentLocation, note: Annotation | undefined);
|
|
8
9
|
fieldDef(): FieldDef | undefined;
|
|
9
10
|
typeDesc(): import("../../../model/malloy_types").TypeDesc;
|
|
10
11
|
}
|
|
@@ -25,19 +25,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
25
|
exports.RenameSpaceField = void 0;
|
|
26
26
|
const space_field_1 = require("../types/space-field");
|
|
27
27
|
class RenameSpaceField extends space_field_1.SpaceField {
|
|
28
|
-
constructor(otherField, newName, location) {
|
|
28
|
+
constructor(otherField, newName, location, note) {
|
|
29
29
|
super();
|
|
30
30
|
this.otherField = otherField;
|
|
31
31
|
this.newName = newName;
|
|
32
32
|
this.location = location;
|
|
33
|
+
this.note = note;
|
|
33
34
|
}
|
|
34
35
|
fieldDef() {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
36
|
+
const returnFieldDef = this.otherField.fieldDef();
|
|
37
|
+
if (returnFieldDef === undefined) {
|
|
37
38
|
return undefined;
|
|
38
39
|
}
|
|
40
|
+
if (this.note) {
|
|
41
|
+
if (returnFieldDef.annotation) {
|
|
42
|
+
returnFieldDef.annotation = {
|
|
43
|
+
...this.note,
|
|
44
|
+
inherits: returnFieldDef.annotation,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
returnFieldDef.annotation = this.note;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
39
51
|
return {
|
|
40
|
-
...
|
|
52
|
+
...returnFieldDef,
|
|
41
53
|
as: this.newName,
|
|
42
54
|
location: this.location,
|
|
43
55
|
};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type { AccessModifierLabel } from '../../../model';
|
|
1
|
+
import type { AccessModifierLabel, Annotation } from '../../../model';
|
|
2
2
|
import type { DynamicSpace } from '../field-space/dynamic-space';
|
|
3
|
+
import { DefinitionList } from '../types/definition-list';
|
|
3
4
|
import type { FieldName } from '../types/field-space';
|
|
4
|
-
import {
|
|
5
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
6
|
+
import { extendNoteMethod, type Noteable } from '../types/noteable';
|
|
5
7
|
import type { MakeEntry } from '../types/space-entry';
|
|
6
|
-
export declare class RenameField extends MalloyElement implements MakeEntry {
|
|
8
|
+
export declare class RenameField extends MalloyElement implements Noteable, MakeEntry {
|
|
7
9
|
readonly newName: string;
|
|
8
10
|
readonly oldName: FieldName;
|
|
9
11
|
elementType: string;
|
|
12
|
+
note?: Annotation;
|
|
13
|
+
extendNote: typeof extendNoteMethod;
|
|
14
|
+
readonly isNoteableObj = true;
|
|
10
15
|
constructor(newName: string, oldName: FieldName);
|
|
11
16
|
makeEntry(fs: DynamicSpace): void;
|
|
12
17
|
getName(): string;
|
|
13
18
|
}
|
|
14
|
-
export declare class Renames extends
|
|
19
|
+
export declare class Renames extends DefinitionList<RenameField> {
|
|
15
20
|
readonly accessModifier: AccessModifierLabel | undefined;
|
|
16
21
|
elementType: string;
|
|
17
22
|
constructor(fields: RenameField[], accessModifier: AccessModifierLabel | undefined);
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Renames = exports.RenameField = void 0;
|
|
26
26
|
const rename_space_field_1 = require("../field-space/rename-space-field");
|
|
27
|
+
const definition_list_1 = require("../types/definition-list");
|
|
27
28
|
const malloy_element_1 = require("../types/malloy-element");
|
|
29
|
+
const noteable_1 = require("../types/noteable");
|
|
28
30
|
const space_field_1 = require("../types/space-field");
|
|
29
31
|
class RenameField extends malloy_element_1.MalloyElement {
|
|
30
32
|
constructor(newName, oldName) {
|
|
@@ -32,6 +34,8 @@ class RenameField extends malloy_element_1.MalloyElement {
|
|
|
32
34
|
this.newName = newName;
|
|
33
35
|
this.oldName = oldName;
|
|
34
36
|
this.elementType = 'renameField';
|
|
37
|
+
this.extendNote = noteable_1.extendNoteMethod;
|
|
38
|
+
this.isNoteableObj = true;
|
|
35
39
|
this.has({ oldName: oldName });
|
|
36
40
|
}
|
|
37
41
|
makeEntry(fs) {
|
|
@@ -40,9 +44,19 @@ class RenameField extends malloy_element_1.MalloyElement {
|
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
46
|
const oldValue = this.oldName.getField(fs);
|
|
47
|
+
/*
|
|
48
|
+
|
|
49
|
+
ok need to get the annotation from the old field into the inherits and the annotaiton
|
|
50
|
+
of the curuent field and then
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
*/
|
|
43
57
|
if (oldValue.found) {
|
|
44
58
|
if (oldValue.found instanceof space_field_1.SpaceField) {
|
|
45
|
-
fs.renameEntry(this.oldName.refString, this.newName, new rename_space_field_1.RenameSpaceField(oldValue.found, this.newName, this.location));
|
|
59
|
+
fs.renameEntry(this.oldName.refString, this.newName, new rename_space_field_1.RenameSpaceField(oldValue.found, this.newName, this.location, this.note));
|
|
46
60
|
}
|
|
47
61
|
else {
|
|
48
62
|
this.logError('failed-rename', `'${this.oldName}' cannot be renamed`);
|
|
@@ -57,7 +71,7 @@ class RenameField extends malloy_element_1.MalloyElement {
|
|
|
57
71
|
}
|
|
58
72
|
}
|
|
59
73
|
exports.RenameField = RenameField;
|
|
60
|
-
class Renames extends
|
|
74
|
+
class Renames extends definition_list_1.DefinitionList {
|
|
61
75
|
constructor(fields, accessModifier) {
|
|
62
76
|
super(fields);
|
|
63
77
|
this.accessModifier = accessModifier;
|
|
@@ -222,7 +222,7 @@ export declare class MalloyParser extends Parser {
|
|
|
222
222
|
static readonly RULE_defMeasures = 38;
|
|
223
223
|
static readonly RULE_defDimensions = 39;
|
|
224
224
|
static readonly RULE_renameList = 40;
|
|
225
|
-
static readonly
|
|
225
|
+
static readonly RULE_renameEntry = 41;
|
|
226
226
|
static readonly RULE_defList = 42;
|
|
227
227
|
static readonly RULE_fieldDef = 43;
|
|
228
228
|
static readonly RULE_fieldNameDef = 44;
|
|
@@ -391,7 +391,7 @@ export declare class MalloyParser extends Parser {
|
|
|
391
391
|
defMeasures(): DefMeasuresContext;
|
|
392
392
|
defDimensions(): DefDimensionsContext;
|
|
393
393
|
renameList(): RenameListContext;
|
|
394
|
-
|
|
394
|
+
renameEntry(): RenameEntryContext;
|
|
395
395
|
defList(): DefListContext;
|
|
396
396
|
fieldDef(): FieldDefContext;
|
|
397
397
|
fieldNameDef(): FieldNameDefContext;
|
|
@@ -936,6 +936,7 @@ export declare class DefExplorePrimaryKeyContext extends ExploreStatementContext
|
|
|
936
936
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
937
937
|
}
|
|
938
938
|
export declare class DefExploreRenameContext extends ExploreStatementContext {
|
|
939
|
+
tags(): TagsContext;
|
|
939
940
|
RENAME(): TerminalNode;
|
|
940
941
|
renameList(): RenameListContext;
|
|
941
942
|
accessLabel(): AccessLabelContext | undefined;
|
|
@@ -1028,8 +1029,8 @@ export declare class DefDimensionsContext extends ParserRuleContext {
|
|
|
1028
1029
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
1029
1030
|
}
|
|
1030
1031
|
export declare class RenameListContext extends ParserRuleContext {
|
|
1031
|
-
|
|
1032
|
-
|
|
1032
|
+
renameEntry(): RenameEntryContext[];
|
|
1033
|
+
renameEntry(i: number): RenameEntryContext;
|
|
1033
1034
|
COMMA(): TerminalNode[];
|
|
1034
1035
|
COMMA(i: number): TerminalNode;
|
|
1035
1036
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
@@ -1038,7 +1039,8 @@ export declare class RenameListContext extends ParserRuleContext {
|
|
|
1038
1039
|
exitRule(listener: MalloyParserListener): void;
|
|
1039
1040
|
accept<Result>(visitor: MalloyParserVisitor<Result>): Result;
|
|
1040
1041
|
}
|
|
1041
|
-
export declare class
|
|
1042
|
+
export declare class RenameEntryContext extends ParserRuleContext {
|
|
1043
|
+
tags(): TagsContext;
|
|
1042
1044
|
fieldName(): FieldNameContext[];
|
|
1043
1045
|
fieldName(i: number): FieldNameContext;
|
|
1044
1046
|
isDefine(): IsDefineContext;
|