@malloydata/malloy 0.0.154 → 0.0.155-dev240722212948

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.
@@ -37,7 +37,7 @@ class ExprCast extends expression_def_1.ExpressionDef {
37
37
  getExpression(fs) {
38
38
  var _a, _b, _c;
39
39
  const expr = this.expr.getExpression(fs);
40
- let dataType = 'unsupported';
40
+ let dataType = 'sql native';
41
41
  if (typeof this.castType === 'string') {
42
42
  dataType = this.castType;
43
43
  }
@@ -48,7 +48,7 @@ class ExprCast extends expression_def_1.ExpressionDef {
48
48
  // TODO theoretically `sqlTypeToMalloyType` can get number subtypes,
49
49
  // but `TypeDesc` does not support them.
50
50
  dataType =
51
- (_c = (_b = (_a = fs.dialectObj()) === null || _a === void 0 ? void 0 : _a.sqlTypeToMalloyType(this.castType.raw)) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'unsupported';
51
+ (_c = (_b = (_a = fs.dialectObj()) === null || _a === void 0 ? void 0 : _a.sqlTypeToMalloyType(this.castType.raw)) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'sql native';
52
52
  }
53
53
  else {
54
54
  this.log(`Cast type \`${this.castType.raw}\` is invalid for ${dialect.name} dialect`);
@@ -68,7 +68,9 @@ class ExpressionDef extends malloy_element_1.MalloyElement {
68
68
  */
69
69
  typeCheck(eNode, eVal) {
70
70
  if (eVal.dataType !== 'error' && !fragtype_utils_1.FT.in(eVal, this.legalChildTypes)) {
71
- eNode.log(`'${this.elementType}' Can't use type ${fragtype_utils_1.FT.inspect(eVal)}`);
71
+ eNode.log(eVal.dataType === 'sql native'
72
+ ? `'${this.elementType}' Can't be used with unsupported SQL native type '${eVal.rawType}'[unsupported-sql-native-type-not-allowed-in-expression]`
73
+ : `'${this.elementType}' Can't use type ${fragtype_utils_1.FT.inspect(eVal)}`);
72
74
  return false;
73
75
  }
74
76
  return true;
@@ -248,7 +250,7 @@ function equality(fs, left, op, right) {
248
250
  if (err)
249
251
  return err;
250
252
  // Unsupported types can be compare with null
251
- const checkUnsupport = lhs.dataType === 'unsupported' || rhs.dataType === 'unsupported';
253
+ const checkUnsupport = lhs.dataType === 'sql native' || rhs.dataType === 'sql native';
252
254
  if (checkUnsupport) {
253
255
  const oneNull = lhs.dataType === 'null' || rhs.dataType === 'null';
254
256
  const rawMatch = lhs.rawType && lhs.rawType === rhs.rawType;
@@ -407,7 +409,7 @@ function applyBinary(fs, left, op, right) {
407
409
  const denom = right.getExpression(fs);
408
410
  const noGo = unsupportError(left, num, right, denom);
409
411
  if (noGo) {
410
- left.log('Cannot operate with unsupported type');
412
+ left.log(`Cannot use '${op}' with sql native type`);
411
413
  return noGo;
412
414
  }
413
415
  const err = errorCascade('number', num, denom);
@@ -459,12 +461,12 @@ function unsupportError(l, lhs, r, rhs) {
459
461
  value: ["'unsupported operation'"],
460
462
  evalSpace: (0, malloy_types_1.mergeEvalSpaces)(lhs.evalSpace, rhs.evalSpace),
461
463
  };
462
- if (lhs.dataType === 'unsupported') {
463
- l.log('Unsupported type not allowed in expression');
464
+ if (lhs.dataType === 'sql native') {
465
+ l.log(`Unsupported SQL native type '${lhs.rawType}' not allowed in expression[unsupported-sql-native-type-not-allowed-in-expression]`);
464
466
  return { ...ret, dataType: rhs.dataType };
465
467
  }
466
- if (rhs.dataType === 'unsupported') {
467
- r.log('Unsupported type not allowed in expression');
468
+ if (rhs.dataType === 'sql native') {
469
+ r.log(`Unsupported SQL native type '${rhs.rawType}' not allowed in expression[unsupported-sql-native-type-not-allowed-in-expression]`);
468
470
  return ret;
469
471
  }
470
472
  return undefined;
@@ -39,8 +39,8 @@ class SpaceField extends space_entry_1.SpaceEntry {
39
39
  if ((0, malloy_types_1.isFieldTypeDef)(def) && def.expressionType) {
40
40
  ref.expressionType = def.expressionType;
41
41
  }
42
- if (ref.dataType === 'unsupported' &&
43
- def.type === 'unsupported' &&
42
+ if (ref.dataType === 'sql native' &&
43
+ def.type === 'sql native' &&
44
44
  def.rawType) {
45
45
  ref.rawType = def.rawType;
46
46
  }
@@ -863,24 +863,24 @@ describe('expressions', () => {
863
863
  expect((0, test_translator_1.expr) `${name} = NULL`).toTranslate();
864
864
  });
865
865
  });
866
- describe('unspported fields in schema', () => {
867
- test('unsupported reference in result allowed', () => {
866
+ describe('sql native fields in schema', () => {
867
+ test('sql native reference in result allowed', () => {
868
868
  const uModel = new test_translator_1.TestTranslator('run: a->{ group_by: aun }');
869
869
  expect(uModel).toTranslate();
870
870
  });
871
- test('unsupported reference can be compared to NULL', () => {
871
+ test('sql native reference can be compared to NULL', () => {
872
872
  const uModel = new test_translator_1.TestTranslator('run: a->{ where: aun != NULL; select: * }');
873
873
  expect(uModel).toTranslate();
874
874
  });
875
875
  test('flag unsupported equality', () => {
876
876
  // because we don't know if the two unsupported types are comparable
877
877
  const uModel = new test_translator_1.TestTranslator('run: ab->{ where: aun = b.aun select: * }');
878
- expect(uModel).translationToFailWith('Unsupported type not allowed in expression');
878
+ expect(uModel).translationToFailWith("Unsupported SQL native type 'undefined' not allowed in expression");
879
879
  });
880
880
  test('flag unsupported compare', () => {
881
881
  // because we don't know if the two unsupported types are comparable
882
882
  const uModel = new test_translator_1.TestTranslator('run: ab->{ where: aun > b.aun select: * }');
883
- expect(uModel).translationToFailWith('Unsupported type not allowed in expression');
883
+ expect(uModel).translationToFailWith("Unsupported SQL native type 'undefined' not allowed in expression");
884
884
  });
885
885
  test('allow unsupported equality when raw types match', () => {
886
886
  const uModel = new test_translator_1.TestTranslator('run: ab->{ where: aweird = b.aweird select: * }');
@@ -888,7 +888,7 @@ describe('unspported fields in schema', () => {
888
888
  });
889
889
  test('flag not applied to unsupported', () => {
890
890
  const uModel = new test_translator_1.TestTranslator('source: x is a extend { dimension: notUn is not aun }');
891
- expect(uModel).translationToFailWith("'not' Can't use type unsupported");
891
+ expect(uModel).translationToFailWith("'not' Can't be used with unsupported SQL native type 'undefined'");
892
892
  });
893
893
  test('allow unsupported to be cast', () => {
894
894
  const uModel = new test_translator_1.TestTranslator('source: x is a extend { dimension: notUn is aun::string }');
@@ -94,7 +94,7 @@ describe('structdef comprehension', () => {
94
94
  test('import unsupported field', () => {
95
95
  const field = {
96
96
  name: 't',
97
- type: 'unsupported',
97
+ type: 'sql native',
98
98
  };
99
99
  const struct = mkStructDef(field);
100
100
  const space = new static_space_1.StaticSpace(struct);
@@ -49,8 +49,8 @@ const mockSchema = {
49
49
  { type: 'date', name: 'ad' },
50
50
  { type: 'boolean', name: 'abool' },
51
51
  { type: 'timestamp', name: 'ats' },
52
- { type: 'unsupported', name: 'aun' },
53
- { type: 'unsupported', name: 'aweird', rawType: 'weird' },
52
+ { type: 'sql native', name: 'aun' },
53
+ { type: 'sql native', name: 'aweird', rawType: 'weird' },
54
54
  {
55
55
  type: 'struct',
56
56
  name: 'astruct',
package/dist/malloy.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { RunSQLOptions } from './run_sql_options';
3
3
  import { DocumentCompletion as DocumentCompletionDefinition, DocumentSymbol as DocumentSymbolDefinition, LogMessage, MalloyTranslator } from './lang';
4
4
  import { DocumentHelpContext } from './lang/parse-tree-walkers/document-help-context-walker';
5
- import { CompiledQuery, DocumentLocation, DocumentReference, FieldBooleanDef, FieldDateDef, FieldJSONDef, FieldNumberDef, FieldStringDef, FieldTimestampDef, FieldTypeDef, FilterExpression, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQuery, QueryData, QueryDataRow, QueryResult, SQLBlock, SQLBlockSource, SQLBlockStructDef, SearchIndexResult, SearchValueMapResult, StructDef, TurtleDef, FieldUnsupportedDef, QueryRunStats, ImportLocation, Annotation } from './model';
5
+ import { CompiledQuery, DocumentLocation, DocumentReference, FieldBooleanDef, FieldDateDef, FieldJSONDef, FieldNumberDef, FieldStringDef, FieldTimestampDef, FieldTypeDef, FilterExpression, Query as InternalQuery, ModelDef, DocumentPosition as ModelDocumentPosition, NamedQuery, QueryData, QueryDataRow, QueryResult, SQLBlock, SQLBlockSource, SQLBlockStructDef, SearchIndexResult, SearchValueMapResult, StructDef, TurtleDef, FeldNativeUnsupportedDef, QueryRunStats, ImportLocation, Annotation } from './model';
6
6
  import { Connection, InfoConnection, LookupConnection, ModelString, ModelURL, QueryString, QueryURL, URLReader } from './runtime_types';
7
7
  import { Tag, TagParse, TagParseSpec, Taggable } from './tags';
8
8
  import { Dialect } from './dialect';
@@ -565,7 +565,7 @@ export declare enum AtomicFieldType {
565
565
  Date = "date",
566
566
  Timestamp = "timestamp",
567
567
  Json = "json",
568
- Unsupported = "unsupported",
568
+ NativeUnsupported = "sql native",
569
569
  Error = "error"
570
570
  }
571
571
  export declare class AtomicField extends Entity implements Taggable {
@@ -641,7 +641,7 @@ export declare class JSONField extends AtomicField {
641
641
  }
642
642
  export declare class UnsupportedField extends AtomicField {
643
643
  private fieldUnsupportedDef;
644
- constructor(fieldUnsupportedDef: FieldUnsupportedDef, parent: Explore, source?: AtomicField);
644
+ constructor(fieldUnsupportedDef: FeldNativeUnsupportedDef, parent: Explore, source?: AtomicField);
645
645
  get rawType(): string | undefined;
646
646
  }
647
647
  export declare class StringField extends AtomicField {
package/dist/malloy.js CHANGED
@@ -1025,7 +1025,7 @@ class Explore extends Entity {
1025
1025
  else if (fieldDef.type === 'json') {
1026
1026
  return [name, new JSONField(fieldDef, this, sourceField)];
1027
1027
  }
1028
- else if (fieldDef.type === 'unsupported') {
1028
+ else if (fieldDef.type === 'sql native') {
1029
1029
  return [name, new UnsupportedField(fieldDef, this, sourceField)];
1030
1030
  }
1031
1031
  }
@@ -1152,7 +1152,7 @@ var AtomicFieldType;
1152
1152
  AtomicFieldType["Date"] = "date";
1153
1153
  AtomicFieldType["Timestamp"] = "timestamp";
1154
1154
  AtomicFieldType["Json"] = "json";
1155
- AtomicFieldType["Unsupported"] = "unsupported";
1155
+ AtomicFieldType["NativeUnsupported"] = "sql native";
1156
1156
  AtomicFieldType["Error"] = "error";
1157
1157
  })(AtomicFieldType || (exports.AtomicFieldType = AtomicFieldType = {}));
1158
1158
  class AtomicField extends Entity {
@@ -1175,8 +1175,8 @@ class AtomicField extends Entity {
1175
1175
  return AtomicFieldType.Number;
1176
1176
  case 'json':
1177
1177
  return AtomicFieldType.Json;
1178
- case 'unsupported':
1179
- return AtomicFieldType.Unsupported;
1178
+ case 'sql native':
1179
+ return AtomicFieldType.NativeUnsupported;
1180
1180
  case 'error':
1181
1181
  return AtomicFieldType.Error;
1182
1182
  }
@@ -1928,7 +1928,7 @@ class QueryQuery extends QueryField {
1928
1928
  annotation,
1929
1929
  });
1930
1930
  break;
1931
- case 'unsupported':
1931
+ case 'sql native':
1932
1932
  fields.push({ ...fi.f.fieldDef, resultMetadata, location });
1933
1933
  break;
1934
1934
  default:
@@ -3148,7 +3148,7 @@ class QueryStruct extends QueryNode {
3148
3148
  return new QueryFieldBoolean(field, this);
3149
3149
  case 'json':
3150
3150
  return new QueryFieldJSON(field, this);
3151
- case 'unsupported':
3151
+ case 'sql native':
3152
3152
  return new QueryFieldUnsupported(field, this);
3153
3153
  // case "reduce":
3154
3154
  // case "project":
@@ -298,7 +298,7 @@ export declare function hasExpression(f: FieldDef): f is HasExpression;
298
298
  export type TimeFieldType = 'date' | 'timestamp';
299
299
  export declare function isTimeFieldType(s: string): s is TimeFieldType;
300
300
  export type CastType = 'string' | 'number' | TimeFieldType | 'boolean' | 'json';
301
- export type AtomicFieldType = CastType | 'unsupported' | 'error';
301
+ export type AtomicFieldType = CastType | 'sql native' | 'error';
302
302
  export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
303
303
  export declare function isCastType(s: string): s is CastType;
304
304
  /**
@@ -342,13 +342,13 @@ export interface FieldJSONTypeDef {
342
342
  export interface FieldJSONDef extends FieldAtomicDef, FieldJSONTypeDef {
343
343
  type: 'json';
344
344
  }
345
- export interface FieldUnsupportedTypeDef {
346
- type: 'unsupported';
345
+ export interface FieldNativeUnsupportedTypeDef {
346
+ type: 'sql native';
347
347
  rawType?: string;
348
348
  }
349
349
  /** Scalar unsupported Field */
350
- export interface FieldUnsupportedDef extends FieldAtomicDef, FieldUnsupportedTypeDef {
351
- type: 'unsupported';
350
+ export interface FeldNativeUnsupportedDef extends FieldAtomicDef, FieldNativeUnsupportedTypeDef {
351
+ type: 'sql native';
352
352
  }
353
353
  export interface FieldErrorTypeDef {
354
354
  type: 'error';
@@ -628,8 +628,8 @@ export interface SQLBlockStructDef extends StructDef {
628
628
  }
629
629
  export declare function isSQLBlockStruct(sd: StructDef): sd is SQLBlockStructDef;
630
630
  /** any of the different field types */
631
- export type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef | FieldJSONDef | FieldUnsupportedDef | FieldErrorDef;
632
- export type FieldAtomicTypeDef = FieldStringTypeDef | FieldDateTypeDef | FieldTimestampTypeDef | FieldNumberTypeDef | FieldBooleanTypeDef | FieldJSONTypeDef | FieldUnsupportedTypeDef | FieldErrorTypeDef;
631
+ export type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef | FieldJSONDef | FeldNativeUnsupportedDef | FieldErrorDef;
632
+ export type FieldAtomicTypeDef = FieldStringTypeDef | FieldDateTypeDef | FieldTimestampTypeDef | FieldNumberTypeDef | FieldBooleanTypeDef | FieldJSONTypeDef | FieldNativeUnsupportedTypeDef | FieldErrorTypeDef;
633
633
  export declare function isFieldTypeDef(f: FieldDef): f is FieldTypeDef;
634
634
  export declare function isFieldTimeBased(f: FieldDef): f is FieldTimestampDef | FieldDateDef;
635
635
  export declare function isFieldStructDef(f: FieldDef): f is StructDef;
@@ -220,7 +220,7 @@ function isAtomicFieldType(s) {
220
220
  'timestamp',
221
221
  'boolean',
222
222
  'json',
223
- 'unsupported',
223
+ 'sql native',
224
224
  'error',
225
225
  ].includes(s);
226
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.154",
3
+ "version": "0.0.155-dev240722212948",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",