@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.
- package/dist/dialect/dialect.d.ts +3 -1
- package/dist/dialect/dialect.js +18 -0
- package/dist/dialect/standardsql/standardsql.d.ts +1 -0
- package/dist/dialect/standardsql/standardsql.js +1 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +61 -60
- package/dist/lang/lib/Malloy/MalloyLexer.js +969 -937
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +116 -97
- package/dist/lang/lib/Malloy/MalloyParser.js +1947 -1819
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +24 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +15 -0
- package/dist/lang/malloy-to-ast.d.ts +1 -0
- package/dist/lang/malloy-to-ast.js +9 -0
- package/dist/lang/parse-log.d.ts +1 -0
- package/dist/lang/test/expressions.spec.js +11 -11
- package/dist/lang/test/literals.spec.js +14 -2
- package/dist/lang/test/parse-expects.js +1 -1
- package/dist/model/malloy_query.js +3 -3
- package/package.json +1 -1
|
@@ -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 {};
|
package/dist/dialect/dialect.js
CHANGED
|
@@ -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
|
|
110
|
-
static readonly
|
|
111
|
-
static readonly
|
|
112
|
-
static readonly
|
|
113
|
-
static readonly
|
|
114
|
-
static readonly
|
|
115
|
-
static readonly
|
|
116
|
-
static readonly
|
|
117
|
-
static readonly
|
|
118
|
-
static readonly
|
|
119
|
-
static readonly
|
|
120
|
-
static readonly
|
|
121
|
-
static readonly
|
|
122
|
-
static readonly
|
|
123
|
-
static readonly
|
|
124
|
-
static readonly
|
|
125
|
-
static readonly
|
|
126
|
-
static readonly
|
|
127
|
-
static readonly
|
|
128
|
-
static readonly
|
|
129
|
-
static readonly
|
|
130
|
-
static readonly
|
|
131
|
-
static readonly
|
|
132
|
-
static readonly
|
|
133
|
-
static readonly
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly
|
|
137
|
-
static readonly
|
|
138
|
-
static readonly
|
|
139
|
-
static readonly
|
|
140
|
-
static readonly
|
|
141
|
-
static readonly
|
|
142
|
-
static readonly
|
|
143
|
-
static readonly
|
|
144
|
-
static readonly
|
|
145
|
-
static readonly
|
|
146
|
-
static readonly
|
|
147
|
-
static readonly
|
|
148
|
-
static readonly
|
|
149
|
-
static readonly
|
|
150
|
-
static readonly
|
|
151
|
-
static readonly
|
|
152
|
-
static readonly
|
|
153
|
-
static readonly
|
|
154
|
-
static readonly
|
|
155
|
-
static readonly
|
|
156
|
-
static readonly
|
|
157
|
-
static readonly
|
|
158
|
-
static readonly
|
|
159
|
-
static readonly
|
|
160
|
-
static readonly
|
|
161
|
-
static readonly
|
|
162
|
-
static readonly
|
|
163
|
-
static readonly
|
|
164
|
-
static readonly
|
|
165
|
-
static readonly
|
|
166
|
-
static readonly
|
|
167
|
-
static readonly
|
|
168
|
-
static readonly
|
|
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[];
|