@malloydata/malloy 0.0.157 → 0.0.158-dev240805161224

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 (67) hide show
  1. package/dist/lang/ast/expressions/constant-expression.d.ts +28 -0
  2. package/dist/lang/ast/expressions/{constant-sub-expression.js → constant-expression.js} +6 -5
  3. package/dist/lang/ast/expressions/expr-func.js +29 -11
  4. package/dist/lang/ast/expressions/expr-id-reference.d.ts +0 -1
  5. package/dist/lang/ast/expressions/expr-id-reference.js +0 -24
  6. package/dist/lang/ast/field-space/dynamic-space.d.ts +4 -1
  7. package/dist/lang/ast/field-space/dynamic-space.js +22 -11
  8. package/dist/lang/ast/field-space/index-field-space.js +3 -0
  9. package/dist/lang/ast/field-space/join-space-field.d.ts +3 -1
  10. package/dist/lang/ast/field-space/join-space-field.js +3 -2
  11. package/dist/lang/ast/field-space/parameter-space.d.ts +18 -0
  12. package/dist/lang/ast/field-space/parameter-space.js +67 -0
  13. package/dist/lang/ast/field-space/query-spaces.js +3 -0
  14. package/dist/lang/ast/field-space/reference-field.js +13 -4
  15. package/dist/lang/ast/field-space/refined-space.d.ts +2 -1
  16. package/dist/lang/ast/field-space/refined-space.js +12 -1
  17. package/dist/lang/ast/field-space/static-space.js +3 -5
  18. package/dist/lang/ast/index.d.ts +1 -0
  19. package/dist/lang/ast/index.js +1 -0
  20. package/dist/lang/ast/parameters/argument.d.ts +14 -0
  21. package/dist/lang/ast/parameters/argument.js +20 -0
  22. package/dist/lang/ast/parameters/has-parameter.d.ts +3 -5
  23. package/dist/lang/ast/parameters/has-parameter.js +24 -13
  24. package/dist/lang/ast/query-elements/query-arrow.js +7 -7
  25. package/dist/lang/ast/query-elements/query-head-struct.d.ts +6 -4
  26. package/dist/lang/ast/query-elements/query-head-struct.js +6 -5
  27. package/dist/lang/ast/query-elements/query-raw.js +7 -7
  28. package/dist/lang/ast/query-elements/query-reference.js +2 -2
  29. package/dist/lang/ast/query-items/field-references.d.ts +4 -0
  30. package/dist/lang/ast/query-items/field-references.js +12 -1
  31. package/dist/lang/ast/source-elements/named-source.d.ts +15 -12
  32. package/dist/lang/ast/source-elements/named-source.js +91 -60
  33. package/dist/lang/ast/source-elements/query-source.d.ts +4 -1
  34. package/dist/lang/ast/source-elements/query-source.js +9 -3
  35. package/dist/lang/ast/source-elements/refined-source.d.ts +3 -2
  36. package/dist/lang/ast/source-elements/refined-source.js +12 -7
  37. package/dist/lang/ast/source-elements/source.d.ts +6 -4
  38. package/dist/lang/ast/source-elements/source.js +19 -16
  39. package/dist/lang/ast/source-elements/sql-source.d.ts +2 -2
  40. package/dist/lang/ast/source-elements/sql-source.js +4 -3
  41. package/dist/lang/ast/source-properties/joins.d.ts +5 -4
  42. package/dist/lang/ast/source-properties/joins.js +7 -7
  43. package/dist/lang/ast/source-query-elements/sq-reference.d.ts +3 -1
  44. package/dist/lang/ast/source-query-elements/sq-reference.js +9 -2
  45. package/dist/lang/ast/statements/define-source.d.ts +4 -2
  46. package/dist/lang/ast/statements/define-source.js +28 -14
  47. package/dist/lang/ast/struct-utils.js +3 -2
  48. package/dist/lang/ast/types/expression-def.js +2 -0
  49. package/dist/lang/lib/Malloy/MalloyParser.d.ts +169 -101
  50. package/dist/lang/lib/Malloy/MalloyParser.js +2105 -1600
  51. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +64 -9
  52. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +40 -5
  53. package/dist/lang/malloy-to-ast.d.ts +5 -1
  54. package/dist/lang/malloy-to-ast.js +51 -10
  55. package/dist/lang/test/expressions.spec.js +21 -1
  56. package/dist/lang/test/field-symbols.spec.js +0 -2
  57. package/dist/lang/test/locations.spec.js +3 -0
  58. package/dist/lang/test/parameters.spec.d.ts +1 -0
  59. package/dist/lang/test/parameters.spec.js +578 -0
  60. package/dist/model/malloy_query.d.ts +8 -5
  61. package/dist/model/malloy_query.js +68 -37
  62. package/dist/model/malloy_types.d.ts +12 -14
  63. package/dist/model/malloy_types.js +22 -10
  64. package/package.json +1 -1
  65. package/dist/lang/ast/expressions/constant-sub-expression.d.ts +0 -16
  66. package/dist/lang/ast/parameters/constant-parameter.d.ts +0 -8
  67. package/dist/lang/ast/parameters/constant-parameter.js +0 -54
@@ -432,30 +432,12 @@ class QueryField extends QueryNode {
432
432
  generateSpread(_resultSet, _context, _frag, _state) {
433
433
  throw new Error('Unexpanded spread encountered during SQL generation');
434
434
  }
435
- generateParameterFragment(resultSet, context, expr, _state) {
436
- /*
437
- mtoy todo parameters and paths figure this out
438
-
439
- // find the structDef and return the path to the field...
440
- const param = context.parameters()[expr.path];
441
- if (isValueParameter(param)) {
442
- if (param.value) {
443
- return this.generateExpressionFromExpr(
444
- resultSet,
445
- context,
446
- param.value,
447
- state
448
- );
449
- }
450
- } else if (param.condition) {
451
- return this.generateExpressionFromExpr(
452
- resultSet,
453
- context,
454
- param.condition,
455
- state
456
- );
457
- }
458
- */
435
+ generateParameterFragment(resultSet, context, expr, state) {
436
+ const name = expr.path[0];
437
+ const argument = context.arguments()[name];
438
+ if (argument.value) {
439
+ return this.generateExpressionFromExpr(resultSet, context, argument.value, state);
440
+ }
459
441
  throw new Error(`Can't generate SQL, no value for ${expr.path}`);
460
442
  }
461
443
  generateFilterFragment(resultSet, context, expr, state) {
@@ -1443,7 +1425,7 @@ class QueryTurtle extends QueryField {
1443
1425
  */
1444
1426
  class Segment {
1445
1427
  static nextStructDef(structDef, segment) {
1446
- const qs = new QueryStruct(structDef, {
1428
+ const qs = new QueryStruct(structDef, undefined, {
1447
1429
  model: new QueryModel(undefined),
1448
1430
  });
1449
1431
  const turtleDef = {
@@ -1486,7 +1468,7 @@ class QueryQuery extends QueryField {
1486
1468
  parent = new QueryStruct({
1487
1469
  ...sourceDef,
1488
1470
  fields: [...sourceDef.fields, ...firstStage.extendSource],
1489
- }, parent.parent ? { struct: parent } : { model: parent.model });
1471
+ }, parentStruct.sourceArguments, parent.parent ? { struct: parent } : { model: parent.model });
1490
1472
  turtleWithFilters = {
1491
1473
  ...turtleWithFilters,
1492
1474
  pipeline: [
@@ -2596,7 +2578,7 @@ class QueryQuery extends QueryField {
2596
2578
  };
2597
2579
  structDef.name = this.parent.dialect.sqlUnnestPipelineHead(repeatedResultType === 'inline_all_numbers', sourceSQLExpression);
2598
2580
  structDef.structSource = { type: 'sql', method: 'nested' };
2599
- const qs = new QueryStruct(structDef, {
2581
+ const qs = new QueryStruct(structDef, undefined, {
2600
2582
  model: this.parent.getModel(),
2601
2583
  });
2602
2584
  const q = QueryQuery.makeQuery(newTurtle, qs, stageWriter, this.isJoinedSubquery);
@@ -2654,7 +2636,7 @@ class QueryQuery extends QueryField {
2654
2636
  };
2655
2637
  pipeline.shift();
2656
2638
  for (const transform of pipeline) {
2657
- const s = new QueryStruct(structDef, {
2639
+ const s = new QueryStruct(structDef, undefined, {
2658
2640
  model: this.parent.getModel(),
2659
2641
  });
2660
2642
  const q = QueryQuery.makeQuery({ type: 'turtle', name: 'ignoreme', pipeline: [transform] }, s, stageWriter, this.isJoinedSubquery);
@@ -2921,9 +2903,11 @@ class QueryQueryIndex extends QueryQuery {
2921
2903
  }
2922
2904
  /** Structure object as it is used to build a query */
2923
2905
  class QueryStruct extends QueryNode {
2924
- constructor(fieldDef, parent) {
2906
+ constructor(fieldDef, sourceArguments, parent) {
2925
2907
  super(fieldDef);
2908
+ this.sourceArguments = sourceArguments;
2926
2909
  this.nameMap = new Map();
2910
+ this._arguments = undefined;
2927
2911
  this.setParent(parent);
2928
2912
  if ('model' in parent) {
2929
2913
  this.model = parent.model;
@@ -2945,15 +2929,57 @@ class QueryStruct extends QueryNode {
2945
2929
  this.dialect = (0, dialect_1.getDialect)(this.fieldDef.dialect);
2946
2930
  this.addFieldsFromFieldList(this.fieldDef.fields);
2947
2931
  }
2948
- parameters() {
2949
- return this.fieldDef.parameters || {};
2932
+ resolveParentParameterReferences(param) {
2933
+ return {
2934
+ ...param,
2935
+ value: param.value === null
2936
+ ? null
2937
+ : (0, utils_1.exprMap)(param.value, frag => {
2938
+ if (typeof frag === 'string')
2939
+ return [frag];
2940
+ if (frag.type === 'parameter') {
2941
+ if (this.parent === undefined) {
2942
+ throw new Error('No parent from which to retrieve parameter value');
2943
+ }
2944
+ const resolved1 = this.parent.arguments()[frag.path[0]];
2945
+ const resolved2 = this.parent.resolveParentParameterReferences(resolved1);
2946
+ if (resolved2.value === null) {
2947
+ throw new Error('Invalid parameter value');
2948
+ }
2949
+ else {
2950
+ return resolved2.value;
2951
+ }
2952
+ }
2953
+ return [frag];
2954
+ }),
2955
+ };
2956
+ }
2957
+ arguments() {
2958
+ var _a, _b, _c;
2959
+ if (this._arguments !== undefined) {
2960
+ return this._arguments;
2961
+ }
2962
+ this._arguments = {};
2963
+ // First, copy over all parameters, to get default values
2964
+ const params = (_a = this.fieldDef.parameters) !== null && _a !== void 0 ? _a : {};
2965
+ for (const parameterName in params) {
2966
+ this._arguments[parameterName] = params[parameterName];
2967
+ }
2968
+ // Then, copy over arguments to override default values
2969
+ const args = (_c = (_b = this.sourceArguments) !== null && _b !== void 0 ? _b : this.fieldDef.arguments) !== null && _c !== void 0 ? _c : {};
2970
+ for (const parameterName in args) {
2971
+ const orig = args[parameterName];
2972
+ this._arguments[parameterName] =
2973
+ this.resolveParentParameterReferences(orig);
2974
+ }
2975
+ return this._arguments;
2950
2976
  }
2951
2977
  addFieldsFromFieldList(fields) {
2952
2978
  for (const field of fields) {
2953
2979
  const as = (0, malloy_types_1.getIdentifier)(field);
2954
2980
  switch (field.type) {
2955
2981
  case 'struct': {
2956
- this.addFieldToNameMap(as, new QueryStruct(field, {
2982
+ this.addFieldToNameMap(as, new QueryStruct(field, undefined, {
2957
2983
  struct: this,
2958
2984
  }));
2959
2985
  break;
@@ -3324,7 +3350,7 @@ class QueryModel {
3324
3350
  for (const s of Object.values(this.modelDef.contents)) {
3325
3351
  let qs;
3326
3352
  if (s.type === 'struct') {
3327
- qs = new QueryStruct(s, { model: this });
3353
+ qs = new QueryStruct(s, undefined, { model: this });
3328
3354
  this.structs.set((0, malloy_types_1.getIdentifier)(s), qs);
3329
3355
  qs.resolveQueryFields();
3330
3356
  }
@@ -3345,10 +3371,15 @@ class QueryModel {
3345
3371
  throw new Error(`Struct ${name} not found in model.`);
3346
3372
  }
3347
3373
  }
3348
- getStructFromRef(structRef) {
3374
+ getStructFromRef(structRef, sourceArguments) {
3375
+ var _a;
3349
3376
  let structDef;
3350
3377
  if (typeof structRef === 'string') {
3351
- return this.getStructByName(structRef);
3378
+ const ret = this.getStructByName(structRef);
3379
+ if (sourceArguments !== undefined) {
3380
+ return new QueryStruct(ret.fieldDef, sourceArguments, (_a = ret.parent) !== null && _a !== void 0 ? _a : { model: this });
3381
+ }
3382
+ return ret;
3352
3383
  }
3353
3384
  else if (structRef.type === 'struct') {
3354
3385
  structDef = structRef;
@@ -3356,7 +3387,7 @@ class QueryModel {
3356
3387
  else {
3357
3388
  throw new Error('Broken for now');
3358
3389
  }
3359
- return new QueryStruct(structDef, { model: this });
3390
+ return new QueryStruct(structDef, sourceArguments, { model: this });
3360
3391
  }
3361
3392
  loadQuery(query, stageWriter, emitFinalStage = false, isJoinedSubquery = false) {
3362
3393
  const malloy = '';
@@ -3369,7 +3400,7 @@ class QueryModel {
3369
3400
  pipeline: query.pipeline,
3370
3401
  filterList: query.filterList,
3371
3402
  };
3372
- const q = QueryQuery.makeQuery(turtleDef, this.getStructFromRef(query.structRef), stageWriter, isJoinedSubquery);
3403
+ const q = QueryQuery.makeQuery(turtleDef, this.getStructFromRef(query.structRef, query.sourceArguments), stageWriter, isJoinedSubquery);
3373
3404
  const ret = q.generateSQLFromPipeline(stageWriter);
3374
3405
  if (emitFinalStage && q.parent.dialect.hasFinalStage) {
3375
3406
  // const fieldNames: string[] = [];
@@ -1,21 +1,11 @@
1
1
  /// <reference types="node" />
2
- interface ParamBase {
3
- name: string;
4
- type: AtomicFieldType;
5
- }
6
2
  type ConstantExpr = Expr;
7
- type Condition = Expr;
8
- interface ParamCondition extends ParamBase {
9
- condition: Condition | null;
10
- type: CastType;
11
- }
12
- interface ParamValue extends ParamBase {
3
+ export interface Parameter {
13
4
  value: ConstantExpr | null;
14
- constant: boolean;
5
+ name: string;
6
+ type: AtomicFieldType;
15
7
  }
16
- export type Parameter = ParamCondition | ParamValue;
17
- export declare function isValueParameter(p: Parameter): p is ParamValue;
18
- export declare function isConditionParameter(p: Parameter): p is ParamCondition;
8
+ export type Argument = Parameter;
19
9
  export declare function paramHasValue(p: Parameter): boolean;
20
10
  export interface DocumentRange {
21
11
  start: DocumentPosition;
@@ -414,6 +404,10 @@ export declare function isByExpression(by: By | undefined): by is ByExpression;
414
404
  /** reference to a data source */
415
405
  export type StructRef = string | StructDef;
416
406
  export declare function refIsStructDef(ref: StructRef): ref is StructDef;
407
+ export type InvokedStructRef = {
408
+ structRef: StructRef;
409
+ sourceArguments?: Record<string, Argument>;
410
+ };
417
411
  /** join pattern structs is a struct. */
418
412
  export interface JoinedStruct {
419
413
  structRef: StructRef;
@@ -436,11 +430,14 @@ export interface Query extends Pipeline, Filtered, HasLocation {
436
430
  type?: 'query';
437
431
  name?: string;
438
432
  structRef: StructRef;
433
+ sourceArguments?: Record<string, Argument>;
439
434
  annotation?: Annotation;
440
435
  modelAnnotation?: Annotation;
441
436
  }
442
437
  export type NamedQuery = Query & NamedObject;
443
438
  export type PipeSegment = QuerySegment | IndexSegment | RawSegment;
439
+ export declare function segmentHasErrors(segment: PipeSegment): boolean;
440
+ export declare function structHasErrors(struct: StructDef): boolean;
444
441
  export interface ReduceSegment extends QuerySegment {
445
442
  type: 'reduce';
446
443
  }
@@ -564,6 +561,7 @@ export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
564
561
  structRelationship: StructRelationship;
565
562
  fields: FieldDef[];
566
563
  primaryKey?: PrimaryKeyRef;
564
+ arguments?: Record<string, Argument>;
567
565
  parameters?: Record<string, Parameter>;
568
566
  queryTimezone?: string;
569
567
  dialect: string;
@@ -22,18 +22,10 @@
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.isIndexSegment = exports.isRawSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isPartialSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = exports.isCastType = exports.isAtomicFieldType = exports.isTimeFieldType = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.mkExpr = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isSourceReferenceFragment = exports.isSqlStringFragment = exports.isFieldFragment = exports.isSpreadFragment = exports.isSQLExpressionFragment = exports.isFunctionCallFragment = exports.isFunctionParameterFragment = exports.isUngroupFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isDialectFragment = exports.isFilterFragment = exports.isOutputFieldFragment = exports.paramHasValue = exports.isConditionParameter = exports.isValueParameter = void 0;
25
+ exports.isIndexSegment = exports.isRawSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isPartialSegment = exports.isReduceSegment = exports.structHasErrors = exports.segmentHasErrors = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = exports.isCastType = exports.isAtomicFieldType = exports.isTimeFieldType = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.mkExpr = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isSourceReferenceFragment = exports.isSqlStringFragment = exports.isFieldFragment = exports.isSpreadFragment = exports.isSQLExpressionFragment = exports.isFunctionCallFragment = exports.isFunctionParameterFragment = exports.isUngroupFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isDialectFragment = exports.isFilterFragment = exports.isOutputFieldFragment = exports.paramHasValue = void 0;
26
26
  exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isAtomicField = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = exports.isSQLBlockStruct = exports.mergeEvalSpaces = exports.isLiteral = exports.isSQLFragment = exports.isJoinOn = exports.isMatrixOperation = void 0;
27
- function isValueParameter(p) {
28
- return p.value !== undefined;
29
- }
30
- exports.isValueParameter = isValueParameter;
31
- function isConditionParameter(p) {
32
- return p.condition !== undefined;
33
- }
34
- exports.isConditionParameter = isConditionParameter;
35
27
  function paramHasValue(p) {
36
- return isValueParameter(p) || p.condition !== null;
28
+ return p.value !== null;
37
29
  }
38
30
  exports.paramHasValue = paramHasValue;
39
31
  function isOutputFieldFragment(f) {
@@ -281,6 +273,26 @@ function refIsStructDef(ref) {
281
273
  return typeof ref !== 'string' && ref.type === 'struct';
282
274
  }
283
275
  exports.refIsStructDef = refIsStructDef;
276
+ function segmentHasErrors(segment) {
277
+ if (segment.type === 'reduce' ||
278
+ segment.type === 'project' ||
279
+ segment.type === 'partial') {
280
+ if (segment.extendSource) {
281
+ if (segment.extendSource.some(f => f.type === 'error')) {
282
+ return true;
283
+ }
284
+ }
285
+ if (segment.queryFields.some(f => f.type === 'error')) {
286
+ return true;
287
+ }
288
+ }
289
+ return false;
290
+ }
291
+ exports.segmentHasErrors = segmentHasErrors;
292
+ function structHasErrors(struct) {
293
+ return struct.fields.some(f => f.type === 'error');
294
+ }
295
+ exports.structHasErrors = structHasErrors;
284
296
  function isReduceSegment(pe) {
285
297
  return pe.type === 'reduce';
286
298
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.157",
3
+ "version": "0.0.158-dev240805161224",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -1,16 +0,0 @@
1
- import { AtomicFieldType } from '../../../model/malloy_types';
2
- import { ExprValue } from '../types/expr-value';
3
- import { ExpressionDef } from '../types/expression-def';
4
- import { FieldSpace } from '../types/field-space';
5
- export declare class ConstantSubExpression extends ExpressionDef {
6
- readonly expr: ExpressionDef;
7
- elementType: string;
8
- private cfs?;
9
- constructor(expr: ExpressionDef);
10
- getExpression(_fs: FieldSpace): ExprValue;
11
- private get constantFs();
12
- constantValue(): ExprValue;
13
- constantCondition(type: AtomicFieldType): ExprValue;
14
- apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
15
- requestExpression(fs: FieldSpace): ExprValue | undefined;
16
- }
@@ -1,8 +0,0 @@
1
- import { Parameter } from '../../../model/malloy_types';
2
- import { ConstantSubExpression } from '../expressions/constant-sub-expression';
3
- import { HasParameter } from './has-parameter';
4
- export declare class ConstantParameter extends HasParameter {
5
- readonly value: ConstantSubExpression;
6
- constructor(name: string, value: ConstantSubExpression);
7
- parameter(): Parameter;
8
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.ConstantParameter = void 0;
26
- const malloy_types_1 = require("../../../model/malloy_types");
27
- const has_parameter_1 = require("./has-parameter");
28
- class ConstantParameter extends has_parameter_1.HasParameter {
29
- constructor(name, value) {
30
- super({ name, isCondition: false });
31
- this.value = value;
32
- this.has({ value: value });
33
- }
34
- parameter() {
35
- const cVal = this.value.constantValue();
36
- if (!(0, malloy_types_1.isAtomicFieldType)(cVal.dataType)) {
37
- this.log(`Unexpected expression type '${cVal.dataType}'`);
38
- return {
39
- value: ['XXX-type-mismatch-error-XXX'],
40
- type: 'error',
41
- name: this.name,
42
- constant: true,
43
- };
44
- }
45
- return {
46
- value: cVal.value,
47
- type: cVal.dataType,
48
- name: this.name,
49
- constant: true,
50
- };
51
- }
52
- }
53
- exports.ConstantParameter = ConstantParameter;
54
- //# sourceMappingURL=constant-parameter.js.map