@malloydata/malloy 0.0.39-dev230613161129 → 0.0.39

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.
Files changed (288) hide show
  1. package/dist/dialect/dialect.d.ts +9 -13
  2. package/dist/dialect/dialect.js +16 -3
  3. package/dist/dialect/dialect_map.d.ts +2 -0
  4. package/dist/dialect/dialect_map.js +61 -1
  5. package/dist/dialect/{duckdb.d.ts → duckdb/duckdb.d.ts} +8 -5
  6. package/dist/dialect/{duckdb.js → duckdb/duckdb.js} +21 -9
  7. package/dist/dialect/duckdb/functions/byte_length.d.ts +2 -0
  8. package/dist/dialect/duckdb/functions/byte_length.js +33 -0
  9. package/dist/dialect/duckdb/functions/div.d.ts +2 -0
  10. package/dist/dialect/duckdb/functions/div.js +38 -0
  11. package/dist/dialect/duckdb/functions/duckdb_functions.d.ts +1 -0
  12. package/dist/dialect/duckdb/functions/duckdb_functions.js +52 -0
  13. package/dist/dialect/duckdb/functions/ends_with.d.ts +2 -0
  14. package/dist/dialect/duckdb/functions/ends_with.js +35 -0
  15. package/dist/dialect/duckdb/functions/greatest_and_least.d.ts +3 -0
  16. package/dist/dialect/duckdb/functions/greatest_and_least.js +58 -0
  17. package/dist/dialect/duckdb/functions/index.d.ts +1 -0
  18. package/dist/dialect/duckdb/functions/index.js +28 -0
  19. package/dist/dialect/duckdb/functions/is_inf.d.ts +2 -0
  20. package/dist/dialect/duckdb/functions/is_inf.js +33 -0
  21. package/dist/dialect/duckdb/functions/is_nan.d.ts +2 -0
  22. package/dist/dialect/duckdb/functions/is_nan.js +33 -0
  23. package/dist/dialect/duckdb/functions/log.d.ts +2 -0
  24. package/dist/dialect/duckdb/functions/log.js +38 -0
  25. package/dist/dialect/duckdb/functions/rand.d.ts +2 -0
  26. package/dist/dialect/duckdb/functions/rand.js +31 -0
  27. package/dist/dialect/duckdb/functions/replace.d.ts +2 -0
  28. package/dist/dialect/duckdb/functions/replace.js +40 -0
  29. package/dist/dialect/duckdb/functions/trunc.d.ts +2 -0
  30. package/dist/dialect/duckdb/functions/trunc.js +39 -0
  31. package/dist/dialect/duckdb/functions/unicode.d.ts +2 -0
  32. package/dist/dialect/duckdb/functions/unicode.js +35 -0
  33. package/dist/dialect/duckdb/index.d.ts +1 -0
  34. package/dist/dialect/duckdb/index.js +40 -0
  35. package/dist/dialect/functions/all_functions.d.ts +8 -0
  36. package/dist/dialect/functions/all_functions.js +135 -0
  37. package/dist/dialect/functions/atan2.d.ts +2 -0
  38. package/dist/dialect/functions/atan2.js +33 -0
  39. package/dist/dialect/functions/avg_moving.d.ts +2 -0
  40. package/dist/dialect/functions/avg_moving.js +46 -0
  41. package/dist/dialect/functions/chr.d.ts +4 -0
  42. package/dist/dialect/functions/chr.js +45 -0
  43. package/dist/dialect/functions/coalesce.d.ts +2 -0
  44. package/dist/dialect/functions/coalesce.js +38 -0
  45. package/dist/dialect/functions/concat.d.ts +2 -0
  46. package/dist/dialect/functions/concat.js +38 -0
  47. package/dist/dialect/functions/div.d.ts +2 -0
  48. package/dist/dialect/functions/div.js +36 -0
  49. package/dist/dialect/functions/first_value_window.d.ts +3 -0
  50. package/dist/dialect/functions/first_value_window.js +49 -0
  51. package/dist/dialect/functions/function_map.d.ts +16 -0
  52. package/dist/dialect/functions/function_map.js +50 -0
  53. package/dist/dialect/functions/greatest_and_least.d.ts +3 -0
  54. package/dist/dialect/functions/greatest_and_least.js +44 -0
  55. package/dist/dialect/functions/ifnull.d.ts +2 -0
  56. package/dist/dialect/functions/ifnull.js +38 -0
  57. package/dist/dialect/functions/index.d.ts +2 -0
  58. package/dist/dialect/functions/index.js +28 -0
  59. package/dist/dialect/functions/is_inf.d.ts +2 -0
  60. package/dist/dialect/functions/is_inf.js +33 -0
  61. package/dist/dialect/functions/is_nan.d.ts +2 -0
  62. package/dist/dialect/functions/is_nan.js +33 -0
  63. package/dist/dialect/functions/lag.d.ts +2 -0
  64. package/dist/dialect/functions/lag.js +53 -0
  65. package/dist/dialect/functions/lead.d.ts +2 -0
  66. package/dist/dialect/functions/lead.js +50 -0
  67. package/dist/dialect/functions/length.d.ts +3 -0
  68. package/dist/dialect/functions/length.js +39 -0
  69. package/dist/dialect/functions/log.d.ts +2 -0
  70. package/dist/dialect/functions/log.js +35 -0
  71. package/dist/dialect/functions/lower.d.ts +2 -0
  72. package/dist/dialect/functions/lower.js +34 -0
  73. package/dist/dialect/functions/nullif.d.ts +2 -0
  74. package/dist/dialect/functions/nullif.js +42 -0
  75. package/dist/dialect/functions/pi.d.ts +2 -0
  76. package/dist/{lang/ast/types/type-desc.js → dialect/functions/pi.js} +7 -1
  77. package/dist/dialect/functions/pow.d.ts +2 -0
  78. package/dist/dialect/functions/pow.js +35 -0
  79. package/dist/dialect/functions/rand.d.ts +2 -0
  80. package/dist/dialect/functions/rand.js +31 -0
  81. package/dist/dialect/functions/rank.d.ts +2 -0
  82. package/dist/dialect/functions/rank.js +36 -0
  83. package/dist/dialect/functions/regexp_extract.d.ts +2 -0
  84. package/dist/dialect/functions/regexp_extract.js +41 -0
  85. package/dist/dialect/functions/repeat.d.ts +2 -0
  86. package/dist/dialect/functions/repeat.js +35 -0
  87. package/dist/dialect/functions/replace.d.ts +2 -0
  88. package/dist/dialect/functions/replace.js +42 -0
  89. package/dist/dialect/functions/reverse.d.ts +2 -0
  90. package/dist/dialect/functions/reverse.js +34 -0
  91. package/dist/dialect/functions/round.d.ts +2 -0
  92. package/dist/dialect/functions/round.js +40 -0
  93. package/dist/dialect/functions/row_number.d.ts +2 -0
  94. package/dist/dialect/functions/row_number.js +40 -0
  95. package/dist/dialect/functions/simple_numeric_functions.d.ts +15 -0
  96. package/dist/dialect/functions/simple_numeric_functions.js +60 -0
  97. package/dist/dialect/functions/starts_ends_with.d.ts +3 -0
  98. package/dist/dialect/functions/starts_ends_with.js +43 -0
  99. package/dist/dialect/functions/stddev.d.ts +2 -0
  100. package/dist/dialect/functions/stddev.js +34 -0
  101. package/dist/dialect/functions/strpos.d.ts +2 -0
  102. package/dist/dialect/functions/strpos.js +35 -0
  103. package/dist/dialect/functions/substr.d.ts +2 -0
  104. package/dist/dialect/functions/substr.js +37 -0
  105. package/dist/dialect/functions/sum_min_max_window.d.ts +7 -0
  106. package/dist/dialect/functions/sum_min_max_window.js +94 -0
  107. package/dist/dialect/functions/trim_functions.d.ts +4 -0
  108. package/dist/dialect/functions/trim_functions.js +42 -0
  109. package/dist/dialect/functions/trunc.d.ts +2 -0
  110. package/dist/dialect/functions/trunc.js +38 -0
  111. package/dist/dialect/functions/upper.d.ts +2 -0
  112. package/dist/dialect/functions/upper.js +34 -0
  113. package/dist/dialect/functions/util.d.ts +45 -0
  114. package/dist/dialect/functions/util.js +187 -0
  115. package/dist/dialect/index.d.ts +1 -1
  116. package/dist/dialect/index.js +2 -1
  117. package/dist/dialect/postgres/functions/byte_length.d.ts +2 -0
  118. package/dist/dialect/postgres/functions/byte_length.js +33 -0
  119. package/dist/dialect/postgres/functions/ends_with.d.ts +2 -0
  120. package/dist/dialect/postgres/functions/ends_with.js +38 -0
  121. package/dist/dialect/postgres/functions/greatest_and_least.d.ts +3 -0
  122. package/dist/dialect/postgres/functions/greatest_and_least.js +45 -0
  123. package/dist/dialect/postgres/functions/ifnull.d.ts +2 -0
  124. package/dist/dialect/postgres/functions/ifnull.js +40 -0
  125. package/dist/dialect/postgres/functions/index.d.ts +1 -0
  126. package/dist/dialect/postgres/functions/index.js +28 -0
  127. package/dist/dialect/postgres/functions/is_inf.d.ts +2 -0
  128. package/dist/dialect/postgres/functions/is_inf.js +34 -0
  129. package/dist/dialect/postgres/functions/is_nan.d.ts +2 -0
  130. package/dist/dialect/postgres/functions/is_nan.js +33 -0
  131. package/dist/dialect/postgres/functions/log.d.ts +2 -0
  132. package/dist/dialect/postgres/functions/log.js +37 -0
  133. package/dist/dialect/postgres/functions/postgres_functions.d.ts +1 -0
  134. package/dist/dialect/postgres/functions/postgres_functions.js +60 -0
  135. package/dist/dialect/postgres/functions/rand.d.ts +2 -0
  136. package/dist/dialect/postgres/functions/rand.js +31 -0
  137. package/dist/dialect/postgres/functions/regexp_extract.d.ts +2 -0
  138. package/dist/dialect/postgres/functions/regexp_extract.js +35 -0
  139. package/dist/dialect/postgres/functions/replace.d.ts +2 -0
  140. package/dist/dialect/postgres/functions/replace.js +40 -0
  141. package/dist/dialect/postgres/functions/round.d.ts +2 -0
  142. package/dist/dialect/postgres/functions/round.js +39 -0
  143. package/dist/dialect/postgres/functions/stddev.d.ts +2 -0
  144. package/dist/dialect/postgres/functions/stddev.js +37 -0
  145. package/dist/dialect/postgres/functions/substr.d.ts +2 -0
  146. package/dist/dialect/postgres/functions/substr.js +38 -0
  147. package/dist/dialect/postgres/functions/trunc.d.ts +2 -0
  148. package/dist/dialect/postgres/functions/trunc.js +40 -0
  149. package/dist/dialect/postgres/functions/unicode.d.ts +2 -0
  150. package/dist/dialect/postgres/functions/unicode.js +34 -0
  151. package/dist/dialect/postgres/index.d.ts +1 -0
  152. package/dist/dialect/postgres/index.js +40 -0
  153. package/dist/dialect/{postgres.d.ts → postgres/postgres.d.ts} +9 -5
  154. package/dist/dialect/{postgres.js → postgres/postgres.js} +24 -10
  155. package/dist/dialect/standardsql/functions/chr.d.ts +2 -0
  156. package/dist/dialect/standardsql/functions/chr.js +37 -0
  157. package/dist/dialect/standardsql/functions/index.d.ts +1 -0
  158. package/dist/dialect/standardsql/functions/index.js +28 -0
  159. package/dist/dialect/standardsql/functions/pi.d.ts +2 -0
  160. package/dist/dialect/standardsql/functions/pi.js +32 -0
  161. package/dist/dialect/standardsql/functions/standardsql_functions.d.ts +1 -0
  162. package/dist/dialect/standardsql/functions/standardsql_functions.js +33 -0
  163. package/dist/dialect/standardsql/index.d.ts +1 -0
  164. package/dist/dialect/standardsql/index.js +40 -0
  165. package/dist/dialect/{standardsql.d.ts → standardsql/standardsql.d.ts} +7 -4
  166. package/dist/dialect/{standardsql.js → standardsql/standardsql.js} +13 -11
  167. package/dist/index.d.ts +1 -1
  168. package/dist/lang/ast/ast-utils.js +1 -0
  169. package/dist/lang/ast/elements/define-query.js +1 -1
  170. package/dist/lang/ast/elements/import-statement.js +6 -1
  171. package/dist/lang/ast/executors/index-executor.d.ts +1 -1
  172. package/dist/lang/ast/executors/index-executor.js +2 -2
  173. package/dist/lang/ast/executors/project-executor.d.ts +1 -1
  174. package/dist/lang/ast/executors/project-executor.js +2 -2
  175. package/dist/lang/ast/executors/reduce-executor.d.ts +2 -4
  176. package/dist/lang/ast/executors/reduce-executor.js +8 -4
  177. package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
  178. package/dist/lang/ast/expressions/binary-boolean.js +2 -0
  179. package/dist/lang/ast/expressions/constant-sub-expression.js +10 -0
  180. package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +2 -2
  181. package/dist/lang/ast/expressions/expr-aggregate-function.js +28 -2
  182. package/dist/lang/ast/expressions/expr-alternation-tree.js +1 -0
  183. package/dist/lang/ast/expressions/expr-cast.js +1 -0
  184. package/dist/lang/ast/expressions/expr-coalesce.d.ts +1 -1
  185. package/dist/lang/ast/expressions/expr-coalesce.js +1 -0
  186. package/dist/lang/ast/expressions/expr-count-distinct.d.ts +1 -1
  187. package/dist/lang/ast/expressions/expr-count.js +1 -0
  188. package/dist/lang/ast/expressions/expr-filter.d.ts +1 -1
  189. package/dist/lang/ast/expressions/expr-filter.js +1 -1
  190. package/dist/lang/ast/expressions/expr-func.d.ts +6 -1
  191. package/dist/lang/ast/expressions/expr-func.js +266 -16
  192. package/dist/lang/ast/expressions/expr-granular-time.d.ts +1 -1
  193. package/dist/lang/ast/expressions/expr-id-reference.js +12 -0
  194. package/dist/lang/ast/expressions/expr-logical-op.d.ts +1 -1
  195. package/dist/lang/ast/expressions/expr-max.d.ts +2 -2
  196. package/dist/lang/ast/expressions/expr-min.d.ts +2 -2
  197. package/dist/lang/ast/expressions/expr-not.d.ts +1 -1
  198. package/dist/lang/ast/expressions/expr-now.js +2 -0
  199. package/dist/lang/ast/expressions/expr-null.js +1 -0
  200. package/dist/lang/ast/expressions/expr-number.js +5 -1
  201. package/dist/lang/ast/expressions/expr-regex.js +4 -1
  202. package/dist/lang/ast/expressions/expr-string.js +1 -0
  203. package/dist/lang/ast/expressions/expr-time-extract.js +2 -0
  204. package/dist/lang/ast/expressions/expr-time.js +1 -0
  205. package/dist/lang/ast/expressions/expr-ungroup.d.ts +2 -2
  206. package/dist/lang/ast/expressions/expr-ungroup.js +15 -7
  207. package/dist/lang/ast/expressions/for-range.d.ts +1 -1
  208. package/dist/lang/ast/expressions/pick-when.js +7 -0
  209. package/dist/lang/ast/expressions/range.js +1 -0
  210. package/dist/lang/ast/expressions/time-literal.js +9 -3
  211. package/dist/lang/ast/field-space/column-space-field.d.ts +1 -2
  212. package/dist/lang/ast/field-space/dynamic-space.js +6 -4
  213. package/dist/lang/ast/field-space/field-definition-value.d.ts +1 -1
  214. package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
  215. package/dist/lang/ast/field-space/project-field-space.js +12 -13
  216. package/dist/lang/ast/field-space/query-space-field.d.ts +1 -2
  217. package/dist/lang/ast/field-space/query-space-field.js +1 -1
  218. package/dist/lang/ast/field-space/query-spaces.d.ts +16 -2
  219. package/dist/lang/ast/field-space/query-spaces.js +175 -10
  220. package/dist/lang/ast/field-space/reference-field.d.ts +3 -2
  221. package/dist/lang/ast/field-space/reference-field.js +8 -1
  222. package/dist/lang/ast/field-space/rename-space-field.d.ts +1 -2
  223. package/dist/lang/ast/field-space/static-space.d.ts +4 -3
  224. package/dist/lang/ast/field-space/static-space.js +4 -0
  225. package/dist/lang/ast/field-space/struct-space-field-base.d.ts +1 -2
  226. package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
  227. package/dist/lang/ast/field-space/wild-space-field.d.ts +1 -2
  228. package/dist/lang/ast/fragtype-utils.d.ts +1 -1
  229. package/dist/lang/ast/fragtype-utils.js +4 -3
  230. package/dist/lang/ast/index.d.ts +1 -0
  231. package/dist/lang/ast/index.js +1 -0
  232. package/dist/lang/ast/query-items/field-declaration.d.ts +40 -4
  233. package/dist/lang/ast/query-items/field-declaration.js +102 -3
  234. package/dist/lang/ast/query-items/field-references.d.ts +44 -2
  235. package/dist/lang/ast/query-items/field-references.js +110 -2
  236. package/dist/lang/ast/query-items/typecheck_utils.d.ts +10 -0
  237. package/dist/lang/ast/query-items/typecheck_utils.js +177 -0
  238. package/dist/lang/ast/query-properties/aggregate.js +0 -6
  239. package/dist/lang/ast/query-properties/calculate.d.ts +5 -0
  240. package/dist/lang/ast/query-properties/calculate.js +33 -0
  241. package/dist/lang/ast/query-properties/dimmensions.js +0 -3
  242. package/dist/lang/ast/query-properties/filters.js +6 -3
  243. package/dist/lang/ast/query-properties/group-by.js +0 -6
  244. package/dist/lang/ast/query-properties/measures.js +0 -3
  245. package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -0
  246. package/dist/lang/ast/query-properties/nest-reference.js +23 -0
  247. package/dist/lang/ast/query-properties/ordering.d.ts +1 -1
  248. package/dist/lang/ast/query-properties/ordering.js +18 -8
  249. package/dist/lang/ast/query-properties/qop-desc.js +8 -4
  250. package/dist/lang/ast/query-properties/top.js +20 -6
  251. package/dist/lang/ast/sources/named-source.js +4 -0
  252. package/dist/lang/ast/sources/sql-source.js +5 -1
  253. package/dist/lang/ast/time-utils.d.ts +1 -2
  254. package/dist/lang/ast/types/expr-result.d.ts +1 -2
  255. package/dist/lang/ast/types/expression-def.d.ts +3 -4
  256. package/dist/lang/ast/types/expression-def.js +10 -2
  257. package/dist/lang/ast/types/field-space.d.ts +7 -0
  258. package/dist/lang/ast/types/global-name-space.d.ts +12 -0
  259. package/dist/lang/ast/types/global-name-space.js +51 -0
  260. package/dist/lang/ast/types/malloy-element.d.ts +1 -0
  261. package/dist/lang/ast/types/malloy-element.js +15 -2
  262. package/dist/lang/ast/types/query-property.d.ts +1 -2
  263. package/dist/lang/ast/types/query-property.js +2 -0
  264. package/dist/lang/ast/types/space-entry.d.ts +1 -1
  265. package/dist/lang/ast/types/space-field.d.ts +1 -2
  266. package/dist/lang/ast/types/space-field.js +5 -1
  267. package/dist/lang/ast/types/space-param.d.ts +1 -2
  268. package/dist/lang/ast/types/space-param.js +10 -2
  269. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +138 -135
  270. package/dist/lang/lib/Malloy/MalloyLexer.js +1135 -1103
  271. package/dist/lang/lib/Malloy/MalloyParser.d.ts +252 -275
  272. package/dist/lang/lib/Malloy/MalloyParser.js +1753 -1905
  273. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +40 -103
  274. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +25 -64
  275. package/dist/lang/malloy-to-ast.d.ts +11 -7
  276. package/dist/lang/malloy-to-ast.js +90 -51
  277. package/dist/lang/parse-tree-walkers/document-symbol-walker.js +5 -2
  278. package/dist/lang/test/parse.spec.js +399 -18
  279. package/dist/lang/test/test-translator.d.ts +1 -0
  280. package/dist/lang/test/test-translator.js +5 -0
  281. package/dist/model/malloy_query.d.ts +13 -4
  282. package/dist/model/malloy_query.js +240 -76
  283. package/dist/model/malloy_types.d.ts +89 -18
  284. package/dist/model/malloy_types.js +88 -61
  285. package/dist/model/utils.d.ts +4 -0
  286. package/dist/model/utils.js +118 -1
  287. package/package.json +1 -1
  288. package/dist/lang/ast/types/type-desc.d.ts +0 -8
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnLog = void 0;
26
+ const util_1 = require("../../functions/util");
27
+ function fnLog() {
28
+ const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('number'));
29
+ const base = (0, util_1.makeParam)('base', (0, util_1.anyExprType)('number'));
30
+ return [
31
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [value.param, base.param],
32
+ // DuckDB doesn't seem to have a log with base function, so we use the change of base
33
+ // forumla to implement it.
34
+ (0, util_1.sql) `(LN(${value.arg}) / LN(${base.arg}))`),
35
+ ];
36
+ }
37
+ exports.fnLog = fnLog;
38
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from '../../functions/util';
2
+ export declare function fnRand(): DialectFunctionOverloadDef[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnRand = void 0;
26
+ const util_1 = require("../../functions/util");
27
+ function fnRand() {
28
+ return [(0, util_1.overload)((0, util_1.minScalar)('number'), [], (0, util_1.sql) `RANDOM()`)];
29
+ }
30
+ exports.fnRand = fnRand;
31
+ //# sourceMappingURL=rand.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from '../../functions/util';
2
+ export declare function fnReplace(): DialectFunctionOverloadDef[];
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnReplace = void 0;
26
+ const util_1 = require("../../functions/util");
27
+ function fnReplace() {
28
+ const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('string'));
29
+ const stringPattern = (0, util_1.makeParam)('pattern', (0, util_1.anyExprType)('string'));
30
+ const regexPattern = (0, util_1.makeParam)('pattern', (0, util_1.anyExprType)('regular expression'));
31
+ const replacement = (0, util_1.makeParam)('replacement', (0, util_1.anyExprType)('string'));
32
+ return [
33
+ (0, util_1.overload)((0, util_1.minScalar)('string'), [value.param, stringPattern.param, replacement.param], (0, util_1.sql) `REPLACE(${value.arg}, ${stringPattern.arg}, ${replacement.arg})`),
34
+ (0, util_1.overload)((0, util_1.minScalar)('string'), [value.param, regexPattern.param, replacement.param],
35
+ // In DuckDB we specifically need to say that the replacement should be global.
36
+ (0, util_1.sql) `REGEXP_REPLACE(${value.arg}, ${regexPattern.arg}, ${replacement.arg}, 'g')`),
37
+ ];
38
+ }
39
+ exports.fnReplace = fnReplace;
40
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from '../../functions/util';
2
+ export declare function fnTrunc(): DialectFunctionOverloadDef[];
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnTrunc = void 0;
26
+ const util_1 = require("../../functions/util");
27
+ function fnTrunc() {
28
+ const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('number'));
29
+ const precision = (0, util_1.makeParam)('precision', (0, util_1.anyExprType)('number'));
30
+ // Trunc function doesn't exist in DuckDB, so we emulate it.
31
+ // For both overloads, we switch between CEIL and FLOOR based on the sign of the arugment
32
+ // For the overload with precision, we multiply by a power of 10 before rounding, then divide.
33
+ return [
34
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [value.param], (0, util_1.sql) `CASE WHEN ${value.arg} < 0 THEN CEIL(${value.arg}) ELSE FLOOR(${value.arg}) END`),
35
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [value.param, precision.param], (0, util_1.sql) `CASE WHEN ${value.arg} < 0 THEN CEIL(${value.arg} * POW(10, ${precision.arg})) / POW(10, ${precision.arg}) ELSE FLOOR(${value.arg} * POW(10, ${precision.arg})) / POW(10, ${precision.arg}) END`),
36
+ ];
37
+ }
38
+ exports.fnTrunc = fnTrunc;
39
+ //# sourceMappingURL=trunc.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from '../../functions/util';
2
+ export declare function fnUnicode(): DialectFunctionOverloadDef[];
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnUnicode = void 0;
26
+ const util_1 = require("../../functions/util");
27
+ function fnUnicode() {
28
+ // In DuckDB, `UNICODE('')` gives -1, rather than 0.
29
+ const value = (0, util_1.makeParam)('value', (0, util_1.anyExprType)('string'));
30
+ return [
31
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [value.param], (0, util_1.sql) `CASE WHEN ${value.arg} = '' THEN 0 ELSE UNICODE(${value.arg}) END`),
32
+ ];
33
+ }
34
+ exports.fnUnicode = fnUnicode;
35
+ //# sourceMappingURL=unicode.js.map
@@ -0,0 +1 @@
1
+ export * from './duckdb';
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ var desc = Object.getOwnPropertyDescriptor(m, k);
27
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
28
+ desc = { enumerable: true, get: function() { return m[k]; } };
29
+ }
30
+ Object.defineProperty(o, k2, desc);
31
+ }) : (function(o, m, k, k2) {
32
+ if (k2 === undefined) k2 = k;
33
+ o[k2] = m[k];
34
+ }));
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ __exportStar(require("./duckdb"), exports);
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,8 @@
1
+ import { FunctionMap } from './function_map';
2
+ /**
3
+ * This is a function map containing default implementations of all Malloy
4
+ * built-in functions. These don't work in all dialects, but are a good starting
5
+ * point. In dialects where they don't work, specific functions are overridden in
6
+ * a dialect-specific function map.
7
+ */
8
+ export declare const FUNCTIONS: FunctionMap;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.FUNCTIONS = void 0;
26
+ const concat_1 = require("./concat");
27
+ const trunc_1 = require("./trunc");
28
+ const stddev_1 = require("./stddev");
29
+ const round_1 = require("./round");
30
+ const lower_1 = require("./lower");
31
+ const chr_1 = require("./chr");
32
+ const upper_1 = require("./upper");
33
+ const substr_1 = require("./substr");
34
+ const regexp_extract_1 = require("./regexp_extract");
35
+ const replace_1 = require("./replace");
36
+ const length_1 = require("./length");
37
+ const ifnull_1 = require("./ifnull");
38
+ const nullif_1 = require("./nullif");
39
+ const row_number_1 = require("./row_number");
40
+ const lag_1 = require("./lag");
41
+ const lead_1 = require("./lead");
42
+ const rank_1 = require("./rank");
43
+ const first_value_window_1 = require("./first_value_window");
44
+ const sum_min_max_window_1 = require("./sum_min_max_window");
45
+ const starts_ends_with_1 = require("./starts_ends_with");
46
+ const is_inf_1 = require("./is_inf");
47
+ const is_nan_1 = require("./is_nan");
48
+ const atan2_1 = require("./atan2");
49
+ const pow_1 = require("./pow");
50
+ const log_1 = require("./log");
51
+ const strpos_1 = require("./strpos");
52
+ const div_1 = require("./div");
53
+ const greatest_and_least_1 = require("./greatest_and_least");
54
+ const trim_functions_1 = require("./trim_functions");
55
+ const rand_1 = require("./rand");
56
+ const pi_1 = require("./pi");
57
+ const repeat_1 = require("./repeat");
58
+ const reverse_1 = require("./reverse");
59
+ const simple_numeric_functions_1 = require("./simple_numeric_functions");
60
+ const avg_moving_1 = require("./avg_moving");
61
+ const function_map_1 = require("./function_map");
62
+ const coalesce_1 = require("./coalesce");
63
+ /**
64
+ * This is a function map containing default implementations of all Malloy
65
+ * built-in functions. These don't work in all dialects, but are a good starting
66
+ * point. In dialects where they don't work, specific functions are overridden in
67
+ * a dialect-specific function map.
68
+ */
69
+ exports.FUNCTIONS = new function_map_1.FunctionMap();
70
+ // Scalar functions
71
+ exports.FUNCTIONS.add('concat', concat_1.fnConcat);
72
+ exports.FUNCTIONS.add('round', round_1.fnRound);
73
+ exports.FUNCTIONS.add('trunc', trunc_1.fnTrunc);
74
+ exports.FUNCTIONS.add('floor', simple_numeric_functions_1.fnFloor);
75
+ exports.FUNCTIONS.add('ceil', simple_numeric_functions_1.fnCeil);
76
+ exports.FUNCTIONS.add('cos', simple_numeric_functions_1.fnCos);
77
+ exports.FUNCTIONS.add('acos', simple_numeric_functions_1.fnAcos);
78
+ exports.FUNCTIONS.add('sin', simple_numeric_functions_1.fnSin);
79
+ exports.FUNCTIONS.add('asin', simple_numeric_functions_1.fnAsin);
80
+ exports.FUNCTIONS.add('tan', simple_numeric_functions_1.fnTan);
81
+ exports.FUNCTIONS.add('atan', simple_numeric_functions_1.fnAtan);
82
+ exports.FUNCTIONS.add('atan2', atan2_1.fnAtan2);
83
+ exports.FUNCTIONS.add('lower', lower_1.fnLower);
84
+ exports.FUNCTIONS.add('upper', upper_1.fnUpper);
85
+ exports.FUNCTIONS.add('sqrt', simple_numeric_functions_1.fnSqrt);
86
+ exports.FUNCTIONS.add('pow', pow_1.fnPow);
87
+ exports.FUNCTIONS.add('abs', simple_numeric_functions_1.fnAbs);
88
+ exports.FUNCTIONS.add('sign', simple_numeric_functions_1.fnSign);
89
+ exports.FUNCTIONS.add('is_inf', is_inf_1.fnIsInf);
90
+ exports.FUNCTIONS.add('is_nan', is_nan_1.fnIsNan);
91
+ exports.FUNCTIONS.add('greatest', greatest_and_least_1.fnGreatest);
92
+ exports.FUNCTIONS.add('least', greatest_and_least_1.fnLeast);
93
+ exports.FUNCTIONS.add('div', div_1.fnDiv);
94
+ exports.FUNCTIONS.add('strpos', strpos_1.fnStrpos);
95
+ exports.FUNCTIONS.add('starts_with', starts_ends_with_1.fnStartsWith);
96
+ exports.FUNCTIONS.add('ends_with', starts_ends_with_1.fnEndsWith);
97
+ exports.FUNCTIONS.add('trim', trim_functions_1.fnTrim);
98
+ exports.FUNCTIONS.add('ltrim', trim_functions_1.fnLtrim);
99
+ exports.FUNCTIONS.add('rtrim', trim_functions_1.fnRtrim);
100
+ exports.FUNCTIONS.add('rand', rand_1.fnRand);
101
+ exports.FUNCTIONS.add('pi', pi_1.fnPi);
102
+ exports.FUNCTIONS.add('substr', substr_1.fnSubstr);
103
+ exports.FUNCTIONS.add('regexp_extract', regexp_extract_1.fnRegexpExtract);
104
+ exports.FUNCTIONS.add('replace', replace_1.fnReplace);
105
+ exports.FUNCTIONS.add('length', length_1.fnLength);
106
+ exports.FUNCTIONS.add('byte_length', length_1.fnByteLength);
107
+ exports.FUNCTIONS.add('ifnull', ifnull_1.fnIfnull);
108
+ exports.FUNCTIONS.add('coalesce', coalesce_1.fnCoalesce);
109
+ exports.FUNCTIONS.add('nullif', nullif_1.fnNullif);
110
+ exports.FUNCTIONS.add('chr', chr_1.fnChr);
111
+ exports.FUNCTIONS.add('ascii', chr_1.fnAscii);
112
+ exports.FUNCTIONS.add('unicode', chr_1.fnUnicode);
113
+ exports.FUNCTIONS.add('repeat', repeat_1.fnRepeat);
114
+ exports.FUNCTIONS.add('reverse', reverse_1.fnReverse);
115
+ exports.FUNCTIONS.add('log', log_1.fnLog);
116
+ exports.FUNCTIONS.add('ln', simple_numeric_functions_1.fnLn);
117
+ exports.FUNCTIONS.add('exp', simple_numeric_functions_1.fnExp);
118
+ // Aggregate functions
119
+ exports.FUNCTIONS.add('stddev', stddev_1.fnStddev);
120
+ // Analytic functions
121
+ exports.FUNCTIONS.add('row_number', row_number_1.fnRowNumber);
122
+ exports.FUNCTIONS.add('lag', lag_1.fnLag);
123
+ exports.FUNCTIONS.add('lead', lead_1.fnLead);
124
+ exports.FUNCTIONS.add('rank', rank_1.fnRank);
125
+ exports.FUNCTIONS.add('first_value', first_value_window_1.fnFirstValueWindow);
126
+ exports.FUNCTIONS.add('last_value', first_value_window_1.fnLastValueWindow);
127
+ exports.FUNCTIONS.add('min_cumulative', sum_min_max_window_1.fnMinCumulative);
128
+ exports.FUNCTIONS.add('max_cumulative', sum_min_max_window_1.fnMaxCumulative);
129
+ exports.FUNCTIONS.add('sum_cumulative', sum_min_max_window_1.fnSumCumulative);
130
+ exports.FUNCTIONS.add('min_window', sum_min_max_window_1.fnMinWindow);
131
+ exports.FUNCTIONS.add('max_window', sum_min_max_window_1.fnMaxWindow);
132
+ exports.FUNCTIONS.add('sum_window', sum_min_max_window_1.fnSumWindow);
133
+ exports.FUNCTIONS.add('avg_moving', avg_moving_1.fnAvgRolling);
134
+ exports.FUNCTIONS.seal();
135
+ //# sourceMappingURL=all_functions.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from './util';
2
+ export declare function fnAtan2(): DialectFunctionOverloadDef[];
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnAtan2 = void 0;
26
+ const util_1 = require("./util");
27
+ function fnAtan2() {
28
+ return [
29
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [(0, util_1.param)('y', (0, util_1.anyExprType)('number')), (0, util_1.param)('x', (0, util_1.anyExprType)('number'))], (0, util_1.sql) `ATAN2(${(0, util_1.arg)('y')}, ${(0, util_1.arg)('x')})`),
30
+ ];
31
+ }
32
+ exports.fnAtan2 = fnAtan2;
33
+ //# sourceMappingURL=atan2.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from './util';
2
+ export declare function fnAvgRolling(): DialectFunctionOverloadDef[];
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnAvgRolling = void 0;
26
+ const util_1 = require("./util");
27
+ const types = ['string', 'number', 'timestamp', 'date'];
28
+ function fnAvgRolling() {
29
+ return types.flatMap(type => {
30
+ const value = (0, util_1.makeParam)('value', (0, util_1.output)((0, util_1.maxAggregate)(type)));
31
+ const preceding = (0, util_1.makeParam)('preceding', (0, util_1.literal)((0, util_1.maxScalar)('number')));
32
+ const following = (0, util_1.makeParam)('following', (0, util_1.literal)((0, util_1.maxScalar)('number')));
33
+ return [
34
+ (0, util_1.overload)((0, util_1.minAnalytic)(type), [value.param, preceding.param], (0, util_1.sql) `AVG(${value.arg})`, {
35
+ needsWindowOrderBy: true,
36
+ between: { preceding: 'preceding', following: 0 },
37
+ }),
38
+ (0, util_1.overload)((0, util_1.minAnalytic)(type), [value.param, preceding.param, following.param], (0, util_1.sql) `AVG(${value.arg})`, {
39
+ needsWindowOrderBy: true,
40
+ between: { preceding: 'preceding', following: 'following' },
41
+ }),
42
+ ];
43
+ });
44
+ }
45
+ exports.fnAvgRolling = fnAvgRolling;
46
+ //# sourceMappingURL=avg_moving.js.map
@@ -0,0 +1,4 @@
1
+ import { DialectFunctionOverloadDef } from './util';
2
+ export declare function fnChr(): DialectFunctionOverloadDef[];
3
+ export declare function fnAscii(): DialectFunctionOverloadDef[];
4
+ export declare function fnUnicode(): DialectFunctionOverloadDef[];
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnUnicode = exports.fnAscii = exports.fnChr = void 0;
26
+ const util_1 = require("./util");
27
+ function fnChr() {
28
+ return [
29
+ (0, util_1.overload)((0, util_1.minScalar)('string'), [(0, util_1.param)('value', (0, util_1.anyExprType)('number'))], (0, util_1.sql) `CASE WHEN ${(0, util_1.arg)('value')} = 0 THEN '' ELSE CHR(${(0, util_1.arg)('value')}) END`),
30
+ ];
31
+ }
32
+ exports.fnChr = fnChr;
33
+ function fnAscii() {
34
+ return [
35
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [(0, util_1.param)('value', (0, util_1.anyExprType)('string'))], (0, util_1.sql) `ASCII(${(0, util_1.arg)('value')})`),
36
+ ];
37
+ }
38
+ exports.fnAscii = fnAscii;
39
+ function fnUnicode() {
40
+ return [
41
+ (0, util_1.overload)((0, util_1.minScalar)('number'), [(0, util_1.param)('value', (0, util_1.anyExprType)('string'))], (0, util_1.sql) `UNICODE(${(0, util_1.arg)('value')})`),
42
+ ];
43
+ }
44
+ exports.fnUnicode = fnUnicode;
45
+ //# sourceMappingURL=chr.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from './util';
2
+ export declare function fnCoalesce(): DialectFunctionOverloadDef[];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnCoalesce = void 0;
26
+ const util_1 = require("./util");
27
+ const types = [
28
+ 'string',
29
+ 'number',
30
+ 'timestamp',
31
+ 'date',
32
+ 'json',
33
+ ];
34
+ function fnCoalesce() {
35
+ return types.map(type => (0, util_1.overload)((0, util_1.minScalar)(type), [(0, util_1.params)('values', (0, util_1.anyExprType)(type))], (0, util_1.sql) `COALESCE(${(0, util_1.spread)((0, util_1.arg)('values'))})`));
36
+ }
37
+ exports.fnCoalesce = fnCoalesce;
38
+ //# sourceMappingURL=coalesce.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from './util';
2
+ export declare function fnConcat(): DialectFunctionOverloadDef[];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining
6
+ * a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ */
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.fnConcat = void 0;
26
+ const util_1 = require("./util");
27
+ function fnConcat() {
28
+ return [
29
+ // TODO in DuckDB, nulls are treated like "", but in BigQuery, nulls propagate and the
30
+ // result becomes null
31
+ (0, util_1.overload)((0, util_1.minScalar)('string'), [], [{ type: 'dialect', function: 'stringLiteral', literal: '' }]),
32
+ (0, util_1.overload)((0, util_1.minScalar)('string'), [
33
+ (0, util_1.params)('values', (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')),
34
+ ], (0, util_1.sql) `CONCAT(${(0, util_1.spread)((0, util_1.arg)('values'))})`),
35
+ ];
36
+ }
37
+ exports.fnConcat = fnConcat;
38
+ //# sourceMappingURL=concat.js.map
@@ -0,0 +1,2 @@
1
+ import { DialectFunctionOverloadDef } from './util';
2
+ export declare function fnDiv(): DialectFunctionOverloadDef[];