@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
@@ -79,27 +79,62 @@ class AtomicFieldDeclaration extends malloy_element_1.MalloyElement {
79
79
  retType = 'number';
80
80
  }
81
81
  if ((0, malloy_types_1.isAtomicFieldType)(retType) && retType !== 'error') {
82
- const template = {
83
- name: exprName,
84
- type: retType,
85
- location: this.location,
86
- };
87
- template.e = exprValue.value;
82
+ this.typecheckExprValue(exprValue);
83
+ let ret;
84
+ switch (retType) {
85
+ case 'date':
86
+ case 'timestamp': {
87
+ const timeRet = {
88
+ name: exprName,
89
+ type: retType,
90
+ location: this.location,
91
+ e: exprValue.value,
92
+ };
93
+ if ((0, granular_result_1.isGranularResult)(exprValue)) {
94
+ timeRet.timeframe = exprValue.timeframe;
95
+ }
96
+ ret = timeRet;
97
+ break;
98
+ }
99
+ case 'json':
100
+ case 'boolean':
101
+ case 'string':
102
+ case 'number':
103
+ case 'sql native': {
104
+ ret = {
105
+ type: retType,
106
+ name: exprName,
107
+ location: this.location,
108
+ e: exprValue.value,
109
+ };
110
+ break;
111
+ }
112
+ case 'record': {
113
+ const fields = [];
114
+ ret = {
115
+ type: 'record',
116
+ name: exprName,
117
+ location: this.location,
118
+ join: 'one',
119
+ fields,
120
+ e: exprValue.value,
121
+ dialect: exprFS.dialectName(),
122
+ };
123
+ break;
124
+ }
125
+ case 'array':
126
+ throw this.internalError('Cannot return an array result from a query (yet)');
127
+ }
88
128
  if (exprValue.expressionType) {
89
- template.expressionType = exprValue.expressionType;
129
+ ret.expressionType = exprValue.expressionType;
90
130
  }
91
- this.typecheckExprValue(exprValue);
92
131
  if (this.exprSrc) {
93
- template.code = this.exprSrc;
94
- }
95
- if ((0, granular_result_1.isGranularResult)(exprValue) &&
96
- (template.type === 'timestamp' || template.type === 'date')) {
97
- template.timeframe = exprValue.timeframe;
132
+ ret.code = this.exprSrc;
98
133
  }
99
134
  if (this.note) {
100
- template.annotation = this.note;
135
+ ret.annotation = this.note;
101
136
  }
102
- return template;
137
+ return ret;
103
138
  }
104
139
  const circularDef = exprFS instanceof DefSpace && exprFS.foundCircle;
105
140
  if (!circularDef) {
@@ -226,6 +261,9 @@ class DefSpace {
226
261
  entries() {
227
262
  return this.realFS.entries();
228
263
  }
264
+ dialectName() {
265
+ return this.realFS.dialectName();
266
+ }
229
267
  dialectObj() {
230
268
  return this.realFS.dialectObj();
231
269
  }
@@ -256,27 +294,31 @@ class FieldDefinitionValue extends space_field_1.SpaceField {
256
294
  get name() {
257
295
  return this.fieldName;
258
296
  }
259
- // A source will call this when it defines the field
260
297
  fieldDef() {
261
- if (!this.haveFieldDef) {
262
- this.haveFieldDef = this.exprDef.fieldDef(this.space, this.name);
298
+ let def = this.defInSource;
299
+ if (def === undefined) {
300
+ this.defInSource = def;
301
+ def = this.exprDef.fieldDef(this.space, this.name);
263
302
  }
264
- return this.haveFieldDef;
303
+ return def;
265
304
  }
266
305
  getQueryFieldDef(fs) {
267
- if (!this.qfd) {
306
+ if (!this.defInQuery) {
268
307
  const def = this.exprDef.queryFieldDef(fs, this.name);
269
- this.qfd = def;
308
+ this.defInQuery = def;
270
309
  }
271
- return this.qfd;
310
+ return this.defInQuery;
272
311
  }
273
312
  // If this is called before the expression has been evaluated, we don't
274
313
  // really know what type we have. However since we have the FieldSpace,
275
314
  // we can compile the expression to find out, this might result in
276
315
  // some expressions being compiled twice.
277
316
  typeDesc() {
278
- const typeFrom = this.qfd || this.fieldDef();
279
- return this.fieldTypeFromFieldDef(typeFrom);
317
+ const typeFrom = this.defInQuery || this.fieldDef();
318
+ if ((0, malloy_types_1.isAtomic)(typeFrom)) {
319
+ return this.fieldTypeFromFieldDef(typeFrom);
320
+ }
321
+ throw new Error(`Can't get typeDesc for ${typeFrom.type}`);
280
322
  }
281
323
  }
282
324
  exports.FieldDefinitionValue = FieldDefinitionValue;
@@ -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 { ListOf } from '../types/malloy-element';
4
4
  import { OpDesc } from '../types/op-desc';
5
5
  import { QueryProperty } from '../types/query-property';
@@ -12,5 +12,5 @@ export declare class QOpDesc extends ListOf<QueryProperty> {
12
12
  protected computeType(): QueryClass | undefined;
13
13
  refineFrom(existing: PipeSegment): void;
14
14
  private getBuilder;
15
- getOp(inputFS: FieldSpace, isNestIn: QueryOperationSpace | undefined): OpDesc;
15
+ getOp(inputFS: SourceFieldSpace, isNestIn: QueryOperationSpace | undefined): OpDesc;
16
16
  }
@@ -98,7 +98,7 @@ class QOpDesc extends malloy_element_1.ListOf {
98
98
  // TODO someday we'd like to get rid of the call to opOutputStruct here.
99
99
  // If the `build.resultFS` is correct, then we should be able to just use that
100
100
  // in a more direct way.
101
- new static_space_1.StaticSpace((0, struct_utils_1.opOutputStruct)(this, inputFS.structDef(), segment)),
101
+ new static_space_1.StaticSourceSpace((0, struct_utils_1.opOutputStruct)(this, inputFS.structDef(), segment)),
102
102
  };
103
103
  }
104
104
  }
@@ -1,4 +1,4 @@
1
- import { Argument, InvokedStructRef, StructDef } from '../../../model/malloy_types';
1
+ import { Argument, InvokedStructRef, SourceDef } from '../../../model/malloy_types';
2
2
  import { Source } from './source';
3
3
  import { ModelEntryReference } from '../types/malloy-element';
4
4
  import { Argument as HasArgument } from '../parameters/argument';
@@ -14,9 +14,9 @@ export declare class NamedSource extends Source {
14
14
  get refName(): string;
15
15
  structRef(parameterSpace: ParameterSpace | undefined): InvokedStructRef;
16
16
  refLogError<T extends MessageCode>(code: T, parameters: MessageParameterType<T>, options?: Omit<LogMessageOptions, 'severity'>): void;
17
- modelStruct(): StructDef | undefined;
17
+ modelStruct(): SourceDef | undefined;
18
18
  private evaluateArgumentsForRef;
19
19
  private evaluateArguments;
20
- structDef(parameterSpace: ParameterSpace | undefined): StructDef;
21
- withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): StructDef;
20
+ getSourceDef(parameterSpace: ParameterSpace | undefined): SourceDef;
21
+ withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): SourceDef;
22
22
  }
@@ -53,7 +53,7 @@ class NamedSource extends source_1.Source {
53
53
  // If we are not exporting the referenced structdef, don't use the reference
54
54
  if (modelEnt && !modelEnt.exported) {
55
55
  return {
56
- structRef: this.structDef(parameterSpace),
56
+ structRef: this.getSourceDef(parameterSpace),
57
57
  };
58
58
  }
59
59
  return {
@@ -78,7 +78,16 @@ class NamedSource extends source_1.Source {
78
78
  return;
79
79
  }
80
80
  if (entry.type === 'query') {
81
- this.logError('invalid-source-from-query', `Cannot construct a source from a query '${this.refName}'`);
81
+ // I don't understand under what circumstance this code would be
82
+ // executed, what Malloy you would write to generate this error,
83
+ // but the error exists so I am leaving it for now.
84
+ //
85
+ // Someone with time and courage should either remove this error
86
+ // because it isn't possible, or go ahead and make a source out
87
+ // of a query, which is a thing you can do, although when you
88
+ // do that it currently doesn't go through this path, so I don't
89
+ // know how you would test that change.
90
+ this.logError('invalid-source-from-query', `Cannot construct a source from query '${this.refName}'`);
82
91
  return;
83
92
  }
84
93
  else if (entry.type === 'function') {
@@ -89,14 +98,13 @@ class NamedSource extends source_1.Source {
89
98
  this.logError('invalid-source-from-connection', `Cannot construct a source from a connection '${this.refName}'`);
90
99
  return;
91
100
  }
92
- else if ((0, malloy_types_1.isSQLBlockStruct)(entry) && entry.declaredSQLBlock) {
93
- this.logError('invalid-source-from-sql-block', `Must use 'from_sql()' for sql source '${this.refName}'`);
94
- return;
95
- }
96
101
  else {
97
102
  (_a = this.document()) === null || _a === void 0 ? void 0 : _a.checkExperimentalDialect(this, entry.dialect);
103
+ if ((0, malloy_types_1.isSourceDef)(entry)) {
104
+ return { ...entry };
105
+ }
98
106
  }
99
- return { ...entry };
107
+ this.logError('invalid-source-source', `Cannot construct a source from a ${entry.type}`);
100
108
  }
101
109
  evaluateArgumentsForRef(parameterSpace) {
102
110
  const base = this.modelStruct();
@@ -152,7 +160,7 @@ class NamedSource extends source_1.Source {
152
160
  }
153
161
  return outArguments;
154
162
  }
155
- structDef(parameterSpace) {
163
+ getSourceDef(parameterSpace) {
156
164
  return this.withParameters(parameterSpace, []);
157
165
  }
158
166
  withParameters(parameterSpace, pList) {
@@ -1,4 +1,4 @@
1
- import { StructDef } from '../../../model/malloy_types';
1
+ import { SourceDef } from '../../../model/malloy_types';
2
2
  import { Source } from './source';
3
3
  import { QueryElement } from '../types/query-element';
4
4
  import { ParameterSpace } from '../field-space/parameter-space';
@@ -7,6 +7,6 @@ export declare class QuerySource extends Source {
7
7
  readonly query: QueryElement;
8
8
  elementType: string;
9
9
  constructor(query: QueryElement);
10
- structDef(parameterSpace: ParameterSpace | undefined): StructDef;
11
- withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): StructDef;
10
+ getSourceDef(parameterSpace: ParameterSpace | undefined): SourceDef;
11
+ withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): SourceDef;
12
12
  }
@@ -24,13 +24,14 @@
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.QuerySource = void 0;
26
26
  const source_1 = require("./source");
27
+ const uuid_1 = require("uuid");
27
28
  class QuerySource extends source_1.Source {
28
29
  constructor(query) {
29
30
  super({ query });
30
31
  this.query = query;
31
32
  this.elementType = 'querySource';
32
33
  }
33
- structDef(parameterSpace) {
34
+ getSourceDef(parameterSpace) {
34
35
  return this.withParameters(parameterSpace, undefined);
35
36
  }
36
37
  withParameters(parameterSpace, pList) {
@@ -38,7 +39,9 @@ class QuerySource extends source_1.Source {
38
39
  const comp = this.query.queryComp(false);
39
40
  const queryStruct = {
40
41
  ...comp.outputStruct,
41
- structSource: { type: 'query', query: comp.query },
42
+ name: `QuerySource-${(0, uuid_1.v4)()}`,
43
+ type: 'query_source',
44
+ query: comp.query,
42
45
  };
43
46
  (_a = this.document()) === null || _a === void 0 ? void 0 : _a.rememberToAddModelAnnotations(queryStruct);
44
47
  return {
@@ -1,4 +1,4 @@
1
- import { Annotation, StructDef } from '../../../model/malloy_types';
1
+ import { Annotation, SourceDef } from '../../../model/malloy_types';
2
2
  import { HasParameter } from '../parameters/has-parameter';
3
3
  import { SourceDesc } from '../types/source-desc';
4
4
  import { Source } from './source';
@@ -12,6 +12,6 @@ export declare class RefinedSource extends Source {
12
12
  elementType: string;
13
13
  currentAnnotation?: Annotation;
14
14
  constructor(source: Source, refinement: SourceDesc);
15
- structDef(parameterSpace: ParameterSpace | undefined): StructDef;
16
- withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): StructDef;
15
+ getSourceDef(parameterSpace: ParameterSpace | undefined): SourceDef;
16
+ withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): SourceDef;
17
17
  }
@@ -27,7 +27,6 @@ const malloy_types_1 = require("../../../model/malloy_types");
27
27
  const refined_space_1 = require("../field-space/refined-space");
28
28
  const declare_fields_1 = require("../query-properties/declare-fields");
29
29
  const filters_1 = require("../query-properties/filters");
30
- const joins_1 = require("../source-properties/joins");
31
30
  const field_list_edit_1 = require("../source-properties/field-list-edit");
32
31
  const primary_key_1 = require("../source-properties/primary-key");
33
32
  const views_1 = require("../source-properties/views");
@@ -36,6 +35,7 @@ const timezone_statement_1 = require("../source-properties/timezone-statement");
36
35
  const annotation_elements_1 = require("../types/annotation-elements");
37
36
  const renames_1 = require("../source-properties/renames");
38
37
  const parameter_space_1 = require("../field-space/parameter-space");
38
+ const join_1 = require("../source-properties/join");
39
39
  /**
40
40
  * A Source made from a source reference and a set of refinements
41
41
  */
@@ -46,7 +46,7 @@ class RefinedSource extends source_1.Source {
46
46
  this.refinement = refinement;
47
47
  this.elementType = 'refinedSource';
48
48
  }
49
- structDef(parameterSpace) {
49
+ getSourceDef(parameterSpace) {
50
50
  return this.withParameters(parameterSpace, []);
51
51
  }
52
52
  withParameters(parameterSpace, pList) {
@@ -79,7 +79,7 @@ class RefinedSource extends source_1.Source {
79
79
  fieldListEdit = el;
80
80
  }
81
81
  else if (el instanceof declare_fields_1.DeclareFields ||
82
- el instanceof joins_1.Joins ||
82
+ el instanceof join_1.JoinStatement ||
83
83
  el instanceof views_1.Views ||
84
84
  el instanceof renames_1.Renames) {
85
85
  fields.push(...el.list);
@@ -95,7 +95,7 @@ class RefinedSource extends source_1.Source {
95
95
  }
96
96
  }
97
97
  const paramSpace = pList ? new parameter_space_1.ParameterSpace(pList) : undefined;
98
- const from = structuredClone(this.source.structDef(paramSpace));
98
+ const from = structuredClone(this.source.getSourceDef(paramSpace));
99
99
  // Note that this is explicitly not:
100
100
  // const from = structuredClone(this.source.withParameters(parameterSpace, pList));
101
101
  // Because the parameters are added to the resulting struct, not the base struct
@@ -1,4 +1,4 @@
1
- import { InvokedStructRef, Parameter, StructDef } from '../../../model/malloy_types';
1
+ import { InvokedStructRef, Parameter, SourceDef, StructDef } from '../../../model/malloy_types';
2
2
  import { MalloyElement } from '../types/malloy-element';
3
3
  import { HasParameter } from '../parameters/has-parameter';
4
4
  import { ParameterSpace } from '../field-space/parameter-space';
@@ -7,7 +7,7 @@ import { ParameterSpace } from '../field-space/parameter-space';
7
7
  * function of a source is to represent an eventual StructDef
8
8
  */
9
9
  export declare abstract class Source extends MalloyElement {
10
- abstract structDef(parameterSpace: ParameterSpace | undefined): StructDef;
10
+ abstract getSourceDef(parameterSpace: ParameterSpace | undefined): SourceDef;
11
11
  structRef(parameterSpace: ParameterSpace | undefined): InvokedStructRef;
12
12
  protected packParameters(pList: HasParameter[] | undefined): Record<string, Parameter> | undefined;
13
13
  withParameters(parameterSpace: ParameterSpace | undefined, pList: HasParameter[] | undefined): StructDef;
@@ -31,7 +31,7 @@ const malloy_element_1 = require("../types/malloy-element");
31
31
  class Source extends malloy_element_1.MalloyElement {
32
32
  structRef(parameterSpace) {
33
33
  return {
34
- structRef: this.structDef(parameterSpace),
34
+ structRef: this.getSourceDef(parameterSpace),
35
35
  };
36
36
  }
37
37
  packParameters(pList) {
@@ -45,7 +45,7 @@ class Source extends malloy_element_1.MalloyElement {
45
45
  return parameters;
46
46
  }
47
47
  withParameters(parameterSpace, pList) {
48
- const before = this.structDef(parameterSpace);
48
+ const before = this.getSourceDef(parameterSpace);
49
49
  return {
50
50
  ...before,
51
51
  parameters: this.packParameters(pList),
@@ -1,4 +1,4 @@
1
- import { StructDef, SQLBlockSource, InvokedStructRef } from '../../../model/malloy_types';
1
+ import { SQLSentence, InvokedStructRef, SourceDef } from '../../../model/malloy_types';
2
2
  import { NeedCompileSQL } from '../../translate-response';
3
3
  import { Source } from './source';
4
4
  import { SQLString } from '../sql-elements/sql-string';
@@ -7,12 +7,12 @@ export declare class SQLSource extends Source {
7
7
  readonly connectionName: ModelEntryReference;
8
8
  readonly select: SQLString;
9
9
  elementType: string;
10
- requestBlock?: SQLBlockSource;
10
+ requestBlock?: SQLSentence;
11
11
  private connectionNameInvalid;
12
12
  constructor(connectionName: ModelEntryReference, select: SQLString);
13
- sqlBlock(): SQLBlockSource;
13
+ sqlSentence(): SQLSentence;
14
14
  structRef(): InvokedStructRef;
15
15
  validateConnectionName(): boolean;
16
16
  needs(doc: Document): NeedCompileSQL | undefined;
17
- structDef(): StructDef;
17
+ getSourceDef(): SourceDef;
18
18
  }
@@ -34,15 +34,15 @@ class SQLSource extends source_1.Source {
34
34
  this.elementType = 'sqlSource';
35
35
  this.connectionNameInvalid = false;
36
36
  }
37
- sqlBlock() {
37
+ sqlSentence() {
38
38
  if (!this.requestBlock) {
39
- this.requestBlock = (0, sql_block_1.makeSQLBlock)(this.select.sqlPhrases(), this.connectionName.refString);
39
+ this.requestBlock = (0, sql_block_1.makeSQLSentence)(this.select.sqlPhrases(), this.connectionName.refString);
40
40
  }
41
41
  return this.requestBlock;
42
42
  }
43
43
  structRef() {
44
44
  return {
45
- structRef: this.structDef(),
45
+ structRef: this.getSourceDef(),
46
46
  };
47
47
  }
48
48
  validateConnectionName() {
@@ -69,7 +69,7 @@ class SQLSource extends source_1.Source {
69
69
  const childNeeds = super.needs(doc);
70
70
  if (childNeeds)
71
71
  return childNeeds;
72
- const sql = this.sqlBlock();
72
+ const sql = this.sqlSentence();
73
73
  const sqlDefEntry = (_a = this.translator()) === null || _a === void 0 ? void 0 : _a.root.sqlQueryZone;
74
74
  if (!sqlDefEntry) {
75
75
  this.logError('failed-to-fetch-sql-source-schema', "Cant't look up schema for sql block");
@@ -87,7 +87,7 @@ class SQLSource extends source_1.Source {
87
87
  doc.checkExperimentalDialect(this, lookup.value.dialect);
88
88
  }
89
89
  }
90
- structDef() {
90
+ getSourceDef() {
91
91
  var _a;
92
92
  if (!this.validateConnectionName()) {
93
93
  return error_factory_1.ErrorFactory.structDef;
@@ -97,7 +97,7 @@ class SQLSource extends source_1.Source {
97
97
  this.logError('failed-to-fetch-sql-source-schema', "Cant't look up schema for sql block");
98
98
  return error_factory_1.ErrorFactory.structDef;
99
99
  }
100
- const sql = this.sqlBlock();
100
+ const sql = this.sqlSentence();
101
101
  sqlDefEntry.reference(sql.name, this.location);
102
102
  const lookup = sqlDefEntry.getEntry(sql.name);
103
103
  if (lookup.status === 'error') {
@@ -1,4 +1,4 @@
1
- import { StructDef } from '../../../model/malloy_types';
1
+ import { SourceDef } from '../../../model/malloy_types';
2
2
  import { Source } from './source';
3
3
  import { ModelEntryReference } from '../types/malloy-element';
4
4
  type TableInfo = {
@@ -7,7 +7,7 @@ type TableInfo = {
7
7
  };
8
8
  export declare abstract class TableSource extends Source {
9
9
  abstract getTableInfo(): TableInfo | undefined;
10
- structDef(): StructDef;
10
+ getSourceDef(): SourceDef;
11
11
  }
12
12
  export declare class TableMethodSource extends TableSource {
13
13
  readonly connectionName: ModelEntryReference;
@@ -27,7 +27,7 @@ const find_external_references_1 = require("../../parse-tree-walkers/find-extern
27
27
  const source_1 = require("./source");
28
28
  const error_factory_1 = require("../error-factory");
29
29
  class TableSource extends source_1.Source {
30
- structDef() {
30
+ getSourceDef() {
31
31
  var _a, _b, _c;
32
32
  const info = this.getTableInfo();
33
33
  if (info === undefined) {
@@ -1,4 +1,4 @@
1
- import { Annotation, Expr, StructDef } from '../../../model/malloy_types';
1
+ import { Annotation, JoinFieldDef, JoinType, MatrixOperation, SourceDef } from '../../../model/malloy_types';
2
2
  import { DynamicSpace } from '../field-space/dynamic-space';
3
3
  import { DefinitionList } from '../types/definition-list';
4
4
  import { QueryBuilder } from '../types/query-builder';
@@ -6,20 +6,20 @@ import { ExpressionDef } from '../types/expression-def';
6
6
  import { FieldSpace } from '../types/field-space';
7
7
  import { MalloyElement, ModelEntryReference } from '../types/malloy-element';
8
8
  import { extendNoteMethod, Noteable } from '../types/noteable';
9
- import { LegalRefinementStage, QueryPropertyInterface } from '../types/query-property-interface';
10
9
  import { MakeEntry } from '../types/space-entry';
11
10
  import { SourceQueryElement } from '../source-query-elements/source-query-element';
12
11
  import { ParameterSpace } from '../field-space/parameter-space';
12
+ import { LegalRefinementStage, QueryPropertyInterface } from '../types/query-property-interface';
13
13
  export declare abstract class Join extends MalloyElement implements Noteable, MakeEntry {
14
14
  abstract name: ModelEntryReference;
15
- abstract structDef(parameterSpace: ParameterSpace): StructDef;
16
- abstract fixupJoinOn(outer: FieldSpace, inStruct: StructDef): void;
15
+ abstract structDef(parameterSpace: ParameterSpace): JoinFieldDef;
16
+ abstract fixupJoinOn(outer: FieldSpace, inStruct: JoinFieldDef): void;
17
17
  readonly isNoteableObj = true;
18
18
  extendNote: typeof extendNoteMethod;
19
19
  abstract sourceExpr: SourceQueryElement;
20
20
  note?: Annotation;
21
21
  makeEntry(fs: DynamicSpace): void;
22
- protected getStructDefFromExpr(parameterSpace: ParameterSpace): StructDef;
22
+ protected getStructDefFromExpr(parameterSpace: ParameterSpace): SourceDef;
23
23
  }
24
24
  export declare class KeyJoin extends Join {
25
25
  readonly name: ModelEntryReference;
@@ -27,29 +27,26 @@ export declare class KeyJoin extends Join {
27
27
  readonly keyExpr: ExpressionDef;
28
28
  elementType: string;
29
29
  constructor(name: ModelEntryReference, sourceExpr: SourceQueryElement, keyExpr: ExpressionDef);
30
- structDef(parameterSpace: ParameterSpace): StructDef;
31
- fixupJoinOn(outer: FieldSpace, inStruct: StructDef): void;
30
+ structDef(parameterSpace: ParameterSpace): JoinFieldDef;
31
+ fixupJoinOn(outer: FieldSpace, inStruct: JoinFieldDef): void;
32
32
  }
33
- type ExpressionJoinType = 'many' | 'one' | 'cross';
34
- export type MatrixOperation = 'left' | 'inner' | 'right' | 'full';
35
33
  export declare class ExpressionJoin extends Join {
36
34
  readonly name: ModelEntryReference;
37
35
  readonly sourceExpr: SourceQueryElement;
38
36
  elementType: string;
39
- joinType: ExpressionJoinType;
37
+ joinType: JoinType;
40
38
  matrixOperation: MatrixOperation;
41
39
  private expr?;
42
40
  constructor(name: ModelEntryReference, sourceExpr: SourceQueryElement);
43
41
  set joinOn(joinExpr: ExpressionDef | undefined);
44
42
  get joinOn(): ExpressionDef | undefined;
45
- fixupJoinOn(outer: FieldSpace, inStruct: StructDef): Expr | undefined;
46
- structDef(parameterSpace: ParameterSpace): StructDef;
43
+ fixupJoinOn(outer: FieldSpace, inStruct: JoinFieldDef): void;
44
+ structDef(parameterSpace: ParameterSpace): JoinFieldDef;
47
45
  }
48
- export declare class Joins extends DefinitionList<Join> implements QueryPropertyInterface {
46
+ export declare class JoinStatement extends DefinitionList<Join> implements QueryPropertyInterface {
49
47
  elementType: string;
50
48
  forceQueryClass: undefined;
51
49
  queryRefinementStage: LegalRefinementStage;
52
50
  constructor(joins: Join[]);
53
51
  queryExecute(executeFor: QueryBuilder): void;
54
52
  }
55
- export {};