@malloydata/malloy 0.0.237-dev250223010918 → 0.0.237-dev250224203840

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.
@@ -1,4 +1,4 @@
1
- import { Expr, Sampling, AtomicTypeDef, MeasureTimeExpr, TimeTruncExpr, TimeExtractExpr, TimeDeltaExpr, TypecastExpr, RegexMatchExpr, TimeLiteralNode, RecordLiteralNode, ArrayLiteralNode, LeafAtomicTypeDef, OrderBy } from '../model/malloy_types';
1
+ import { Expr, Sampling, AtomicTypeDef, MeasureTimeExpr, TimeTruncExpr, TimeExtractExpr, TimeDeltaExpr, TypecastExpr, RegexMatchExpr, TimeLiteralNode, RecordLiteralNode, ArrayLiteralNode, LeafAtomicTypeDef, OrderBy, BinaryExpr } from '../model/malloy_types';
2
2
  import { DialectFunctionOverloadDef } from './functions';
3
3
  type DialectFieldTypes = string | 'struct';
4
4
  interface DialectField {
@@ -65,6 +65,7 @@ export declare abstract class Dialect {
65
65
  nestedArrays: boolean;
66
66
  compoundObjectInSchema: boolean;
67
67
  booleanAsNumbers: boolean;
68
+ likeEscape: boolean;
68
69
  abstract getDialectFunctionOverrides(): {
69
70
  [name: string]: DialectFunctionOverloadDef[];
70
71
  };
@@ -138,5 +139,6 @@ export declare abstract class Dialect {
138
139
  dstTypeDef: LeafAtomicTypeDef | undefined;
139
140
  dstSQLType: string;
140
141
  };
142
+ likeExpr(expr: BinaryExpr): string;
141
143
  }
142
144
  export {};
@@ -91,6 +91,8 @@ class Dialect {
91
91
  this.compoundObjectInSchema = true;
92
92
  // No true boolean type, e.g. true=1 and false=0, set this to true
93
93
  this.booleanAsNumbers = false;
94
+ // Like characters are escaped with ESCAPE clause
95
+ this.likeEscape = true;
94
96
  }
95
97
  sqlFinalStage(_lastStageName, _fields) {
96
98
  throw new Error('Dialect has no final Stage but called Anyway');
@@ -223,6 +225,22 @@ class Dialect {
223
225
  dstSQLType: this.malloyTypeToSQLType(cast.dstType),
224
226
  };
225
227
  }
228
+ likeExpr(expr) {
229
+ const isLike = expr.kids.right;
230
+ if (expr.node === 'like' || expr.node === '!like') {
231
+ const likeOp = expr.node === '!like' ? 'NOT LIKE' : 'LIKE';
232
+ if (this.likeEscape && isLike.node === 'stringLiteral') {
233
+ const likeStr = isLike.literal;
234
+ if (likeStr.includes('\\')) {
235
+ const escapeUp = likeStr.replace(/\^/g, '^^');
236
+ const newLikeStr = escapeUp.replace(/\\/g, '^');
237
+ return `${expr.kids.left.sql} ${likeOp} '${newLikeStr}' ESCAPE '^'`;
238
+ }
239
+ }
240
+ return `${expr.kids.left.sql} ${likeOp} ${isLike.sql}`;
241
+ }
242
+ return 'false';
243
+ }
226
244
  }
227
245
  exports.Dialect = Dialect;
228
246
  //# sourceMappingURL=dialect.js.map
@@ -25,6 +25,7 @@ export declare class StandardSQLDialect extends Dialect {
25
25
  hasModOperator: boolean;
26
26
  nestedArrays: boolean;
27
27
  supportsHyperLogLog: boolean;
28
+ likeEscape: boolean;
28
29
  quoteTablePath(tablePath: string): string;
29
30
  sqlGroupSetTable(groupSetCount: number): string;
30
31
  sqlAnyValue(groupSet: number, fieldName: string): string;
@@ -99,6 +99,7 @@ class StandardSQLDialect extends dialect_1.Dialect {
99
99
  this.hasModOperator = false;
100
100
  this.nestedArrays = false; // Can't have an array of arrays for some reason
101
101
  this.supportsHyperLogLog = true;
102
+ this.likeEscape = false; // Uses \ instead of ESCAPE 'X' in like clauses
102
103
  }
103
104
  quoteTablePath(tablePath) {
104
105
  return `\`${tablePath}\``;
@@ -106,66 +106,67 @@ export declare class MalloyLexer extends Lexer {
106
106
  static readonly WITH = 101;
107
107
  static readonly YEAR = 102;
108
108
  static readonly UNGROUPED = 103;
109
- static readonly STRING_ESCAPE = 104;
110
- static readonly HACKY_REGEX = 105;
111
- static readonly SQ_STRING = 106;
112
- static readonly DQ_STRING = 107;
113
- static readonly BQ_STRING = 108;
114
- static readonly DOC_ANNOTATION = 109;
115
- static readonly ANNOTATION = 110;
116
- static readonly AMPER = 111;
117
- static readonly ARROW = 112;
118
- static readonly FAT_ARROW = 113;
119
- static readonly OPAREN = 114;
120
- static readonly CPAREN = 115;
121
- static readonly OBRACK = 116;
122
- static readonly CBRACK = 117;
123
- static readonly OCURLY = 118;
124
- static readonly CCURLY = 119;
125
- static readonly DOUBLECOLON = 120;
126
- static readonly TRIPLECOLON = 121;
127
- static readonly EXCLAM = 122;
128
- static readonly COLON = 123;
129
- static readonly COMMA = 124;
130
- static readonly DOT = 125;
131
- static readonly LT = 126;
132
- static readonly GT = 127;
133
- static readonly EQ = 128;
134
- static readonly NE = 129;
135
- static readonly LTE = 130;
136
- static readonly GTE = 131;
137
- static readonly PLUS = 132;
138
- static readonly MINUS = 133;
139
- static readonly STAR = 134;
140
- static readonly STARSTAR = 135;
141
- static readonly SLASH = 136;
142
- static readonly BAR = 137;
143
- static readonly SEMI = 138;
144
- static readonly NOT_MATCH = 139;
145
- static readonly MATCH = 140;
146
- static readonly PERCENT = 141;
147
- static readonly DOUBLE_QMARK = 142;
148
- static readonly QMARK = 143;
149
- static readonly LITERAL_TIMESTAMP = 144;
150
- static readonly LITERAL_HOUR = 145;
151
- static readonly LITERAL_DAY = 146;
152
- static readonly LITERAL_QUARTER = 147;
153
- static readonly LITERAL_MONTH = 148;
154
- static readonly LITERAL_WEEK = 149;
155
- static readonly LITERAL_YEAR = 150;
156
- static readonly IDENTIFIER = 151;
157
- static readonly PERCENT_LITERAL = 152;
158
- static readonly NUMERIC_LITERAL = 153;
159
- static readonly INTEGER_LITERAL = 154;
160
- static readonly BLOCK_COMMENT = 155;
161
- static readonly COMMENT_TO_EOL = 156;
162
- static readonly WHITE_SPACE = 157;
163
- static readonly SQL_BEGIN = 158;
164
- static readonly CLOSE_CODE = 159;
165
- static readonly UNWATED_CHARS_TRAILING_NUMBERS = 160;
166
- static readonly UNEXPECTED_CHAR = 161;
167
- static readonly OPEN_CODE = 162;
168
- static readonly SQL_END = 163;
109
+ static readonly HACKY_REGEX = 104;
110
+ static readonly RAW_SQ = 105;
111
+ static readonly RAW_DQ = 106;
112
+ static readonly SQ_STRING = 107;
113
+ static readonly DQ_STRING = 108;
114
+ static readonly BQ_STRING = 109;
115
+ static readonly DOC_ANNOTATION = 110;
116
+ static readonly ANNOTATION = 111;
117
+ static readonly AMPER = 112;
118
+ static readonly ARROW = 113;
119
+ static readonly FAT_ARROW = 114;
120
+ static readonly OPAREN = 115;
121
+ static readonly CPAREN = 116;
122
+ static readonly OBRACK = 117;
123
+ static readonly CBRACK = 118;
124
+ static readonly OCURLY = 119;
125
+ static readonly CCURLY = 120;
126
+ static readonly DOUBLECOLON = 121;
127
+ static readonly TRIPLECOLON = 122;
128
+ static readonly EXCLAM = 123;
129
+ static readonly COLON = 124;
130
+ static readonly COMMA = 125;
131
+ static readonly DOT = 126;
132
+ static readonly LT = 127;
133
+ static readonly GT = 128;
134
+ static readonly EQ = 129;
135
+ static readonly NE = 130;
136
+ static readonly LTE = 131;
137
+ static readonly GTE = 132;
138
+ static readonly PLUS = 133;
139
+ static readonly MINUS = 134;
140
+ static readonly STAR = 135;
141
+ static readonly STARSTAR = 136;
142
+ static readonly SLASH = 137;
143
+ static readonly BAR = 138;
144
+ static readonly SEMI = 139;
145
+ static readonly NOT_MATCH = 140;
146
+ static readonly MATCH = 141;
147
+ static readonly PERCENT = 142;
148
+ static readonly DOUBLE_QMARK = 143;
149
+ static readonly QMARK = 144;
150
+ static readonly LITERAL_TIMESTAMP = 145;
151
+ static readonly LITERAL_HOUR = 146;
152
+ static readonly LITERAL_DAY = 147;
153
+ static readonly LITERAL_QUARTER = 148;
154
+ static readonly LITERAL_MONTH = 149;
155
+ static readonly LITERAL_WEEK = 150;
156
+ static readonly LITERAL_YEAR = 151;
157
+ static readonly IDENTIFIER = 152;
158
+ static readonly PERCENT_LITERAL = 153;
159
+ static readonly NUMERIC_LITERAL = 154;
160
+ static readonly INTEGER_LITERAL = 155;
161
+ static readonly BLOCK_COMMENT = 156;
162
+ static readonly COMMENT_TO_EOL = 157;
163
+ static readonly WHITE_SPACE = 158;
164
+ static readonly SQL_BEGIN = 159;
165
+ static readonly CLOSE_CODE = 160;
166
+ static readonly UNWATED_CHARS_TRAILING_NUMBERS = 161;
167
+ static readonly UNEXPECTED_CHAR = 162;
168
+ static readonly OPEN_CODE = 163;
169
+ static readonly SQL_END = 164;
169
170
  static readonly SQL_MODE = 1;
170
171
  static readonly channelNames: string[];
171
172
  static readonly modeNames: string[];