@malloydata/malloy 0.0.223-dev241216182944 → 0.0.223-dev241217155138

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.
@@ -60,6 +60,7 @@ export declare abstract class Dialect {
60
60
  hasModOperator: boolean;
61
61
  supportsLeftJoinUnnest: boolean;
62
62
  supportsCountApprox: boolean;
63
+ supportsHyperLogLog: boolean;
63
64
  supportsFullJoin: boolean;
64
65
  nativeBoolean: boolean;
65
66
  nestedArrays: boolean;
@@ -82,6 +82,7 @@ class Dialect {
82
82
  // can LEFT JOIN UNNEST
83
83
  this.supportsLeftJoinUnnest = true;
84
84
  this.supportsCountApprox = false;
85
+ this.supportsHyperLogLog = false;
85
86
  // MYSQL doesn't have full join, maybe others.
86
87
  this.supportsFullJoin = true;
87
88
  this.nativeBoolean = true;
@@ -18,6 +18,16 @@ const dayname = {
18
18
  returns: 'string',
19
19
  impl: { function: 'DAYNAME' },
20
20
  };
21
+ const date_part = {
22
+ takes: { 'part': 'string', 'interval': { sql_native: 'interval' } },
23
+ returns: 'number',
24
+ impl: { function: 'DATE_PART' },
25
+ };
26
+ const to_seconds = {
27
+ takes: { 'seconds': 'number' },
28
+ returns: { sql_native: 'interval' },
29
+ impl: { function: 'TO_SECONDS' },
30
+ };
21
31
  const to_timestamp = {
22
32
  takes: { 'epoch_seconds': 'number' },
23
33
  returns: 'timestamp',
@@ -77,5 +87,7 @@ exports.DUCKDB_DIALECT_FUNCTIONS = {
77
87
  to_timestamp,
78
88
  string_agg,
79
89
  string_agg_distinct,
90
+ to_seconds,
91
+ date_part,
80
92
  };
81
93
  //# sourceMappingURL=dialect_functions.js.map
@@ -69,8 +69,11 @@ export type TypeDescElementBlueprintOrNamedGeneric = TypeDescElementBlueprint |
69
69
  export interface RecordBlueprint {
70
70
  record: Record<string, TypeDescElementBlueprintOrNamedGeneric>;
71
71
  }
72
+ export interface SQLNativeTypeBlueprint {
73
+ sql_native: string;
74
+ }
72
75
  export type LeafPlusType = LeafExpressionType | 'any';
73
- export type TypeDescElementBlueprint = LeafPlusType | ArrayBlueprint | RecordBlueprint;
76
+ export type TypeDescElementBlueprint = LeafPlusType | ArrayBlueprint | RecordBlueprint | SQLNativeTypeBlueprint;
74
77
  export type NamedGeneric = {
75
78
  generic: string;
76
79
  };
@@ -195,6 +195,9 @@ function expandTypeDescElementBlueprint(blueprint, allowAny = true, allowGeneric
195
195
  }
196
196
  return { type: 'generic', generic: blueprint.generic };
197
197
  }
198
+ else if ('sql_native' in blueprint) {
199
+ return { type: 'sql native', rawType: blueprint.sql_native };
200
+ }
198
201
  throw new Error('Cannot figure out type');
199
202
  }
200
203
  function expandReturnTypeBlueprint(blueprint) {
@@ -225,6 +228,9 @@ function expandReturnTypeBlueprint(blueprint) {
225
228
  else if ('measure' in blueprint) {
226
229
  return minAggregate(expandTypeDescElementBlueprint(blueprint.measure, false));
227
230
  }
231
+ else if ('sql_native' in blueprint) {
232
+ return anyExprType({ type: 'sql native', rawType: blueprint.sql_native });
233
+ }
228
234
  else {
229
235
  return minAnalytic(expandTypeDescElementBlueprint(blueprint.calculation, false));
230
236
  }
@@ -238,7 +244,8 @@ function isTypeDescBlueprint(blueprint) {
238
244
  'constant' in blueprint ||
239
245
  'dimension' in blueprint ||
240
246
  'measure' in blueprint ||
241
- 'calculation' in blueprint);
247
+ 'calculation' in blueprint ||
248
+ 'sql_native' in blueprint);
242
249
  }
243
250
  function extractParamTypeBlueprints(blueprint) {
244
251
  if (isTypeDescBlueprint(blueprint)) {
@@ -279,6 +286,9 @@ function expandParamTypeBlueprint(blueprint) {
279
286
  else if ('record' in blueprint) {
280
287
  return anyExprType(expandTypeDescElementBlueprint(blueprint, false));
281
288
  }
289
+ else if ('sql_native' in blueprint) {
290
+ return anyExprType({ type: 'sql native', rawType: blueprint.sql_native });
291
+ }
282
292
  else {
283
293
  return maxAnalytic(expandTypeDescElementBlueprint(blueprint.calculation));
284
294
  }
@@ -63,6 +63,63 @@ const count_approx = {
63
63
  impl: { function: 'APPROX_DISTINCT' },
64
64
  isSymmetric: true,
65
65
  };
66
+ const hll_accumulate = {
67
+ default: {
68
+ generic: {
69
+ 'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
70
+ },
71
+ takes: { 'value': { dimension: { generic: 'T' } } },
72
+ returns: { measure: 'string' },
73
+ isSymmetric: true,
74
+ impl: {
75
+ function: 'APPROX_SET',
76
+ },
77
+ },
78
+ with_percent: {
79
+ generic: {
80
+ 'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'],
81
+ },
82
+ takes: { 'value': { dimension: { generic: 'T' } }, 'accuracy': 'number' },
83
+ returns: { measure: 'string' },
84
+ isSymmetric: true,
85
+ impl: {
86
+ function: 'APPROX_SET',
87
+ },
88
+ },
89
+ };
90
+ const hll_combine = {
91
+ takes: {
92
+ 'value': 'string',
93
+ },
94
+ returns: { measure: 'string' },
95
+ impl: { function: 'MERGE' },
96
+ isSymmetric: true,
97
+ };
98
+ const hll_estimate = {
99
+ takes: {
100
+ 'value': 'string',
101
+ },
102
+ returns: { dimension: 'number' },
103
+ impl: { function: 'CARDINALITY' },
104
+ };
105
+ const hll_export = {
106
+ takes: {
107
+ 'value': 'string',
108
+ },
109
+ returns: { dimension: 'string' },
110
+ impl: {
111
+ sql: 'CAST(${value} AS VARBINARY)',
112
+ },
113
+ };
114
+ const hll_import = {
115
+ takes: {
116
+ 'value': 'string',
117
+ },
118
+ returns: { dimension: 'string' },
119
+ impl: {
120
+ sql: 'CAST(${value} AS HyperLogLog)',
121
+ },
122
+ };
66
123
  const max_by = {
67
124
  generic: { 'T': ['string', 'number', 'date', 'timestamp', 'boolean', 'json'] },
68
125
  takes: {
@@ -255,6 +312,8 @@ exports.TRINO_DIALECT_FUNCTIONS = {
255
312
  bool_or,
256
313
  corr,
257
314
  count_approx,
315
+ hll_accumulate,
316
+ hll_combine,
258
317
  max_by,
259
318
  min_by,
260
319
  string_agg,
@@ -266,6 +325,9 @@ exports.TRINO_DIALECT_FUNCTIONS = {
266
325
  date_format,
267
326
  date_parse,
268
327
  from_unixtime,
328
+ hll_estimate,
329
+ hll_export,
330
+ hll_import,
269
331
  json_extract_scalar,
270
332
  regexp_like,
271
333
  regexp_replace,
@@ -29,6 +29,7 @@ export declare class TrinoDialect extends PostgresBase {
29
29
  supportsComplexFilteredSources: boolean;
30
30
  supportsTempTables: boolean;
31
31
  supportsCountApprox: boolean;
32
+ supportsHyperLogLog: boolean;
32
33
  quoteTablePath(tablePath: string): string;
33
34
  sqlGroupSetTable(groupSetCount: number): string;
34
35
  exprToSQL(qi: QueryInfo, df: Expr): string | undefined;
@@ -109,6 +109,7 @@ class TrinoDialect extends pg_impl_1.PostgresBase {
109
109
  this.supportsComplexFilteredSources = false;
110
110
  this.supportsTempTables = false;
111
111
  this.supportsCountApprox = true;
112
+ this.supportsHyperLogLog = true;
112
113
  // TODO(figutierrez): update.
113
114
  this.keywords = `
114
115
  ALL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.223-dev241216182944",
3
+ "version": "0.0.223-dev241217155138",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",