@malloydata/malloy 0.0.168-dev240815233255 → 0.0.168-dev240816220640

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.
@@ -58,6 +58,7 @@ export declare abstract class Dialect {
58
58
  supportsTempTables: boolean;
59
59
  hasModOperator: boolean;
60
60
  supportsLeftJoinUnnest: boolean;
61
+ supportsCountApprox: boolean;
61
62
  abstract getGlobalFunctionDef(name: string): DialectFunctionOverloadDef[] | undefined;
62
63
  abstract quoteTablePath(tablePath: string): string;
63
64
  abstract sqlGroupSetTable(groupSetCount: number): string;
@@ -81,6 +81,7 @@ class Dialect {
81
81
  this.hasModOperator = true;
82
82
  // can LEFT JOIN UNNEST
83
83
  this.supportsLeftJoinUnnest = true;
84
+ this.supportsCountApprox = false;
84
85
  }
85
86
  sqlFinalStage(_lastStageName, _fields) {
86
87
  throw new Error('Dialect has no final Stage but called Anyway');
@@ -20,6 +20,7 @@ export declare class DuckDBDialect extends Dialect {
20
20
  supportsQualify: boolean;
21
21
  supportsSafeCast: boolean;
22
22
  supportsNesting: boolean;
23
+ supportsCountApprox: boolean;
23
24
  get udfPrefix(): string;
24
25
  quoteTablePath(tableName: string): string;
25
26
  sqlGroupSetTable(groupSetCount: number): string;
@@ -71,6 +71,7 @@ class DuckDBDialect extends dialect_1.Dialect {
71
71
  this.supportsQualify = true;
72
72
  this.supportsSafeCast = true;
73
73
  this.supportsNesting = true;
74
+ this.supportsCountApprox = true;
74
75
  }
75
76
  // hack until they support temporary macros.
76
77
  get udfPrefix() {
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from '../../functions/util';
2
+ export declare function fnCountApprox(): DialectFunctionOverloadDef[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.fnCountApprox = void 0;
10
+ const util_1 = require("../../functions/util");
11
+ function fnCountApprox() {
12
+ const value = (0, util_1.makeParam)('value', (0, util_1.maxScalar)('number'));
13
+ return [
14
+ (0, util_1.overload)((0, util_1.minAggregate)('number'), [
15
+ (0, util_1.param)('value', (0, util_1.anyExprType)('string'), (0, util_1.anyExprType)('number'), (0, util_1.anyExprType)('date'), (0, util_1.anyExprType)('timestamp'), (0, util_1.anyExprType)('boolean')),
16
+ ], (0, util_1.sql) `APPROX_COUNT_DISTINCT(${value.arg})`, { isSymmetric: true }),
17
+ ];
18
+ }
19
+ exports.fnCountApprox = fnCountApprox;
20
+ //# sourceMappingURL=count_approx.js.map
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.DUCKDB_FUNCTIONS = void 0;
26
26
  const functions_1 = require("../../functions");
27
27
  const byte_length_1 = require("./byte_length");
28
+ const count_approx_1 = require("./count_approx");
28
29
  const div_1 = require("./div");
29
30
  const ends_with_1 = require("./ends_with");
30
31
  const greatest_and_least_1 = require("./greatest_and_least");
@@ -48,5 +49,6 @@ exports.DUCKDB_FUNCTIONS.add('unicode', unicode_1.fnUnicode);
48
49
  exports.DUCKDB_FUNCTIONS.add('replace', replace_1.fnReplace);
49
50
  exports.DUCKDB_FUNCTIONS.add('ends_with', ends_with_1.fnEndsWith);
50
51
  exports.DUCKDB_FUNCTIONS.add('log', log_1.fnLog);
52
+ exports.DUCKDB_FUNCTIONS.add('count_approx', count_approx_1.fnCountApprox);
51
53
  exports.DUCKDB_FUNCTIONS.seal();
52
54
  //# sourceMappingURL=duckdb_functions.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from '../../functions/util';
2
+ export declare function fnCountApprox(): DialectFunctionOverloadDef[];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.fnCountApprox = void 0;
10
+ const util_1 = require("../../functions/util");
11
+ function fnCountApprox() {
12
+ const value = (0, util_1.makeParam)('value', (0, util_1.maxScalar)('number'));
13
+ return [
14
+ (0, util_1.overload)((0, util_1.minAggregate)('number'), [
15
+ (0, util_1.param)('value', (0, util_1.anyExprType)('string'), (0, util_1.anyExprType)('number'), (0, util_1.anyExprType)('date'), (0, util_1.anyExprType)('timestamp'), (0, util_1.anyExprType)('boolean')),
16
+ ], (0, util_1.sql) `APPROX_DISTINCT(${value.arg})`, { isSymmetric: true }),
17
+ ];
18
+ }
19
+ exports.fnCountApprox = fnCountApprox;
20
+ //# sourceMappingURL=count_approx.js.map
@@ -36,6 +36,7 @@ const starts_ends_with_1 = require("./starts_ends_with");
36
36
  const div_1 = require("./div");
37
37
  const repeat_1 = require("./repeat");
38
38
  const reverse_1 = require("./reverse");
39
+ const count_approx_1 = require("./count_approx");
39
40
  exports.TRINO_FUNCTIONS = functions_1.FUNCTIONS.clone();
40
41
  exports.TRINO_FUNCTIONS.add('trunc', trunc_1.fnTrunc);
41
42
  exports.TRINO_FUNCTIONS.add('log', log_1.fnLog);
@@ -53,5 +54,6 @@ exports.TRINO_FUNCTIONS.add('ascii', chr_1.fnAscii);
53
54
  exports.TRINO_FUNCTIONS.add('unicode', chr_1.fnUnicode);
54
55
  exports.TRINO_FUNCTIONS.add('repeat', repeat_1.fnRepeat);
55
56
  exports.TRINO_FUNCTIONS.add('reverse', reverse_1.fnReverse);
57
+ exports.TRINO_FUNCTIONS.add('count_approx', count_approx_1.fnCountApprox);
56
58
  exports.TRINO_FUNCTIONS.seal();
57
59
  //# sourceMappingURL=trino_functions.js.map
@@ -27,6 +27,7 @@ export declare class TrinoDialect extends Dialect {
27
27
  supportsSelectReplace: boolean;
28
28
  supportsComplexFilteredSources: boolean;
29
29
  supportsTempTables: boolean;
30
+ supportsCountApprox: boolean;
30
31
  quoteTablePath(tablePath: string): string;
31
32
  sqlGroupSetTable(groupSetCount: number): string;
32
33
  dialectExpr(qi: QueryInfo, df: DialectFragment): Expr;
@@ -81,6 +81,7 @@ class TrinoDialect extends dialect_1.Dialect {
81
81
  this.supportsSelectReplace = false;
82
82
  this.supportsComplexFilteredSources = false;
83
83
  this.supportsTempTables = false;
84
+ this.supportsCountApprox = true;
84
85
  // TODO(figutierrez): update.
85
86
  this.keywords = `
86
87
  ALL
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.168-dev240815233255",
3
+ "version": "0.0.168-dev240816220640",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",