@malloydata/malloy 0.0.143-dev240418162623 → 0.0.143-dev240419025427
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 +1 -0
- package/dist/dialect/dialect.js +7 -0
- package/dist/dialect/standardsql/standardsql.d.ts +1 -0
- package/dist/dialect/standardsql/standardsql.js +1 -0
- package/dist/lang/ast/types/expression-def.js +5 -5
- package/dist/model/malloy_query.js +1 -0
- package/dist/model/malloy_types.d.ts +3 -3
- package/package.json +1 -1
|
@@ -55,6 +55,7 @@ export declare abstract class Dialect {
|
|
|
55
55
|
supportsSelectReplace: boolean;
|
|
56
56
|
supportsComplexFilteredSources: boolean;
|
|
57
57
|
supportsTempTables: boolean;
|
|
58
|
+
hasModOperator: boolean;
|
|
58
59
|
abstract getGlobalFunctionDef(name: string): DialectFunctionOverloadDef[] | undefined;
|
|
59
60
|
abstract quoteTablePath(tablePath: string): string;
|
|
60
61
|
abstract sqlGroupSetTable(groupSetCount: number): string;
|
package/dist/dialect/dialect.js
CHANGED
|
@@ -78,6 +78,7 @@ class Dialect {
|
|
|
78
78
|
this.supportsComplexFilteredSources = true;
|
|
79
79
|
// can create temp tables
|
|
80
80
|
this.supportsTempTables = true;
|
|
81
|
+
this.hasModOperator = true;
|
|
81
82
|
}
|
|
82
83
|
sqlFinalStage(_lastStageName, _fields) {
|
|
83
84
|
throw new Error('Dialect has no final Stage but called Anyway');
|
|
@@ -116,6 +117,12 @@ class Dialect {
|
|
|
116
117
|
}
|
|
117
118
|
return (0, malloy_types_1.mkExpr) `${df.numerator}/${df.denominator}`;
|
|
118
119
|
}
|
|
120
|
+
case 'mod': {
|
|
121
|
+
if (this.hasModOperator) {
|
|
122
|
+
return (0, malloy_types_1.mkExpr) `${df.numerator}%${df.denominator}`;
|
|
123
|
+
}
|
|
124
|
+
return (0, malloy_types_1.mkExpr) `mod(${df.numerator},${df.denominator})`;
|
|
125
|
+
}
|
|
119
126
|
case 'timeLiteral': {
|
|
120
127
|
return [
|
|
121
128
|
this.sqlLiteralTime(qi, df.literal, df.literalType, df.timezone),
|
|
@@ -21,6 +21,7 @@ export declare class StandardSQLDialect extends Dialect {
|
|
|
21
21
|
supportsSafeCast: boolean;
|
|
22
22
|
supportsNesting: boolean;
|
|
23
23
|
cantPartitionWindowFunctionsOnExpressions: boolean;
|
|
24
|
+
hasModOperator: boolean;
|
|
24
25
|
quoteTablePath(tablePath: string): string;
|
|
25
26
|
sqlGroupSetTable(groupSetCount: number): string;
|
|
26
27
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
@@ -399,10 +399,10 @@ function applyBinary(fs, left, op, right) {
|
|
|
399
399
|
if (oneOf(op, '+', '-')) {
|
|
400
400
|
return delta(fs, left, op, right);
|
|
401
401
|
}
|
|
402
|
-
if (
|
|
402
|
+
if (op === '*') {
|
|
403
403
|
return numeric(fs, left, op, right);
|
|
404
404
|
}
|
|
405
|
-
if (oneOf(op, '/')) {
|
|
405
|
+
if (oneOf(op, '/', '%')) {
|
|
406
406
|
const num = left.getExpression(fs);
|
|
407
407
|
const denom = right.getExpression(fs);
|
|
408
408
|
const noGo = unsupportError(left, num, right, denom);
|
|
@@ -414,15 +414,15 @@ function applyBinary(fs, left, op, right) {
|
|
|
414
414
|
if (err)
|
|
415
415
|
return err;
|
|
416
416
|
if (num.dataType !== 'number') {
|
|
417
|
-
left.log('Numerator
|
|
417
|
+
left.log('Numerator must be a number');
|
|
418
418
|
}
|
|
419
419
|
else if (denom.dataType !== 'number') {
|
|
420
|
-
right.log('Denominator
|
|
420
|
+
right.log('Denominator must be a number');
|
|
421
421
|
}
|
|
422
422
|
else {
|
|
423
423
|
const div = {
|
|
424
424
|
type: 'dialect',
|
|
425
|
-
function: 'div',
|
|
425
|
+
function: op === '/' ? 'div' : 'mod',
|
|
426
426
|
numerator: num.value,
|
|
427
427
|
denominator: denom.value,
|
|
428
428
|
};
|
|
@@ -230,8 +230,8 @@ export interface RegexpMatchFragment extends DialectFragmentBase {
|
|
|
230
230
|
expr: Expr;
|
|
231
231
|
regexp: Expr;
|
|
232
232
|
}
|
|
233
|
-
export interface
|
|
234
|
-
function: 'div';
|
|
233
|
+
export interface DivModFragment extends DialectFragmentBase {
|
|
234
|
+
function: 'div' | 'mod';
|
|
235
235
|
numerator: Expr;
|
|
236
236
|
denominator: Expr;
|
|
237
237
|
}
|
|
@@ -253,7 +253,7 @@ export interface NumberLiteralFragment extends DialectFragmentBase {
|
|
|
253
253
|
function: 'numberLiteral';
|
|
254
254
|
literal: string;
|
|
255
255
|
}
|
|
256
|
-
export type DialectFragment =
|
|
256
|
+
export type DialectFragment = DivModFragment | TimeLiteralFragment | NowFragment | TimeDeltaFragment | TimeDiffFragment | TimeTruncFragment | TypecastFragment | TimeExtractFragment | StringLiteralFragment | RegexpLiteralFragment | NumberLiteralFragment | RegexpMatchFragment;
|
|
257
257
|
export type Fragment = string | ApplyFragment | ApplyValueFragment | FieldFragment | SourceReferenceFragment | SqlStringFragment | ParameterFragment | FilterFragment | OutputFieldFragment | AggregateFragment | UngroupFragment | DialectFragment | FunctionParameterFragment | AggregateOrderByFragment | AggregateLimitFragment | FunctionCallFragment | SQLExpressionFragment | SpreadFragment;
|
|
258
258
|
export type Expr = Fragment[];
|
|
259
259
|
export interface TypedValue {
|