@malloydata/malloy 0.0.195-dev241003204819 → 0.0.195-dev241007154000

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.
Files changed (146) hide show
  1. package/dist/connection/base_connection.d.ts +21 -7
  2. package/dist/connection/base_connection.js +62 -0
  3. package/dist/connection/types.d.ts +5 -5
  4. package/dist/dialect/dialect.d.ts +5 -3
  5. package/dist/dialect/dialect.js +15 -0
  6. package/dist/dialect/duckdb/duckdb.d.ts +3 -3
  7. package/dist/dialect/duckdb/duckdb.js +8 -3
  8. package/dist/dialect/postgres/postgres.d.ts +3 -3
  9. package/dist/dialect/postgres/postgres.js +5 -2
  10. package/dist/dialect/snowflake/snowflake.d.ts +3 -3
  11. package/dist/dialect/snowflake/snowflake.js +4 -1
  12. package/dist/dialect/standardsql/standardsql.d.ts +3 -3
  13. package/dist/dialect/standardsql/standardsql.js +5 -2
  14. package/dist/dialect/trino/trino.d.ts +3 -3
  15. package/dist/dialect/trino/trino.js +35 -3
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +6 -2
  18. package/dist/lang/ast/error-factory.d.ts +4 -3
  19. package/dist/lang/ast/error-factory.js +27 -17
  20. package/dist/lang/ast/expressions/constant-expression.d.ts +1 -0
  21. package/dist/lang/ast/expressions/constant-expression.js +3 -0
  22. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +3 -7
  23. package/dist/lang/ast/expressions/expr-aggregate-function.js +50 -54
  24. package/dist/lang/ast/expressions/expr-cast.js +2 -4
  25. package/dist/lang/ast/expressions/expr-func.js +1 -1
  26. package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
  27. package/dist/lang/ast/expressions/expr-record-literal.d.ts +16 -0
  28. package/dist/lang/ast/expressions/expr-record-literal.js +57 -0
  29. package/dist/lang/ast/expressions/expr-time-extract.js +3 -3
  30. package/dist/lang/ast/expressions/expr-time.d.ts +3 -3
  31. package/dist/lang/ast/expressions/expr-time.js +1 -1
  32. package/dist/lang/ast/expressions/time-literal.d.ts +6 -6
  33. package/dist/lang/ast/expressions/time-literal.js +1 -1
  34. package/dist/lang/ast/field-space/column-space-field.d.ts +6 -5
  35. package/dist/lang/ast/field-space/column-space-field.js +7 -4
  36. package/dist/lang/ast/field-space/dynamic-space.d.ts +8 -6
  37. package/dist/lang/ast/field-space/dynamic-space.js +35 -11
  38. package/dist/lang/ast/field-space/index-field-space.js +6 -3
  39. package/dist/lang/ast/field-space/ir-view-field.d.ts +1 -0
  40. package/dist/lang/ast/field-space/ir-view-field.js +3 -1
  41. package/dist/lang/ast/field-space/join-space-field.d.ts +2 -2
  42. package/dist/lang/ast/field-space/join-space-field.js +2 -2
  43. package/dist/lang/ast/field-space/parameter-space.d.ts +1 -0
  44. package/dist/lang/ast/field-space/parameter-space.js +4 -1
  45. package/dist/lang/ast/field-space/query-input-space.d.ts +4 -4
  46. package/dist/lang/ast/field-space/query-input-space.js +3 -5
  47. package/dist/lang/ast/field-space/query-spaces.d.ts +4 -4
  48. package/dist/lang/ast/field-space/query-spaces.js +1 -1
  49. package/dist/lang/ast/field-space/reference-field.js +10 -8
  50. package/dist/lang/ast/field-space/refined-space.d.ts +2 -2
  51. package/dist/lang/ast/field-space/static-space.d.ts +14 -5
  52. package/dist/lang/ast/field-space/static-space.js +45 -20
  53. package/dist/lang/ast/field-space/struct-space-field-base.d.ts +6 -5
  54. package/dist/lang/ast/field-space/struct-space-field-base.js +12 -4
  55. package/dist/lang/ast/index.d.ts +2 -1
  56. package/dist/lang/ast/index.js +2 -1
  57. package/dist/lang/ast/query-builders/index-builder.d.ts +2 -2
  58. package/dist/lang/ast/query-builders/project-builder.d.ts +2 -2
  59. package/dist/lang/ast/query-builders/reduce-builder.d.ts +2 -2
  60. package/dist/lang/ast/query-elements/query-arrow.js +2 -2
  61. package/dist/lang/ast/query-elements/query-head-struct.d.ts +2 -2
  62. package/dist/lang/ast/query-elements/query-head-struct.js +2 -2
  63. package/dist/lang/ast/query-elements/query-raw.js +2 -2
  64. package/dist/lang/ast/query-elements/query-reference.js +1 -1
  65. package/dist/lang/ast/query-items/field-declaration.d.ts +8 -6
  66. package/dist/lang/ast/query-items/field-declaration.js +66 -24
  67. package/dist/lang/ast/query-properties/qop-desc.d.ts +2 -2
  68. package/dist/lang/ast/query-properties/qop-desc.js +1 -1
  69. package/dist/lang/ast/source-elements/named-source.d.ts +4 -4
  70. package/dist/lang/ast/source-elements/named-source.js +16 -8
  71. package/dist/lang/ast/source-elements/query-source.d.ts +3 -3
  72. package/dist/lang/ast/source-elements/query-source.js +5 -2
  73. package/dist/lang/ast/source-elements/refined-source.d.ts +3 -3
  74. package/dist/lang/ast/source-elements/refined-source.js +4 -4
  75. package/dist/lang/ast/source-elements/source.d.ts +2 -2
  76. package/dist/lang/ast/source-elements/source.js +2 -2
  77. package/dist/lang/ast/source-elements/sql-source.d.ts +4 -4
  78. package/dist/lang/ast/source-elements/sql-source.js +6 -6
  79. package/dist/lang/ast/source-elements/table-source.d.ts +2 -2
  80. package/dist/lang/ast/source-elements/table-source.js +1 -1
  81. package/dist/lang/ast/source-properties/{joins.d.ts → join.d.ts} +11 -14
  82. package/dist/lang/ast/source-properties/{joins.js → join.js} +35 -52
  83. package/dist/lang/ast/source-query-elements/sq-reference.js +6 -5
  84. package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
  85. package/dist/lang/ast/statements/define-source.js +1 -1
  86. package/dist/lang/ast/struct-utils.d.ts +3 -3
  87. package/dist/lang/ast/struct-utils.js +12 -3
  88. package/dist/lang/ast/time-utils.d.ts +3 -3
  89. package/dist/lang/ast/types/document-compile-result.d.ts +2 -2
  90. package/dist/lang/ast/types/expression-def.js +4 -4
  91. package/dist/lang/ast/types/field-space.d.ts +8 -3
  92. package/dist/lang/ast/types/lookup-result.d.ts +8 -5
  93. package/dist/lang/ast/types/malloy-element.d.ts +3 -3
  94. package/dist/lang/ast/types/malloy-element.js +10 -21
  95. package/dist/lang/ast/types/op-desc.d.ts +2 -2
  96. package/dist/lang/ast/types/pipeline-comp.d.ts +2 -2
  97. package/dist/lang/ast/types/query-comp.d.ts +3 -3
  98. package/dist/lang/ast/types/query-extend-property.d.ts +1 -2
  99. package/dist/lang/ast/types/query-extend-property.js +4 -2
  100. package/dist/lang/ast/types/source-property.d.ts +2 -2
  101. package/dist/lang/ast/types/source-property.js +2 -2
  102. package/dist/lang/ast/types/space-field.d.ts +10 -3
  103. package/dist/lang/ast/types/space-field.js +11 -2
  104. package/dist/lang/ast/types/time-result.d.ts +2 -2
  105. package/dist/lang/ast/view-elements/qop-desc-view.d.ts +3 -3
  106. package/dist/lang/ast/view-elements/qop-desc-view.js +1 -1
  107. package/dist/lang/ast/view-elements/reference-view.d.ts +4 -4
  108. package/dist/lang/ast/view-elements/reference-view.js +2 -6
  109. package/dist/lang/ast/view-elements/view-refine.d.ts +2 -2
  110. package/dist/lang/index.d.ts +1 -1
  111. package/dist/lang/lib/Malloy/MalloyParser.d.ts +54 -21
  112. package/dist/lang/lib/Malloy/MalloyParser.js +1647 -1457
  113. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +57 -9
  114. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +35 -5
  115. package/dist/lang/malloy-to-ast.d.ts +4 -4
  116. package/dist/lang/malloy-to-ast.js +32 -4
  117. package/dist/lang/parse-log.d.ts +5 -9
  118. package/dist/lang/parse-malloy.d.ts +10 -10
  119. package/dist/lang/parse-malloy.js +2 -1
  120. package/dist/lang/test/annotation.spec.js +7 -1
  121. package/dist/lang/test/field-symbols.spec.js +21 -25
  122. package/dist/lang/test/imports.spec.js +12 -10
  123. package/dist/lang/test/lenses.spec.js +2 -2
  124. package/dist/lang/test/model_serialization.spec.d.ts +4 -4
  125. package/dist/lang/test/model_serialization.spec.js +19 -31
  126. package/dist/lang/test/parse.spec.js +3 -4
  127. package/dist/lang/test/query.spec.js +3 -2
  128. package/dist/lang/test/source.spec.js +7 -0
  129. package/dist/lang/test/sql-block.spec.js +8 -19
  130. package/dist/lang/test/test-translator.d.ts +4 -4
  131. package/dist/lang/test/test-translator.js +53 -61
  132. package/dist/lang/translate-response.d.ts +3 -3
  133. package/dist/malloy.d.ts +31 -149
  134. package/dist/malloy.js +111 -269
  135. package/dist/model/malloy_query.d.ts +25 -23
  136. package/dist/model/malloy_query.js +262 -323
  137. package/dist/model/malloy_types.d.ts +145 -155
  138. package/dist/model/malloy_types.js +81 -84
  139. package/dist/model/sql_block.d.ts +4 -4
  140. package/dist/model/sql_block.js +9 -12
  141. package/dist/tags.js +2 -2
  142. package/dist/version.d.ts +1 -0
  143. package/dist/version.js +6 -0
  144. package/package.json +3 -2
  145. package/dist/lang/ast/space-seed.d.ts +0 -16
  146. package/dist/lang/ast/space-seed.js +0 -59
@@ -13,6 +13,7 @@ export declare class ParameterSpace implements FieldSpace {
13
13
  entry(name: string): SpaceEntry | undefined;
14
14
  lookup(symbol: FieldName[]): LookupResult;
15
15
  entries(): [string, SpaceEntry][];
16
+ dialectName(): string;
16
17
  dialectObj(): Dialect | undefined;
17
18
  isQueryFieldSpace(): this is QueryFieldSpace;
18
19
  }
@@ -60,13 +60,16 @@ class ParameterSpace {
60
60
  return {
61
61
  found: entry,
62
62
  error: undefined,
63
- relationship: [],
63
+ joinPath: [],
64
64
  isOutputField: false,
65
65
  };
66
66
  }
67
67
  entries() {
68
68
  return Object.entries(this._map);
69
69
  }
70
+ dialectName() {
71
+ return '~parameter-space-unknown-dialect~';
72
+ }
70
73
  dialectObj() {
71
74
  return undefined;
72
75
  }
@@ -5,9 +5,9 @@
5
5
  * expressions in the query is called the "input space". There is a
6
6
  * specialized QuerySpace for each type of query operation.
7
7
  */
8
+ import { SourceDef } from '../../../model';
8
9
  import { AtomicFieldDeclaration } from '../query-items/field-declaration';
9
- import { Join } from '../source-properties/joins';
10
- import { SourceSpec } from '../space-seed';
10
+ import { Join } from '../source-properties/join';
11
11
  import { QueryFieldSpace } from '../types/field-space';
12
12
  import { QueryOperationSpace } from './query-spaces';
13
13
  import { RefinedSpace } from './refined-space';
@@ -20,9 +20,9 @@ export declare class QueryInputSpace extends RefinedSpace implements QueryFieldS
20
20
  * @param input The source which might be extended
21
21
  * @param queryOutput MUST BE A QuerySpace
22
22
  */
23
- constructor(input: SourceSpec, queryOutput: QueryOperationSpace);
23
+ constructor(input: SourceDef, queryOutput: QueryOperationSpace);
24
24
  extendSource(extendField: Join | AtomicFieldDeclaration): void;
25
- isQueryFieldSpace(): boolean;
25
+ isQueryFieldSpace(): this is QueryFieldSpace;
26
26
  outputSpace(): QueryOperationSpace;
27
27
  inputSpace(): this;
28
28
  }
@@ -23,8 +23,7 @@
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.QueryInputSpace = void 0;
26
- const joins_1 = require("../source-properties/joins");
27
- const space_seed_1 = require("../space-seed");
26
+ const join_1 = require("../source-properties/join");
28
27
  const refined_space_1 = require("./refined-space");
29
28
  class QueryInputSpace extends refined_space_1.RefinedSpace {
30
29
  /**
@@ -34,14 +33,13 @@ class QueryInputSpace extends refined_space_1.RefinedSpace {
34
33
  * @param queryOutput MUST BE A QuerySpace
35
34
  */
36
35
  constructor(input, queryOutput) {
37
- const inputSpace = new space_seed_1.SpaceSeed(input);
38
- super(inputSpace.structDef);
36
+ super(input);
39
37
  this.queryOutput = queryOutput;
40
38
  this.extendList = [];
41
39
  }
42
40
  extendSource(extendField) {
43
41
  this.pushFields(extendField);
44
- if (extendField instanceof joins_1.Join) {
42
+ if (extendField instanceof join_1.Join) {
45
43
  this.extendList.push(extendField.name.refString);
46
44
  }
47
45
  else {
@@ -1,5 +1,5 @@
1
1
  import * as model from '../../../model/malloy_types';
2
- import { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
2
+ import { FieldName, QueryFieldSpace, SourceFieldSpace } from '../types/field-space';
3
3
  import { MalloyElement } from '../types/malloy-element';
4
4
  import { WildcardFieldReference } from '../query-items/field-references';
5
5
  import { RefinedSpace } from './refined-space';
@@ -13,13 +13,13 @@ import { LogMessageOptions, MessageCode, MessageParameterType } from '../../pars
13
13
  * created and paired when a QueryOperationSpace is created.
14
14
  */
15
15
  export declare abstract class QueryOperationSpace extends RefinedSpace implements QueryFieldSpace {
16
- readonly queryInputSpace: FieldSpace;
16
+ readonly queryInputSpace: SourceFieldSpace;
17
17
  readonly nestParent: QueryOperationSpace | undefined;
18
18
  readonly astEl: MalloyElement;
19
19
  protected exprSpace: QueryInputSpace;
20
20
  abstract readonly segmentType: 'reduce' | 'project' | 'index';
21
21
  expandedWild: Record<string, string[]>;
22
- constructor(queryInputSpace: FieldSpace, refineThis: model.PipeSegment | undefined, nestParent: QueryOperationSpace | undefined, astEl: MalloyElement);
22
+ constructor(queryInputSpace: SourceFieldSpace, refineThis: model.PipeSegment | undefined, nestParent: QueryOperationSpace | undefined, astEl: MalloyElement);
23
23
  abstract addRefineFromFields(refineThis: model.PipeSegment): void;
24
24
  logError<T extends MessageCode>(code: T, parameters: MessageParameterType<T>, options?: Omit<LogMessageOptions, 'severity'>): T;
25
25
  inputSpace(): QueryInputSpace;
@@ -34,7 +34,7 @@ export declare abstract class QuerySpace extends QueryOperationSpace {
34
34
  getQuerySegment(rf: model.QuerySegment | undefined): model.QuerySegment;
35
35
  getPipeSegment(refineFrom: model.QuerySegment | undefined): model.PipeSegment;
36
36
  lookup(path: FieldName[]): LookupResult;
37
- isQueryFieldSpace(): boolean;
37
+ isQueryFieldSpace(): this is QueryFieldSpace;
38
38
  }
39
39
  export declare class ReduceFieldSpace extends QuerySpace {
40
40
  readonly segmentType = "reduce";
@@ -68,7 +68,7 @@ class QueryOperationSpace extends refined_space_1.RefinedSpace {
68
68
  this.nestParent = nestParent;
69
69
  this.astEl = astEl;
70
70
  this.expandedWild = {};
71
- this.exprSpace = new query_input_space_1.QueryInputSpace(queryInputSpace, this);
71
+ this.exprSpace = new query_input_space_1.QueryInputSpace(queryInputSpace.structDef(), this);
72
72
  if (refineThis)
73
73
  this.addRefineFromFields(refineThis);
74
74
  }
@@ -58,15 +58,17 @@ class ReferenceField extends space_field_1.SpaceField {
58
58
  : { type: 'fieldref', path };
59
59
  this.queryFieldDef = queryFieldDef;
60
60
  const refTo = this.referenceTo;
61
- if (refTo instanceof space_field_1.SpaceField && refTo.haveFieldDef) {
62
- const origFd = refTo.haveFieldDef;
63
- const notes = this.fieldRef.note;
64
- if (origFd.annotation || notes) {
65
- const annotation = notes || {};
66
- if (origFd.annotation) {
67
- annotation.inherits = origFd.annotation;
61
+ if (refTo instanceof space_field_1.SpaceField) {
62
+ const origFd = refTo.constructorFieldDef();
63
+ if (origFd) {
64
+ const notes = this.fieldRef.note;
65
+ if (origFd.annotation || notes) {
66
+ const annotation = notes || {};
67
+ if (origFd.annotation) {
68
+ annotation.inherits = origFd.annotation;
69
+ }
70
+ this.queryFieldDef.annotation = annotation;
68
71
  }
69
- this.queryFieldDef.annotation = annotation;
70
72
  }
71
73
  }
72
74
  }
@@ -1,4 +1,4 @@
1
- import { StructDef } from '../../../model/malloy_types';
1
+ import { SourceDef } from '../../../model/malloy_types';
2
2
  import { FieldListEdit } from '../source-properties/field-list-edit';
3
3
  import { DynamicSpace } from './dynamic-space';
4
4
  import { MalloyElement } from '../types/malloy-element';
@@ -9,6 +9,6 @@ export declare class RefinedSpace extends DynamicSpace {
9
9
  * @param from A structdef which seeds this space
10
10
  * @param choose A accept/except edit of the "from" fields
11
11
  */
12
- static filteredFrom(from: StructDef, choose: FieldListEdit | undefined, parameters: ParameterSpace | undefined): RefinedSpace;
12
+ static filteredFrom(from: SourceDef, choose: FieldListEdit | undefined, parameters: ParameterSpace | undefined): RefinedSpace;
13
13
  pushFields(...defs: MalloyElement[]): void;
14
14
  }
@@ -1,15 +1,17 @@
1
1
  import { Dialect } from '../../../dialect/dialect';
2
- import { FieldDef, StructDef } from '../../../model/malloy_types';
2
+ import { FieldDef, StructDef, SourceDef, JoinFieldDef } from '../../../model/malloy_types';
3
3
  import { SpaceEntry } from '../types/space-entry';
4
4
  import { LookupResult } from '../types/lookup-result';
5
- import { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
5
+ import { FieldName, FieldSpace, QueryFieldSpace, SourceFieldSpace } from '../types/field-space';
6
6
  import { SpaceField } from '../types/space-field';
7
7
  import { StructSpaceFieldBase } from './struct-space-field-base';
8
8
  export declare class StaticSpace implements FieldSpace {
9
+ protected fromStruct: StructDef;
9
10
  readonly type = "fieldSpace";
10
11
  private memoMap?;
11
- protected fromStruct: StructDef;
12
- constructor(sourceStructDef: StructDef);
12
+ get dialect(): string;
13
+ constructor(fromStruct: StructDef);
14
+ dialectName(): string;
13
15
  dialectObj(): Dialect | undefined;
14
16
  defToSpaceField(from: FieldDef): SpaceField;
15
17
  private get map();
@@ -24,6 +26,13 @@ export declare class StaticSpace implements FieldSpace {
24
26
  isQueryFieldSpace(): this is QueryFieldSpace;
25
27
  }
26
28
  export declare class StructSpaceField extends StructSpaceFieldBase {
27
- constructor(def: StructDef);
29
+ private parentDialect;
30
+ constructor(def: JoinFieldDef, dialect: string);
28
31
  get fieldSpace(): FieldSpace;
29
32
  }
33
+ export declare class StaticSourceSpace extends StaticSpace implements SourceFieldSpace {
34
+ protected source: SourceDef;
35
+ constructor(source: SourceDef);
36
+ structDef(): SourceDef;
37
+ emptyStructDef(): SourceDef;
38
+ }
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.StructSpaceField = exports.StaticSpace = void 0;
25
+ exports.StaticSourceSpace = exports.StructSpaceField = exports.StaticSpace = void 0;
26
26
  const dialect_map_1 = require("../../../dialect/dialect_map");
27
27
  const malloy_types_1 = require("../../../model/malloy_types");
28
28
  const space_param_1 = require("../types/space-param");
@@ -31,9 +31,15 @@ const struct_space_field_base_1 = require("./struct-space-field-base");
31
31
  const column_space_field_1 = require("./column-space-field");
32
32
  const ir_view_field_1 = require("./ir-view-field");
33
33
  class StaticSpace {
34
- constructor(sourceStructDef) {
34
+ get dialect() {
35
+ return this.fromStruct.dialect;
36
+ }
37
+ constructor(fromStruct) {
38
+ this.fromStruct = fromStruct;
35
39
  this.type = 'fieldSpace';
36
- this.fromStruct = sourceStructDef;
40
+ }
41
+ dialectName() {
42
+ return this.fromStruct.dialect;
37
43
  }
38
44
  dialectObj() {
39
45
  try {
@@ -44,8 +50,8 @@ class StaticSpace {
44
50
  }
45
51
  }
46
52
  defToSpaceField(from) {
47
- if (from.type === 'struct') {
48
- return new StructSpaceField(from);
53
+ if ((0, malloy_types_1.isJoined)(from)) {
54
+ return new StructSpaceField(from, this.fromStruct.dialect);
49
55
  }
50
56
  else if ((0, malloy_types_1.isTurtleDef)(from)) {
51
57
  return new ir_view_field_1.IRViewField(this, from);
@@ -59,10 +65,12 @@ class StaticSpace {
59
65
  const name = f.as || f.name;
60
66
  this.memoMap[name] = this.defToSpaceField(f);
61
67
  }
62
- if (this.fromStruct.parameters) {
63
- for (const [paramName, paramDef] of Object.entries(this.fromStruct.parameters)) {
64
- if (!(paramName in this.memoMap)) {
65
- this.memoMap[paramName] = new space_param_1.DefinedParameter(paramDef);
68
+ if ((0, malloy_types_1.isSourceDef)(this.fromStruct)) {
69
+ if (this.fromStruct.parameters) {
70
+ for (const [paramName, paramDef] of Object.entries(this.fromStruct.parameters)) {
71
+ if (!(paramName in this.memoMap)) {
72
+ this.memoMap[paramName] = new space_param_1.DefinedParameter(paramDef);
73
+ }
66
74
  }
67
75
  }
68
76
  }
@@ -89,7 +97,12 @@ class StaticSpace {
89
97
  return this.fromStruct;
90
98
  }
91
99
  emptyStructDef() {
92
- return { ...this.fromStruct, fields: [], parameters: {} };
100
+ const ret = { ...this.fromStruct };
101
+ if ((0, malloy_types_1.isSourceDef)(ret)) {
102
+ ret.parameters = {};
103
+ }
104
+ ret.fields = [];
105
+ return ret;
93
106
  }
94
107
  lookup(path) {
95
108
  const head = path[0];
@@ -117,13 +130,8 @@ class StaticSpace {
117
130
  });
118
131
  }
119
132
  }
120
- const relationship = found instanceof struct_space_field_base_1.StructSpaceFieldBase
121
- ? [
122
- {
123
- name: head.refString,
124
- structRelationship: found.structRelationship,
125
- },
126
- ]
133
+ const joinPath = found instanceof struct_space_field_base_1.StructSpaceFieldBase
134
+ ? [{ ...found.joinPathElement, name: head.refString }]
127
135
  : [];
128
136
  if (rest.length) {
129
137
  if (found instanceof struct_space_field_base_1.StructSpaceFieldBase) {
@@ -131,7 +139,7 @@ class StaticSpace {
131
139
  if (restResult.found) {
132
140
  return {
133
141
  ...restResult,
134
- relationship: [...relationship, ...restResult.relationship],
142
+ joinPath: [...joinPath, ...restResult.joinPath],
135
143
  };
136
144
  }
137
145
  else {
@@ -146,7 +154,7 @@ class StaticSpace {
146
154
  found: undefined,
147
155
  };
148
156
  }
149
- return { found, error: undefined, relationship, isOutputField: false };
157
+ return { found, error: undefined, joinPath, isOutputField: false };
150
158
  }
151
159
  isQueryFieldSpace() {
152
160
  return false;
@@ -154,12 +162,29 @@ class StaticSpace {
154
162
  }
155
163
  exports.StaticSpace = StaticSpace;
156
164
  class StructSpaceField extends struct_space_field_base_1.StructSpaceFieldBase {
157
- constructor(def) {
165
+ constructor(def, dialect) {
158
166
  super(def);
167
+ this.parentDialect = dialect;
159
168
  }
160
169
  get fieldSpace() {
161
170
  return new StaticSpace(this.sourceDef);
162
171
  }
163
172
  }
164
173
  exports.StructSpaceField = StructSpaceField;
174
+ class StaticSourceSpace extends StaticSpace {
175
+ constructor(source) {
176
+ super(source);
177
+ this.source = source;
178
+ }
179
+ structDef() {
180
+ return this.source;
181
+ }
182
+ emptyStructDef() {
183
+ const ret = { ...this.source };
184
+ ret.parameters = {};
185
+ ret.fields = [];
186
+ return ret;
187
+ }
188
+ }
189
+ exports.StaticSourceSpace = StaticSourceSpace;
165
190
  //# sourceMappingURL=static-space.js.map
@@ -1,11 +1,12 @@
1
- import { FieldDef, StructDef, StructRelationship, TypeDesc } from '../../../model/malloy_types';
1
+ import { JoinFieldDef, TypeDesc } from '../../../model/malloy_types';
2
2
  import { FieldSpace } from '../types/field-space';
3
+ import { JoinPathElement } from '../types/lookup-result';
3
4
  import { SpaceField } from '../types/space-field';
4
5
  export declare abstract class StructSpaceFieldBase extends SpaceField {
5
- protected sourceDef: StructDef;
6
- constructor(sourceDef: StructDef);
6
+ protected sourceDef: JoinFieldDef;
7
+ constructor(sourceDef: JoinFieldDef);
7
8
  abstract get fieldSpace(): FieldSpace;
8
- get structRelationship(): StructRelationship;
9
- fieldDef(): FieldDef;
9
+ fieldDef(): JoinFieldDef;
10
+ get joinPathElement(): JoinPathElement;
10
11
  typeDesc(): TypeDesc;
11
12
  }
@@ -29,14 +29,22 @@ class StructSpaceFieldBase extends space_field_1.SpaceField {
29
29
  super();
30
30
  this.sourceDef = sourceDef;
31
31
  }
32
- get structRelationship() {
33
- return this.sourceDef.structRelationship;
34
- }
35
32
  fieldDef() {
36
33
  return this.sourceDef;
37
34
  }
35
+ get joinPathElement() {
36
+ return {
37
+ name: this.sourceDef.as || this.sourceDef.name,
38
+ joinType: this.sourceDef.join,
39
+ joinElementType: this.sourceDef.type,
40
+ };
41
+ }
38
42
  typeDesc() {
39
- return { dataType: 'struct', expressionType: 'scalar', evalSpace: 'input' };
43
+ return {
44
+ dataType: this.sourceDef.type,
45
+ expressionType: 'scalar',
46
+ evalSpace: 'input',
47
+ };
40
48
  }
41
49
  }
42
50
  exports.StructSpaceFieldBase = StructSpaceFieldBase;
@@ -52,6 +52,7 @@ export * from './expressions/time-literal';
52
52
  export * from './expressions/partial-compare';
53
53
  export * from './expressions/partition_by';
54
54
  export * from './expressions/pick-when';
55
+ export * from './expressions/expr-record-literal';
55
56
  export * from './expressions/range';
56
57
  export * from './expressions/time-frame';
57
58
  export * from './expressions/top-by';
@@ -78,7 +79,7 @@ export * from './query-properties/extend';
78
79
  export * from './query-properties/filters';
79
80
  export * from './query-properties/group-by';
80
81
  export * from './query-properties/indexing';
81
- export * from './source-properties/joins';
82
+ export * from './source-properties/join';
82
83
  export * from './source-properties/view-field-declaration';
83
84
  export * from './query-properties/limit';
84
85
  export * from './source-properties/measures';
@@ -90,6 +90,7 @@ __exportStar(require("./expressions/time-literal"), exports);
90
90
  __exportStar(require("./expressions/partial-compare"), exports);
91
91
  __exportStar(require("./expressions/partition_by"), exports);
92
92
  __exportStar(require("./expressions/pick-when"), exports);
93
+ __exportStar(require("./expressions/expr-record-literal"), exports);
93
94
  __exportStar(require("./expressions/range"), exports);
94
95
  __exportStar(require("./expressions/time-frame"), exports);
95
96
  __exportStar(require("./expressions/top-by"), exports);
@@ -116,7 +117,7 @@ __exportStar(require("./query-properties/extend"), exports);
116
117
  __exportStar(require("./query-properties/filters"), exports);
117
118
  __exportStar(require("./query-properties/group-by"), exports);
118
119
  __exportStar(require("./query-properties/indexing"), exports);
119
- __exportStar(require("./source-properties/joins"), exports);
120
+ __exportStar(require("./source-properties/join"), exports);
120
121
  __exportStar(require("./source-properties/view-field-declaration"), exports);
121
122
  __exportStar(require("./query-properties/limit"), exports);
122
123
  __exportStar(require("./source-properties/measures"), exports);
@@ -1,5 +1,5 @@
1
1
  import { FilterCondition, PipeSegment, Sampling } from '../../../model/malloy_types';
2
- import { FieldName, FieldSpace } from '../types/field-space';
2
+ import { FieldName, SourceFieldSpace } from '../types/field-space';
3
3
  import { Limit } from '../query-properties/limit';
4
4
  import { IndexFieldSpace } from '../field-space/index-field-space';
5
5
  import { QueryProperty } from '../types/query-property';
@@ -15,7 +15,7 @@ export declare class IndexBuilder implements QueryBuilder {
15
15
  resultFS: IndexFieldSpace;
16
16
  inputFS: QueryInputSpace;
17
17
  readonly type = "index";
18
- constructor(inputFS: FieldSpace, refineThis: PipeSegment | undefined, isNestIn: QueryOperationSpace | undefined, astEl: MalloyElement);
18
+ constructor(inputFS: SourceFieldSpace, refineThis: PipeSegment | undefined, isNestIn: QueryOperationSpace | undefined, astEl: MalloyElement);
19
19
  execute(qp: QueryProperty): void;
20
20
  finalize(from: PipeSegment | undefined): PipeSegment;
21
21
  }
@@ -1,5 +1,5 @@
1
1
  import { PipeSegment } from '../../../model/malloy_types';
2
- import { FieldSpace } from '../types/field-space';
2
+ import { SourceFieldSpace } from '../types/field-space';
3
3
  import { ProjectFieldSpace } from '../field-space/project-field-space';
4
4
  import { QueryProperty } from '../types/query-property';
5
5
  import { QuerySegmentBuilder } from './reduce-builder';
@@ -11,7 +11,7 @@ export declare class ProjectBuilder extends QuerySegmentBuilder implements Query
11
11
  resultFS: ProjectFieldSpace;
12
12
  inputFS: QueryInputSpace;
13
13
  readonly type = "project";
14
- constructor(baseFS: FieldSpace, refineThis: PipeSegment | undefined, isNestIn: QueryOperationSpace | undefined, astEl: MalloyElement);
14
+ constructor(baseFS: SourceFieldSpace, refineThis: PipeSegment | undefined, isNestIn: QueryOperationSpace | undefined, astEl: MalloyElement);
15
15
  execute(qp: QueryProperty): void;
16
16
  finalize(fromSeg: PipeSegment | undefined): PipeSegment;
17
17
  }
@@ -1,5 +1,5 @@
1
1
  import { FilterCondition, PipeSegment, QuerySegment } from '../../../model/malloy_types';
2
- import { FieldSpace } from '../types/field-space';
2
+ import { SourceFieldSpace } from '../types/field-space';
3
3
  import { Ordering } from '../query-properties/ordering';
4
4
  import { Top } from '../query-properties/top';
5
5
  import { QueryProperty } from '../types/query-property';
@@ -22,6 +22,6 @@ export declare class ReduceBuilder extends QuerySegmentBuilder implements QueryB
22
22
  inputFS: QueryInputSpace;
23
23
  resultFS: ReduceFieldSpace;
24
24
  readonly type = "grouping";
25
- constructor(baseFS: FieldSpace, refineThis: PipeSegment | undefined, isNestIn: QueryOperationSpace | undefined, astEl: MalloyElement);
25
+ constructor(baseFS: SourceFieldSpace, refineThis: PipeSegment | undefined, isNestIn: QueryOperationSpace | undefined, astEl: MalloyElement);
26
26
  finalize(fromSeg: PipeSegment | undefined): PipeSegment;
27
27
  }
@@ -48,7 +48,7 @@ class QueryArrow extends query_base_1.QueryBase {
48
48
  // the view as the head, or the scalar as the head (if scalar lenses is enabled)
49
49
  const invoked = isRefOk
50
50
  ? this.source.structRef(undefined)
51
- : { structRef: this.source.structDef(undefined) };
51
+ : { structRef: this.source.getSourceDef(undefined) };
52
52
  queryBase = {
53
53
  type: 'query',
54
54
  ...invoked,
@@ -57,7 +57,7 @@ class QueryArrow extends query_base_1.QueryBase {
57
57
  };
58
58
  inputStruct = (0, malloy_types_1.refIsStructDef)(invoked.structRef)
59
59
  ? invoked.structRef
60
- : this.source.structDef(undefined);
60
+ : this.source.getSourceDef(undefined);
61
61
  fieldSpace = new static_space_1.StaticSpace(inputStruct);
62
62
  }
63
63
  else {
@@ -1,4 +1,4 @@
1
- import { Argument, InvokedStructRef, StructDef, StructRef } from '../../../model/malloy_types';
1
+ import { Argument, InvokedStructRef, SourceDef, StructRef } from '../../../model/malloy_types';
2
2
  import { Source } from '../source-elements/source';
3
3
  import { ParameterSpace } from '../field-space/parameter-space';
4
4
  export declare class QueryHeadStruct extends Source {
@@ -7,5 +7,5 @@ export declare class QueryHeadStruct extends Source {
7
7
  elementType: string;
8
8
  constructor(fromRef: StructRef, sourceArguments: Record<string, Argument> | undefined);
9
9
  structRef(): InvokedStructRef;
10
- structDef(parameterSpace: ParameterSpace | undefined): StructDef;
10
+ getSourceDef(parameterSpace: ParameterSpace | undefined): SourceDef;
11
11
  }
@@ -36,13 +36,13 @@ class QueryHeadStruct extends source_1.Source {
36
36
  structRef() {
37
37
  return { structRef: this.fromRef };
38
38
  }
39
- structDef(parameterSpace) {
39
+ getSourceDef(parameterSpace) {
40
40
  if ((0, malloy_types_1.refIsStructDef)(this.fromRef)) {
41
41
  return this.fromRef;
42
42
  }
43
43
  const ns = new named_source_1.NamedSource(this.fromRef, this.sourceArguments, undefined);
44
44
  this.has({ exploreReference: ns });
45
- return ns.structDef(parameterSpace);
45
+ return ns.getSourceDef(parameterSpace);
46
46
  }
47
47
  }
48
48
  exports.QueryHeadStruct = QueryHeadStruct;
@@ -42,10 +42,10 @@ class QueryRaw extends malloy_element_1.MalloyElement {
42
42
  queryComp(isRefOk) {
43
43
  const invoked = isRefOk
44
44
  ? this.source.structRef(undefined)
45
- : { structRef: this.source.structDef(undefined) };
45
+ : { structRef: this.source.getSourceDef(undefined) };
46
46
  const structDef = (0, malloy_types_1.refIsStructDef)(invoked.structRef)
47
47
  ? invoked.structRef
48
- : this.source.structDef(undefined);
48
+ : this.source.getSourceDef(undefined);
49
49
  return {
50
50
  query: {
51
51
  type: 'query',
@@ -56,7 +56,7 @@ class QueryReference extends malloy_element_1.MalloyElement {
56
56
  if (query.type === 'query') {
57
57
  const queryHead = new query_head_struct_1.QueryHeadStruct(query.structRef, query.sourceArguments);
58
58
  this.has({ queryHead: queryHead });
59
- const inputStruct = queryHead.structDef(undefined);
59
+ const inputStruct = queryHead.getSourceDef(undefined);
60
60
  const outputStruct = (0, struct_utils_1.getFinalStruct)(this, inputStruct, query.pipeline);
61
61
  const unRefedQuery = isRefOk
62
62
  ? query
@@ -1,5 +1,5 @@
1
1
  import { Dialect } from '../../../dialect/dialect';
2
- import { Annotation, FieldTypeDef, StructDef, TypeDesc, FieldDef, QueryFieldDef } from '../../../model/malloy_types';
2
+ import { Annotation, StructDef, TypeDesc, FieldDef, AtomicFieldDef } from '../../../model/malloy_types';
3
3
  import { ExprValue } from '../types/expr-value';
4
4
  import { ExpressionDef } from '../types/expression-def';
5
5
  import { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
@@ -18,10 +18,10 @@ export declare abstract class AtomicFieldDeclaration extends MalloyElement imple
18
18
  extendNote: typeof extendNoteMethod;
19
19
  note?: Annotation;
20
20
  constructor(expr: ExpressionDef, defineName: string, exprSrc?: string | undefined);
21
- fieldDef(fs: FieldSpace, exprName: string): FieldTypeDef;
21
+ fieldDef(fs: FieldSpace, exprName: string): FieldDef;
22
22
  abstract typecheckExprValue(expr: ExprValue): void;
23
23
  executesInOutputSpace(): boolean;
24
- queryFieldDef(exprFS: FieldSpace, exprName: string): FieldTypeDef;
24
+ queryFieldDef(exprFS: FieldSpace, exprName: string): AtomicFieldDef;
25
25
  makeEntry(fs: DynamicSpace): void;
26
26
  }
27
27
  export declare class CalculateFieldDeclaration extends AtomicFieldDeclaration {
@@ -67,10 +67,11 @@ export declare class DefSpace implements FieldSpace {
67
67
  entry(name: string): SpaceEntry | undefined;
68
68
  lookup(symbol: FieldName[]): LookupResult;
69
69
  entries(): [string, SpaceEntry][];
70
+ dialectName(): string;
70
71
  dialectObj(): Dialect | undefined;
71
72
  isQueryFieldSpace(): this is QueryFieldSpace;
72
73
  outputSpace(): import("../field-space/query-spaces").QueryOperationSpace;
73
- inputSpace(): FieldSpace;
74
+ inputSpace(): import("../types/field-space").SourceFieldSpace;
74
75
  }
75
76
  export declare class FieldDefinitionValue extends SpaceField {
76
77
  readonly space: FieldSpace;
@@ -78,8 +79,9 @@ export declare class FieldDefinitionValue extends SpaceField {
78
79
  fieldName: string;
79
80
  constructor(space: FieldSpace, exprDef: AtomicFieldDeclaration);
80
81
  get name(): string;
82
+ private defInSource?;
81
83
  fieldDef(): FieldDef;
82
- private qfd?;
83
- getQueryFieldDef(fs: FieldSpace): QueryFieldDef;
84
+ private defInQuery?;
85
+ getQueryFieldDef(fs: FieldSpace): AtomicFieldDef;
84
86
  typeDesc(): TypeDesc;
85
87
  }