elasticsearch 9.0.2__py3-none-any.whl → 9.0.3__py3-none-any.whl

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 (54) hide show
  1. elasticsearch/_async/client/__init__.py +42 -198
  2. elasticsearch/_async/client/cat.py +393 -25
  3. elasticsearch/_async/client/cluster.py +14 -4
  4. elasticsearch/_async/client/eql.py +10 -2
  5. elasticsearch/_async/client/esql.py +17 -4
  6. elasticsearch/_async/client/indices.py +87 -43
  7. elasticsearch/_async/client/inference.py +108 -3
  8. elasticsearch/_async/client/ingest.py +0 -7
  9. elasticsearch/_async/client/license.py +4 -4
  10. elasticsearch/_async/client/ml.py +6 -17
  11. elasticsearch/_async/client/monitoring.py +1 -1
  12. elasticsearch/_async/client/rollup.py +1 -22
  13. elasticsearch/_async/client/security.py +11 -17
  14. elasticsearch/_async/client/snapshot.py +6 -0
  15. elasticsearch/_async/client/synonyms.py +1 -0
  16. elasticsearch/_async/client/watcher.py +4 -2
  17. elasticsearch/_sync/client/__init__.py +42 -198
  18. elasticsearch/_sync/client/cat.py +393 -25
  19. elasticsearch/_sync/client/cluster.py +14 -4
  20. elasticsearch/_sync/client/eql.py +10 -2
  21. elasticsearch/_sync/client/esql.py +17 -4
  22. elasticsearch/_sync/client/indices.py +87 -43
  23. elasticsearch/_sync/client/inference.py +108 -3
  24. elasticsearch/_sync/client/ingest.py +0 -7
  25. elasticsearch/_sync/client/license.py +4 -4
  26. elasticsearch/_sync/client/ml.py +6 -17
  27. elasticsearch/_sync/client/monitoring.py +1 -1
  28. elasticsearch/_sync/client/rollup.py +1 -22
  29. elasticsearch/_sync/client/security.py +11 -17
  30. elasticsearch/_sync/client/snapshot.py +6 -0
  31. elasticsearch/_sync/client/synonyms.py +1 -0
  32. elasticsearch/_sync/client/watcher.py +4 -2
  33. elasticsearch/_version.py +1 -1
  34. elasticsearch/compat.py +5 -0
  35. elasticsearch/dsl/__init__.py +2 -1
  36. elasticsearch/dsl/document_base.py +176 -16
  37. elasticsearch/dsl/field.py +222 -47
  38. elasticsearch/dsl/query.py +7 -4
  39. elasticsearch/dsl/types.py +105 -80
  40. elasticsearch/dsl/utils.py +1 -1
  41. elasticsearch/{dsl/_sync/_sync_check → esql}/__init__.py +2 -0
  42. elasticsearch/esql/esql.py +1105 -0
  43. elasticsearch/esql/functions.py +1738 -0
  44. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.3.dist-info}/METADATA +1 -1
  45. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.3.dist-info}/RECORD +48 -52
  46. elasticsearch/dsl/_sync/_sync_check/document.py +0 -514
  47. elasticsearch/dsl/_sync/_sync_check/faceted_search.py +0 -50
  48. elasticsearch/dsl/_sync/_sync_check/index.py +0 -597
  49. elasticsearch/dsl/_sync/_sync_check/mapping.py +0 -49
  50. elasticsearch/dsl/_sync/_sync_check/search.py +0 -230
  51. elasticsearch/dsl/_sync/_sync_check/update_by_query.py +0 -45
  52. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.3.dist-info}/WHEEL +0 -0
  53. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.3.dist-info}/licenses/LICENSE +0 -0
  54. {elasticsearch-9.0.2.dist-info → elasticsearch-9.0.3.dist-info}/licenses/NOTICE +0 -0
@@ -0,0 +1,1738 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ import json
19
+ from typing import Any
20
+
21
+ from elasticsearch.dsl.document_base import InstrumentedExpression
22
+ from elasticsearch.esql.esql import ExpressionType
23
+
24
+
25
+ def _render(v: Any) -> str:
26
+ return json.dumps(v) if not isinstance(v, InstrumentedExpression) else str(v)
27
+
28
+
29
+ def abs(number: ExpressionType) -> InstrumentedExpression:
30
+ """Returns the absolute value.
31
+
32
+ :param number: Numeric expression. If `null`, the function returns `null`.
33
+ """
34
+ return InstrumentedExpression(f"ABS({_render(number)})")
35
+
36
+
37
+ def acos(number: ExpressionType) -> InstrumentedExpression:
38
+ """Returns the arccosine of `n` as an angle, expressed in radians.
39
+
40
+ :param number: Number between -1 and 1. If `null`, the function returns `null`.
41
+ """
42
+ return InstrumentedExpression(f"ACOS({_render(number)})")
43
+
44
+
45
+ def asin(number: ExpressionType) -> InstrumentedExpression:
46
+ """Returns the arcsine of the input numeric expression as an angle,
47
+ expressed in radians.
48
+
49
+ :param number: Number between -1 and 1. If `null`, the function returns `null`.
50
+ """
51
+ return InstrumentedExpression(f"ASIN({_render(number)})")
52
+
53
+
54
+ def atan(number: ExpressionType) -> InstrumentedExpression:
55
+ """Returns the arctangent of the input numeric expression as an angle,
56
+ expressed in radians.
57
+
58
+ :param number: Numeric expression. If `null`, the function returns `null`.
59
+ """
60
+ return InstrumentedExpression(f"ATAN({_render(number)})")
61
+
62
+
63
+ def atan2(
64
+ y_coordinate: ExpressionType, x_coordinate: ExpressionType
65
+ ) -> InstrumentedExpression:
66
+ """The angle between the positive x-axis and the ray from the origin to the
67
+ point (x , y) in the Cartesian plane, expressed in radians.
68
+
69
+ :param y_coordinate: y coordinate. If `null`, the function returns `null`.
70
+ :param x_coordinate: x coordinate. If `null`, the function returns `null`.
71
+ """
72
+ return InstrumentedExpression(f"ATAN2({y_coordinate}, {x_coordinate})")
73
+
74
+
75
+ def avg(number: ExpressionType) -> InstrumentedExpression:
76
+ """The average of a numeric field.
77
+
78
+ :param number: Expression that outputs values to average.
79
+ """
80
+ return InstrumentedExpression(f"AVG({_render(number)})")
81
+
82
+
83
+ def avg_over_time(number: ExpressionType) -> InstrumentedExpression:
84
+ """The average over time of a numeric field.
85
+
86
+ :param number: Expression that outputs values to average.
87
+ """
88
+ return InstrumentedExpression(f"AVG_OVER_TIME({_render(number)})")
89
+
90
+
91
+ def bit_length(string: ExpressionType) -> InstrumentedExpression:
92
+ """Returns the bit length of a string.
93
+
94
+ :param string: String expression. If `null`, the function returns `null`.
95
+ """
96
+ return InstrumentedExpression(f"BIT_LENGTH({_render(string)})")
97
+
98
+
99
+ def bucket(
100
+ field: ExpressionType,
101
+ buckets: ExpressionType,
102
+ from_: ExpressionType,
103
+ to: ExpressionType,
104
+ ) -> InstrumentedExpression:
105
+ """Creates groups of values - buckets - out of a datetime or numeric input.
106
+ The size of the buckets can either be provided directly, or chosen based on
107
+ a recommended count and values range.
108
+
109
+ :param field: Numeric or date expression from which to derive buckets.
110
+ :param buckets: Target number of buckets, or desired bucket size if `from`
111
+ and `to` parameters are omitted.
112
+ :param from_: Start of the range. Can be a number, a date or a date expressed
113
+ as a string.
114
+ :param to: End of the range. Can be a number, a date or a date expressed as a string.
115
+ """
116
+ return InstrumentedExpression(
117
+ f"BUCKET({_render(field)}, {_render(buckets)}, {from_}, {_render(to)})"
118
+ )
119
+
120
+
121
+ def byte_length(string: ExpressionType) -> InstrumentedExpression:
122
+ """Returns the byte length of a string.
123
+
124
+ :param string: String expression. If `null`, the function returns `null`.
125
+ """
126
+ return InstrumentedExpression(f"BYTE_LENGTH({_render(string)})")
127
+
128
+
129
+ def case(*conditions: ExpressionType) -> InstrumentedExpression:
130
+ """Accepts pairs of conditions and values. The function returns the value
131
+ that belongs to the first condition that evaluates to `true`. If the
132
+ number of arguments is odd, the last argument is the default value which is
133
+ returned when no condition matches. If the number of arguments is even, and
134
+ no condition matches, the function returns `null`.
135
+ """
136
+ return InstrumentedExpression(
137
+ f'CASE({", ".join([_render(c) for c in conditions])})'
138
+ )
139
+
140
+
141
+ def categorize(field: ExpressionType) -> InstrumentedExpression:
142
+ """Groups text messages into categories of similarly formatted text values.
143
+
144
+ :param field: Expression to categorize
145
+ """
146
+ return InstrumentedExpression(f"CATEGORIZE({_render(field)})")
147
+
148
+
149
+ def cbrt(number: ExpressionType) -> InstrumentedExpression:
150
+ """Returns the cube root of a number. The input can be any numeric value,
151
+ the return value is always a double. Cube roots of infinities are null.
152
+
153
+ :param number: Numeric expression. If `null`, the function returns `null`.
154
+ """
155
+ return InstrumentedExpression(f"CBRT({_render(number)})")
156
+
157
+
158
+ def ceil(number: ExpressionType) -> InstrumentedExpression:
159
+ """Round a number up to the nearest integer.
160
+
161
+ :param number: Numeric expression. If `null`, the function returns `null`.
162
+ """
163
+ return InstrumentedExpression(f"CEIL({_render(number)})")
164
+
165
+
166
+ def cidr_match(ip: ExpressionType, block_x: ExpressionType) -> InstrumentedExpression:
167
+ """Returns true if the provided IP is contained in one of the provided CIDR blocks.
168
+
169
+ :param ip: IP address of type `ip` (both IPv4 and IPv6 are supported).
170
+ :param block_x: CIDR block to test the IP against.
171
+ """
172
+ return InstrumentedExpression(f"CIDR_MATCH({_render(ip)}, {block_x})")
173
+
174
+
175
+ def coalesce(first: ExpressionType, rest: ExpressionType) -> InstrumentedExpression:
176
+ """Returns the first of its arguments that is not null. If all arguments
177
+ are null, it returns `null`.
178
+
179
+ :param first: Expression to evaluate.
180
+ :param rest: Other expression to evaluate.
181
+ """
182
+ return InstrumentedExpression(f"COALESCE({_render(first)}, {_render(rest)})")
183
+
184
+
185
+ def concat(*strings: ExpressionType) -> InstrumentedExpression:
186
+ """Concatenates two or more strings."""
187
+ return InstrumentedExpression(
188
+ f'CONCAT({", ".join([f"{_render(s)}" for s in strings])})'
189
+ )
190
+
191
+
192
+ def cos(angle: ExpressionType) -> InstrumentedExpression:
193
+ """Returns the cosine of an angle.
194
+
195
+ :param angle: An angle, in radians. If `null`, the function returns `null`.
196
+ """
197
+ return InstrumentedExpression(f"COS({_render(angle)})")
198
+
199
+
200
+ def cosh(number: ExpressionType) -> InstrumentedExpression:
201
+ """Returns the hyperbolic cosine of a number.
202
+
203
+ :param number: Numeric expression. If `null`, the function returns `null`.
204
+ """
205
+ return InstrumentedExpression(f"COSH({_render(number)})")
206
+
207
+
208
+ def count(field: ExpressionType) -> InstrumentedExpression:
209
+ """Returns the total number (count) of input values.
210
+
211
+ :param field: Expression that outputs values to be counted. If omitted,
212
+ equivalent to `COUNT(*)` (the number of rows).
213
+ """
214
+ return InstrumentedExpression(f"COUNT({_render(field)})")
215
+
216
+
217
+ def count_distinct(
218
+ field: ExpressionType, precision: ExpressionType
219
+ ) -> InstrumentedExpression:
220
+ """Returns the approximate number of distinct values.
221
+
222
+ :param field: Column or literal for which to count the number of distinct values.
223
+ :param precision: Precision threshold. The maximum supported value is 40000. Thresholds
224
+ above this number will have the same effect as a threshold of 40000.
225
+ The default value is 3000.
226
+ """
227
+ return InstrumentedExpression(
228
+ f"COUNT_DISTINCT({_render(field)}, {_render(precision)})"
229
+ )
230
+
231
+
232
+ def count_distinct_over_time(
233
+ field: ExpressionType, precision: ExpressionType
234
+ ) -> InstrumentedExpression:
235
+ """The count of distinct values over time for a field.
236
+
237
+ :param field:
238
+ :param precision: Precision threshold. The maximum supported value is 40000. Thresholds
239
+ above this number will have the same effect as a threshold of 40000. The
240
+ default value is 3000.
241
+ """
242
+ return InstrumentedExpression(
243
+ f"COUNT_DISTINCT_OVER_TIME({_render(field)}, {_render(precision)})"
244
+ )
245
+
246
+
247
+ def count_over_time(field: ExpressionType) -> InstrumentedExpression:
248
+ """The count over time value of a field.
249
+
250
+ :param field:
251
+ """
252
+ return InstrumentedExpression(f"COUNT_OVER_TIME({_render(field)})")
253
+
254
+
255
+ def date_diff(
256
+ unit: ExpressionType, start_timestamp: ExpressionType, end_timestamp: ExpressionType
257
+ ) -> InstrumentedExpression:
258
+ """Subtracts the `startTimestamp` from the `endTimestamp` and returns the
259
+ difference in multiples of `unit`. If `startTimestamp` is later than the
260
+ `endTimestamp`, negative values are returned.
261
+
262
+ :param unit: Time difference unit
263
+ :param start_timestamp: A string representing a start timestamp
264
+ :param end_timestamp: A string representing an end timestamp
265
+ """
266
+ return InstrumentedExpression(
267
+ f"DATE_DIFF({_render(unit)}, {start_timestamp}, {end_timestamp})"
268
+ )
269
+
270
+
271
+ def date_extract(
272
+ date_part: ExpressionType, date: ExpressionType
273
+ ) -> InstrumentedExpression:
274
+ """Extracts parts of a date, like year, month, day, hour.
275
+
276
+ :param date_part: Part of the date to extract. Can be:
277
+ `aligned_day_of_week_in_month`, `aligned_day_of_week_in_year`,
278
+ `aligned_week_of_month`, `aligned_week_of_year`, `ampm_of_day`,
279
+ `clock_hour_of_ampm`, `clock_hour_of_day`, `day_of_month`, `day_of_week`,
280
+ `day_of_year`, `epoch_day`, `era`, `hour_of_ampm`, `hour_of_day`,
281
+ `instant_seconds`, `micro_of_day`, `micro_of_second`, `milli_of_day`,
282
+ `milli_of_second`, `minute_of_day`, `minute_of_hour`, `month_of_year`,
283
+ `nano_of_day`, `nano_of_second`, `offset_seconds`, `proleptic_month`,
284
+ `second_of_day`, `second_of_minute`, `year`, or `year_of_era`. If `null`,
285
+ the function returns `null`.
286
+ :param date: Date expression. If `null`, the function returns `null`.
287
+ """
288
+ return InstrumentedExpression(f"DATE_EXTRACT({date_part}, {_render(date)})")
289
+
290
+
291
+ def date_format(
292
+ date: ExpressionType,
293
+ date_format: ExpressionType = None,
294
+ ) -> InstrumentedExpression:
295
+ """Returns a string representation of a date, in the provided format.
296
+
297
+ :param date_format: Date format (optional). If no format is specified, the
298
+ `yyyy-MM-dd'T'HH:mm:ss.SSSZ` format is used. If `null`, the
299
+ function returns `null`.
300
+ :param date: Date expression. If `null`, the function returns `null`.
301
+ """
302
+ if date_format is not None:
303
+ return InstrumentedExpression(
304
+ f"DATE_FORMAT({json.dumps(date_format)}, {_render(date)})"
305
+ )
306
+ else:
307
+ return InstrumentedExpression(f"DATE_FORMAT({_render(date)})")
308
+
309
+
310
+ def date_parse(
311
+ date_pattern: ExpressionType, date_string: ExpressionType
312
+ ) -> InstrumentedExpression:
313
+ """Returns a date by parsing the second argument using the format specified
314
+ in the first argument.
315
+
316
+ :param date_pattern: The date format. If `null`, the function returns `null`.
317
+ :param date_string: Date expression as a string. If `null` or an empty
318
+ string, the function returns `null`.
319
+ """
320
+ return InstrumentedExpression(f"DATE_PARSE({date_pattern}, {date_string})")
321
+
322
+
323
+ def date_trunc(
324
+ interval: ExpressionType, date: ExpressionType
325
+ ) -> InstrumentedExpression:
326
+ """Rounds down a date to the closest interval since epoch, which starts at `0001-01-01T00:00:00Z`.
327
+
328
+ :param interval: Interval; expressed using the timespan literal syntax.
329
+ :param date: Date expression
330
+ """
331
+ return InstrumentedExpression(f"DATE_TRUNC({_render(interval)}, {_render(date)})")
332
+
333
+
334
+ def e() -> InstrumentedExpression:
335
+ """Returns Euler’s number)."""
336
+ return InstrumentedExpression("E()")
337
+
338
+
339
+ def ends_with(str: ExpressionType, suffix: ExpressionType) -> InstrumentedExpression:
340
+ """Returns a boolean that indicates whether a keyword string ends with
341
+ another string.
342
+
343
+ :param str: String expression. If `null`, the function returns `null`.
344
+ :param suffix: String expression. If `null`, the function returns `null`.
345
+ """
346
+ return InstrumentedExpression(f"ENDS_WITH({_render(str)}, {_render(suffix)})")
347
+
348
+
349
+ def exp(number: ExpressionType) -> InstrumentedExpression:
350
+ """Returns the value of e raised to the power of the given number.
351
+
352
+ :param number: Numeric expression. If `null`, the function returns `null`.
353
+ """
354
+ return InstrumentedExpression(f"EXP({_render(number)})")
355
+
356
+
357
+ def first_over_time(field: ExpressionType) -> InstrumentedExpression:
358
+ """The earliest value of a field, where recency determined by the
359
+ `@timestamp` field.
360
+
361
+ :param field:
362
+ """
363
+ return InstrumentedExpression(f"FIRST_OVER_TIME({_render(field)})")
364
+
365
+
366
+ def floor(number: ExpressionType) -> InstrumentedExpression:
367
+ """Round a number down to the nearest integer.
368
+
369
+ :param number: Numeric expression. If `null`, the function returns `null`.
370
+ """
371
+ return InstrumentedExpression(f"FLOOR({_render(number)})")
372
+
373
+
374
+ def from_base64(string: ExpressionType) -> InstrumentedExpression:
375
+ """Decode a base64 string.
376
+
377
+ :param string: A base64 string.
378
+ """
379
+ return InstrumentedExpression(f"FROM_BASE64({_render(string)})")
380
+
381
+
382
+ def greatest(first: ExpressionType, rest: ExpressionType) -> InstrumentedExpression:
383
+ """Returns the maximum value from multiple columns. This is similar to
384
+ `MV_MAX` except it is intended to run on multiple columns at once.
385
+
386
+ :param first: First of the columns to evaluate.
387
+ :param rest: The rest of the columns to evaluate.
388
+ """
389
+ return InstrumentedExpression(f"GREATEST({_render(first)}, {_render(rest)})")
390
+
391
+
392
+ def hash(algorithm: ExpressionType, input: ExpressionType) -> InstrumentedExpression:
393
+ """Computes the hash of the input using various algorithms such as MD5,
394
+ SHA, SHA-224, SHA-256, SHA-384, SHA-512.
395
+
396
+ :param algorithm: Hash algorithm to use.
397
+ :param input: Input to hash.
398
+ """
399
+ return InstrumentedExpression(f"HASH({_render(algorithm)}, {_render(input)})")
400
+
401
+
402
+ def hypot(number1: ExpressionType, number2: ExpressionType) -> InstrumentedExpression:
403
+ """Returns the hypotenuse of two numbers. The input can be any numeric
404
+ values, the return value is always a double. Hypotenuses of infinities are null.
405
+
406
+ :param number1: Numeric expression. If `null`, the function returns `null`.
407
+ :param number2: Numeric expression. If `null`, the function returns `null`.
408
+ """
409
+ return InstrumentedExpression(f"HYPOT({number1}, {number2})")
410
+
411
+
412
+ def ip_prefix(
413
+ ip: ExpressionType,
414
+ prefix_length_v4: ExpressionType,
415
+ prefix_length_v6: ExpressionType,
416
+ ) -> InstrumentedExpression:
417
+ """Truncates an IP to a given prefix length.
418
+
419
+ :param ip: IP address of type `ip` (both IPv4 and IPv6 are supported).
420
+ :param prefix_length_v4: Prefix length for IPv4 addresses.
421
+ :param prefix_length_v6: Prefix length for IPv6 addresses.
422
+ """
423
+ return InstrumentedExpression(
424
+ f"IP_PREFIX({_render(ip)}, {prefix_length_v4}, {prefix_length_v6})"
425
+ )
426
+
427
+
428
+ def knn(
429
+ field: ExpressionType, query: ExpressionType, options: ExpressionType = None
430
+ ) -> InstrumentedExpression:
431
+ """Finds the k nearest vectors to a query vector, as measured by a
432
+ similarity metric. knn function finds nearest vectors through approximate
433
+ search on indexed dense_vectors.
434
+
435
+ :param field: Field that the query will target.
436
+ :param query: Vector value to find top nearest neighbours for.
437
+ :param options: (Optional) kNN additional options as function named parameters.
438
+ """
439
+ if options is not None:
440
+ return InstrumentedExpression(
441
+ f"KNN({_render(field)}, {_render(query)}, {_render(options)})"
442
+ )
443
+ else:
444
+ return InstrumentedExpression(f"KNN({_render(field)}, {_render(query)})")
445
+
446
+
447
+ def kql(query: ExpressionType) -> InstrumentedExpression:
448
+ """Performs a KQL query. Returns true if the provided KQL query string
449
+ matches the row.
450
+
451
+ :param query: Query string in KQL query string format.
452
+ """
453
+ return InstrumentedExpression(f"KQL({_render(query)})")
454
+
455
+
456
+ def last_over_time(field: ExpressionType) -> InstrumentedExpression:
457
+ """The latest value of a field, where recency determined by the
458
+ `@timestamp` field.
459
+
460
+ :param field:
461
+ """
462
+ return InstrumentedExpression(f"LAST_OVER_TIME({_render(field)})")
463
+
464
+
465
+ def least(first: ExpressionType, rest: ExpressionType) -> InstrumentedExpression:
466
+ """Returns the minimum value from multiple columns. This is similar to
467
+ `MV_MIN` except it is intended to run on multiple columns at once.
468
+
469
+ :param first: First of the columns to evaluate.
470
+ :param rest: The rest of the columns to evaluate.
471
+ """
472
+ return InstrumentedExpression(f"LEAST({_render(first)}, {_render(rest)})")
473
+
474
+
475
+ def left(string: ExpressionType, length: ExpressionType) -> InstrumentedExpression:
476
+ """Returns the substring that extracts *length* chars from *string*
477
+ starting from the left.
478
+
479
+ :param string: The string from which to return a substring.
480
+ :param length: The number of characters to return.
481
+ """
482
+ return InstrumentedExpression(f"LEFT({_render(string)}, {_render(length)})")
483
+
484
+
485
+ def length(string: ExpressionType) -> InstrumentedExpression:
486
+ """Returns the character length of a string.
487
+
488
+ :param string: String expression. If `null`, the function returns `null`.
489
+ """
490
+ return InstrumentedExpression(f"LENGTH({_render(string)})")
491
+
492
+
493
+ def locate(
494
+ string: ExpressionType, substring: ExpressionType, start: ExpressionType
495
+ ) -> InstrumentedExpression:
496
+ """Returns an integer that indicates the position of a keyword substring
497
+ within another string. Returns `0` if the substring cannot be found. Note
498
+ that string positions start from `1`.
499
+
500
+ :param string: An input string
501
+ :param substring: A substring to locate in the input string
502
+ :param start: The start index
503
+ """
504
+ return InstrumentedExpression(
505
+ f"LOCATE({_render(string)}, {_render(substring)}, {_render(start)})"
506
+ )
507
+
508
+
509
+ def log(base: ExpressionType, number: ExpressionType) -> InstrumentedExpression:
510
+ """Returns the logarithm of a value to a base. The input can be any numeric
511
+ value, the return value is always a double. Logs of zero, negative
512
+ numbers, and base of one return `null` as well as a warning.
513
+
514
+ :param base: Base of logarithm. If `null`, the function returns `null`. If
515
+ not provided, this function returns the natural logarithm (base e) of a value.
516
+ :param number: Numeric expression. If `null`, the function returns `null`.
517
+ """
518
+ return InstrumentedExpression(f"LOG({_render(base)}, {_render(number)})")
519
+
520
+
521
+ def log10(number: ExpressionType) -> InstrumentedExpression:
522
+ """Returns the logarithm of a value to base 10. The input can be any
523
+ numeric value, the return value is always a double. Logs of 0 and negative
524
+ numbers return `null` as well as a warning.
525
+
526
+ :param number: Numeric expression. If `null`, the function returns `null`.
527
+ """
528
+ return InstrumentedExpression(f"LOG10({_render(number)})")
529
+
530
+
531
+ def ltrim(string: ExpressionType) -> InstrumentedExpression:
532
+ """Removes leading whitespaces from a string.
533
+
534
+ :param string: String expression. If `null`, the function returns `null`.
535
+ """
536
+ return InstrumentedExpression(f"LTRIM({_render(string)})")
537
+
538
+
539
+ def match(
540
+ field: ExpressionType, query: ExpressionType, options: ExpressionType = None
541
+ ) -> InstrumentedExpression:
542
+ """Use `MATCH` to perform a match query on the specified field. Using
543
+ `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.
544
+
545
+ :param field: Field that the query will target.
546
+ :param query: Value to find in the provided field.
547
+ :param options: (Optional) Match additional options as function named parameters.
548
+ """
549
+ if options is not None:
550
+ return InstrumentedExpression(
551
+ f"MATCH({_render(field)}, {_render(query)}, {_render(options)})"
552
+ )
553
+ else:
554
+ return InstrumentedExpression(f"MATCH({_render(field)}, {_render(query)})")
555
+
556
+
557
+ def match_phrase(
558
+ field: ExpressionType, query: ExpressionType, options: ExpressionType = None
559
+ ) -> InstrumentedExpression:
560
+ """Use `MATCH_PHRASE` to perform a `match_phrase` on the specified field.
561
+ Using `MATCH_PHRASE` is equivalent to using the `match_phrase` query in the
562
+ Elasticsearch Query DSL.
563
+
564
+ :param field: Field that the query will target.
565
+ :param query: Value to find in the provided field.
566
+ :param options: (Optional) MatchPhrase additional options as function named parameters.
567
+ """
568
+ if options is not None:
569
+ return InstrumentedExpression(
570
+ f"MATCH_PHRASE({_render(field)}, {_render(query)}, {_render(options)})"
571
+ )
572
+ else:
573
+ return InstrumentedExpression(
574
+ f"MATCH_PHRASE({_render(field)}, {_render(query)})"
575
+ )
576
+
577
+
578
+ def max(field: ExpressionType) -> InstrumentedExpression:
579
+ """The maximum value of a field.
580
+
581
+ :param field:
582
+ """
583
+ return InstrumentedExpression(f"MAX({_render(field)})")
584
+
585
+
586
+ def max_over_time(field: ExpressionType) -> InstrumentedExpression:
587
+ """The maximum over time value of a field.
588
+
589
+ :param field:
590
+ """
591
+ return InstrumentedExpression(f"MAX_OVER_TIME({_render(field)})")
592
+
593
+
594
+ def md5(input: ExpressionType) -> InstrumentedExpression:
595
+ """Computes the MD5 hash of the input.
596
+
597
+ :param input: Input to hash.
598
+ """
599
+ return InstrumentedExpression(f"MD5({_render(input)})")
600
+
601
+
602
+ def median(number: ExpressionType) -> InstrumentedExpression:
603
+ """The value that is greater than half of all values and less than half of
604
+ all values, also known as the 50% `PERCENTILE`.
605
+
606
+ :param number: Expression that outputs values to calculate the median of.
607
+ """
608
+ return InstrumentedExpression(f"MEDIAN({_render(number)})")
609
+
610
+
611
+ def median_absolute_deviation(number: ExpressionType) -> InstrumentedExpression:
612
+ """Returns the median absolute deviation, a measure of variability. It is a
613
+ robust statistic, meaning that it is useful for describing data that may
614
+ have outliers, or may not be normally distributed. For such data it can be
615
+ more descriptive than standard deviation. It is calculated as the median
616
+ of each data point’s deviation from the median of the entire sample. That
617
+ is, for a random variable `X`, the median absolute deviation is
618
+ `median(|median(X) - X|)`.
619
+
620
+ :param number:
621
+ """
622
+ return InstrumentedExpression(f"MEDIAN_ABSOLUTE_DEVIATION({_render(number)})")
623
+
624
+
625
+ def min(field: ExpressionType) -> InstrumentedExpression:
626
+ """The minimum value of a field.
627
+
628
+ :param field:
629
+ """
630
+ return InstrumentedExpression(f"MIN({_render(field)})")
631
+
632
+
633
+ def min_over_time(field: ExpressionType) -> InstrumentedExpression:
634
+ """The minimum over time value of a field.
635
+
636
+ :param field:
637
+ """
638
+ return InstrumentedExpression(f"MIN_OVER_TIME({_render(field)})")
639
+
640
+
641
+ def multi_match(
642
+ query: ExpressionType, fields: ExpressionType, options: ExpressionType = None
643
+ ) -> InstrumentedExpression:
644
+ """Use `MULTI_MATCH` to perform a multi-match query on the specified field.
645
+ The multi_match query builds on the match query to allow multi-field queries.
646
+
647
+ :param query: Value to find in the provided fields.
648
+ :param fields: Fields to use for matching
649
+ :param options: (Optional) Additional options for MultiMatch, passed as function
650
+ named parameters
651
+ """
652
+ if options is not None:
653
+ return InstrumentedExpression(
654
+ f"MULTI_MATCH({_render(query)}, {_render(fields)}, {_render(options)})"
655
+ )
656
+ else:
657
+ return InstrumentedExpression(
658
+ f"MULTI_MATCH({_render(query)}, {_render(fields)})"
659
+ )
660
+
661
+
662
+ def mv_append(field1: ExpressionType, field2: ExpressionType) -> InstrumentedExpression:
663
+ """Concatenates values of two multi-value fields.
664
+
665
+ :param field1:
666
+ :param field2:
667
+ """
668
+ return InstrumentedExpression(f"MV_APPEND({field1}, {field2})")
669
+
670
+
671
+ def mv_avg(number: ExpressionType) -> InstrumentedExpression:
672
+ """Converts a multivalued field into a single valued field containing the
673
+ average of all of the values.
674
+
675
+ :param number: Multivalue expression.
676
+ """
677
+ return InstrumentedExpression(f"MV_AVG({_render(number)})")
678
+
679
+
680
+ def mv_concat(string: ExpressionType, delim: ExpressionType) -> InstrumentedExpression:
681
+ """Converts a multivalued string expression into a single valued column
682
+ containing the concatenation of all values separated by a delimiter.
683
+
684
+ :param string: Multivalue expression.
685
+ :param delim: Delimiter.
686
+ """
687
+ return InstrumentedExpression(f"MV_CONCAT({_render(string)}, {_render(delim)})")
688
+
689
+
690
+ def mv_count(field: ExpressionType) -> InstrumentedExpression:
691
+ """Converts a multivalued expression into a single valued column containing
692
+ a count of the number of values.
693
+
694
+ :param field: Multivalue expression.
695
+ """
696
+ return InstrumentedExpression(f"MV_COUNT({_render(field)})")
697
+
698
+
699
+ def mv_dedupe(field: ExpressionType) -> InstrumentedExpression:
700
+ """Remove duplicate values from a multivalued field.
701
+
702
+ :param field: Multivalue expression.
703
+ """
704
+ return InstrumentedExpression(f"MV_DEDUPE({_render(field)})")
705
+
706
+
707
+ def mv_first(field: ExpressionType) -> InstrumentedExpression:
708
+ """Converts a multivalued expression into a single valued column containing
709
+ the first value. This is most useful when reading from a function that
710
+ emits multivalued columns in a known order like `SPLIT`.
711
+
712
+ :param field: Multivalue expression.
713
+ """
714
+ return InstrumentedExpression(f"MV_FIRST({_render(field)})")
715
+
716
+
717
+ def mv_last(field: ExpressionType) -> InstrumentedExpression:
718
+ """Converts a multivalue expression into a single valued column containing
719
+ the last value. This is most useful when reading from a function that emits
720
+ multivalued columns in a known order like `SPLIT`.
721
+
722
+ :param field: Multivalue expression.
723
+ """
724
+ return InstrumentedExpression(f"MV_LAST({_render(field)})")
725
+
726
+
727
+ def mv_max(field: ExpressionType) -> InstrumentedExpression:
728
+ """Converts a multivalued expression into a single valued column containing
729
+ the maximum value.
730
+
731
+ :param field: Multivalue expression.
732
+ """
733
+ return InstrumentedExpression(f"MV_MAX({_render(field)})")
734
+
735
+
736
+ def mv_median(number: ExpressionType) -> InstrumentedExpression:
737
+ """Converts a multivalued field into a single valued field containing the
738
+ median value.
739
+
740
+ :param number: Multivalue expression.
741
+ """
742
+ return InstrumentedExpression(f"MV_MEDIAN({_render(number)})")
743
+
744
+
745
+ def mv_median_absolute_deviation(number: ExpressionType) -> InstrumentedExpression:
746
+ """Converts a multivalued field into a single valued field containing the
747
+ median absolute deviation. It is calculated as the median of each data
748
+ point’s deviation from the median of the entire sample. That is, for a
749
+ random variable `X`, the median absolute deviation is `median(|median(X) - X|)`.
750
+
751
+ :param number: Multivalue expression.
752
+ """
753
+ return InstrumentedExpression(f"MV_MEDIAN_ABSOLUTE_DEVIATION({_render(number)})")
754
+
755
+
756
+ def mv_min(field: ExpressionType) -> InstrumentedExpression:
757
+ """Converts a multivalued expression into a single valued column containing
758
+ the minimum value.
759
+
760
+ :param field: Multivalue expression.
761
+ """
762
+ return InstrumentedExpression(f"MV_MIN({_render(field)})")
763
+
764
+
765
+ def mv_percentile(
766
+ number: ExpressionType, percentile: ExpressionType
767
+ ) -> InstrumentedExpression:
768
+ """Converts a multivalued field into a single valued field containing the
769
+ value at which a certain percentage of observed values occur.
770
+
771
+ :param number: Multivalue expression.
772
+ :param percentile: The percentile to calculate. Must be a number between 0
773
+ and 100. Numbers out of range will return a null instead.
774
+ """
775
+ return InstrumentedExpression(
776
+ f"MV_PERCENTILE({_render(number)}, {_render(percentile)})"
777
+ )
778
+
779
+
780
+ def mv_pseries_weighted_sum(
781
+ number: ExpressionType, p: ExpressionType
782
+ ) -> InstrumentedExpression:
783
+ """Converts a multivalued expression into a single-valued column by
784
+ multiplying every element on the input list by its corresponding term in
785
+ P-Series and computing the sum.
786
+
787
+ :param number: Multivalue expression.
788
+ :param p: It is a constant number that represents the *p* parameter in the
789
+ P-Series. It impacts every element’s contribution to the weighted sum.
790
+ """
791
+ return InstrumentedExpression(
792
+ f"MV_PSERIES_WEIGHTED_SUM({_render(number)}, {_render(p)})"
793
+ )
794
+
795
+
796
+ def mv_slice(
797
+ field: ExpressionType, start: ExpressionType, end: ExpressionType = None
798
+ ) -> InstrumentedExpression:
799
+ """Returns a subset of the multivalued field using the start and end index
800
+ values. This is most useful when reading from a function that emits
801
+ multivalued columns in a known order like `SPLIT` or `MV_SORT`.
802
+
803
+ :param field: Multivalue expression. If `null`, the function returns `null`.
804
+ :param start: Start position. If `null`, the function returns `null`. The
805
+ start argument can be negative. An index of -1 is used to specify
806
+ the last value in the list.
807
+ :param end: End position(included). Optional; if omitted, the position at
808
+ `start` is returned. The end argument can be negative. An index of -1
809
+ is used to specify the last value in the list.
810
+ """
811
+ if end is not None:
812
+ return InstrumentedExpression(
813
+ f"MV_SLICE({_render(field)}, {_render(start)}, {_render(end)})"
814
+ )
815
+ else:
816
+ return InstrumentedExpression(f"MV_SLICE({_render(field)}, {_render(start)})")
817
+
818
+
819
+ def mv_sort(field: ExpressionType, order: ExpressionType) -> InstrumentedExpression:
820
+ """Sorts a multivalued field in lexicographical order.
821
+
822
+ :param field: Multivalue expression. If `null`, the function returns `null`.
823
+ :param order: Sort order. The valid options are ASC and DESC, the default is ASC.
824
+ """
825
+ return InstrumentedExpression(f"MV_SORT({_render(field)}, {_render(order)})")
826
+
827
+
828
+ def mv_sum(number: ExpressionType) -> InstrumentedExpression:
829
+ """Converts a multivalued field into a single valued field containing the
830
+ sum of all of the values.
831
+
832
+ :param number: Multivalue expression.
833
+ """
834
+ return InstrumentedExpression(f"MV_SUM({_render(number)})")
835
+
836
+
837
+ def mv_zip(
838
+ string1: ExpressionType, string2: ExpressionType, delim: ExpressionType = None
839
+ ) -> InstrumentedExpression:
840
+ """Combines the values from two multivalued fields with a delimiter that
841
+ joins them together.
842
+
843
+ :param string1: Multivalue expression.
844
+ :param string2: Multivalue expression.
845
+ :param delim: Delimiter. Optional; if omitted, `,` is used as a default delimiter.
846
+ """
847
+ if delim is not None:
848
+ return InstrumentedExpression(f"MV_ZIP({string1}, {string2}, {_render(delim)})")
849
+ else:
850
+ return InstrumentedExpression(f"MV_ZIP({string1}, {string2})")
851
+
852
+
853
+ def now() -> InstrumentedExpression:
854
+ """Returns current date and time."""
855
+ return InstrumentedExpression("NOW()")
856
+
857
+
858
+ def percentile(
859
+ number: ExpressionType, percentile: ExpressionType
860
+ ) -> InstrumentedExpression:
861
+ """Returns the value at which a certain percentage of observed values
862
+ occur. For example, the 95th percentile is the value which is greater than
863
+ 95% of the observed values and the 50th percentile is the `MEDIAN`.
864
+
865
+ :param number:
866
+ :param percentile:
867
+ """
868
+ return InstrumentedExpression(
869
+ f"PERCENTILE({_render(number)}, {_render(percentile)})"
870
+ )
871
+
872
+
873
+ def pi() -> InstrumentedExpression:
874
+ """Returns Pi, the ratio of a circle’s circumference to its diameter."""
875
+ return InstrumentedExpression("PI()")
876
+
877
+
878
+ def pow(base: ExpressionType, exponent: ExpressionType) -> InstrumentedExpression:
879
+ """Returns the value of `base` raised to the power of `exponent`.
880
+
881
+ :param base: Numeric expression for the base. If `null`, the function returns `null`.
882
+ :param exponent: Numeric expression for the exponent. If `null`, the function returns `null`.
883
+ """
884
+ return InstrumentedExpression(f"POW({_render(base)}, {_render(exponent)})")
885
+
886
+
887
+ def qstr(
888
+ query: ExpressionType, options: ExpressionType = None
889
+ ) -> InstrumentedExpression:
890
+ """Performs a query string query. Returns true if the provided query string
891
+ matches the row.
892
+
893
+ :param query: Query string in Lucene query string format.
894
+ :param options: (Optional) Additional options for Query String as function named
895
+ parameters.
896
+ """
897
+ if options is not None:
898
+ return InstrumentedExpression(f"QSTR({_render(query)}, {_render(options)})")
899
+ else:
900
+ return InstrumentedExpression(f"QSTR({_render(query)})")
901
+
902
+
903
+ def rate(field: ExpressionType) -> InstrumentedExpression:
904
+ """The rate of a counter field.
905
+
906
+ :param field:
907
+ """
908
+ return InstrumentedExpression(f"RATE({_render(field)})")
909
+
910
+
911
+ def repeat(string: ExpressionType, number: ExpressionType) -> InstrumentedExpression:
912
+ """Returns a string constructed by concatenating `string` with itself the
913
+ specified `number` of times.
914
+
915
+ :param string: String expression.
916
+ :param number: Number times to repeat.
917
+ """
918
+ return InstrumentedExpression(f"REPEAT({_render(string)}, {_render(number)})")
919
+
920
+
921
+ def replace(
922
+ string: ExpressionType, regex: ExpressionType, new_string: ExpressionType
923
+ ) -> InstrumentedExpression:
924
+ """The function substitutes in the string `str` any match of the regular
925
+ expression `regex` with the replacement string `newStr`.
926
+
927
+ :param string: String expression.
928
+ :param regex: Regular expression.
929
+ :param new_string: Replacement string.
930
+ """
931
+ return InstrumentedExpression(
932
+ f"REPLACE({_render(string)}, {_render(regex)}, {new_string})"
933
+ )
934
+
935
+
936
+ def reverse(str: ExpressionType) -> InstrumentedExpression:
937
+ """Returns a new string representing the input string in reverse order.
938
+
939
+ :param str: String expression. If `null`, the function returns `null`.
940
+ """
941
+ return InstrumentedExpression(f"REVERSE({_render(str)})")
942
+
943
+
944
+ def right(string: ExpressionType, length: ExpressionType) -> InstrumentedExpression:
945
+ """Return the substring that extracts *length* chars from *str* starting
946
+ from the right.
947
+
948
+ :param string: The string from which to returns a substring.
949
+ :param length: The number of characters to return.
950
+ """
951
+ return InstrumentedExpression(f"RIGHT({_render(string)}, {_render(length)})")
952
+
953
+
954
+ def round(
955
+ number: ExpressionType, decimals: ExpressionType = None
956
+ ) -> InstrumentedExpression:
957
+ """Rounds a number to the specified number of decimal places. Defaults to
958
+ 0, which returns the nearest integer. If the precision is a negative
959
+ number, rounds to the number of digits left of the decimal point.
960
+
961
+ :param number: The numeric value to round. If `null`, the function returns `null`.
962
+ :param decimals: The number of decimal places to round to. Defaults to 0. If
963
+ `null`, the function returns `null`.
964
+ """
965
+ if decimals is not None:
966
+ return InstrumentedExpression(f"ROUND({_render(number)}, {_render(decimals)})")
967
+ else:
968
+ return InstrumentedExpression(f"ROUND({_render(number)})")
969
+
970
+
971
+ def round_to(field: ExpressionType, points: ExpressionType) -> InstrumentedExpression:
972
+ """Rounds down to one of a list of fixed points.
973
+
974
+ :param field: The numeric value to round. If `null`, the function returns `null`.
975
+ :param points: Remaining rounding points. Must be constants.
976
+ """
977
+ return InstrumentedExpression(f"ROUND_TO({_render(field)}, {_render(points)})")
978
+
979
+
980
+ def rtrim(string: ExpressionType) -> InstrumentedExpression:
981
+ """Removes trailing whitespaces from a string.
982
+
983
+ :param string: String expression. If `null`, the function returns `null`.
984
+ """
985
+ return InstrumentedExpression(f"RTRIM({_render(string)})")
986
+
987
+
988
+ def sample(field: ExpressionType, limit: ExpressionType) -> InstrumentedExpression:
989
+ """Collects sample values for a field.
990
+
991
+ :param field: The field to collect sample values for.
992
+ :param limit: The maximum number of values to collect.
993
+ """
994
+ return InstrumentedExpression(f"SAMPLE({_render(field)}, {_render(limit)})")
995
+
996
+
997
+ def scalb(d: ExpressionType, scale_factor: ExpressionType) -> InstrumentedExpression:
998
+ """Returns the result of `d * 2 ^ scaleFactor`, Similar to Java's `scalb`
999
+ function. Result is rounded as if performed by a single correctly rounded
1000
+ floating-point multiply to a member of the double value set.
1001
+
1002
+ :param d: Numeric expression for the multiplier. If `null`, the function
1003
+ returns `null`.
1004
+ :param scale_factor: Numeric expression for the scale factor. If `null`, the
1005
+ function returns `null`.
1006
+ """
1007
+ return InstrumentedExpression(f"SCALB({_render(d)}, {scale_factor})")
1008
+
1009
+
1010
+ def sha1(input: ExpressionType) -> InstrumentedExpression:
1011
+ """Computes the SHA1 hash of the input.
1012
+
1013
+ :param input: Input to hash.
1014
+ """
1015
+ return InstrumentedExpression(f"SHA1({_render(input)})")
1016
+
1017
+
1018
+ def sha256(input: ExpressionType) -> InstrumentedExpression:
1019
+ """Computes the SHA256 hash of the input.
1020
+
1021
+ :param input: Input to hash.
1022
+ """
1023
+ return InstrumentedExpression(f"SHA256({_render(input)})")
1024
+
1025
+
1026
+ def signum(number: ExpressionType) -> InstrumentedExpression:
1027
+ """Returns the sign of the given number. It returns `-1` for negative
1028
+ numbers, `0` for `0` and `1` for positive numbers.
1029
+
1030
+ :param number: Numeric expression. If `null`, the function returns `null`.
1031
+ """
1032
+ return InstrumentedExpression(f"SIGNUM({_render(number)})")
1033
+
1034
+
1035
+ def sin(angle: ExpressionType) -> InstrumentedExpression:
1036
+ """Returns the sine of an angle.
1037
+
1038
+ :param angle: An angle, in radians. If `null`, the function returns `null`.
1039
+ """
1040
+ return InstrumentedExpression(f"SIN({_render(angle)})")
1041
+
1042
+
1043
+ def sinh(number: ExpressionType) -> InstrumentedExpression:
1044
+ """Returns the hyperbolic sine of a number.
1045
+
1046
+ :param number: Numeric expression. If `null`, the function returns `null`.
1047
+ """
1048
+ return InstrumentedExpression(f"SINH({_render(number)})")
1049
+
1050
+
1051
+ def space(number: ExpressionType) -> InstrumentedExpression:
1052
+ """Returns a string made of `number` spaces.
1053
+
1054
+ :param number: Number of spaces in result.
1055
+ """
1056
+ return InstrumentedExpression(f"SPACE({_render(number)})")
1057
+
1058
+
1059
+ def split(string: ExpressionType, delim: ExpressionType) -> InstrumentedExpression:
1060
+ """Split a single valued string into multiple strings.
1061
+
1062
+ :param string: String expression. If `null`, the function returns `null`.
1063
+ :param delim: Delimiter. Only single byte delimiters are currently supported.
1064
+ """
1065
+ return InstrumentedExpression(f"SPLIT({_render(string)}, {_render(delim)})")
1066
+
1067
+
1068
+ def sqrt(number: ExpressionType) -> InstrumentedExpression:
1069
+ """Returns the square root of a number. The input can be any numeric value,
1070
+ the return value is always a double. Square roots of negative numbers and
1071
+ infinities are null.
1072
+
1073
+ :param number: Numeric expression. If `null`, the function returns `null`.
1074
+ """
1075
+ return InstrumentedExpression(f"SQRT({_render(number)})")
1076
+
1077
+
1078
+ def starts_with(str: ExpressionType, prefix: ExpressionType) -> InstrumentedExpression:
1079
+ """Returns a boolean that indicates whether a keyword string starts with
1080
+ another string.
1081
+
1082
+ :param str: String expression. If `null`, the function returns `null`.
1083
+ :param prefix: String expression. If `null`, the function returns `null`.
1084
+ """
1085
+ return InstrumentedExpression(f"STARTS_WITH({_render(str)}, {_render(prefix)})")
1086
+
1087
+
1088
+ def std_dev(number: ExpressionType) -> InstrumentedExpression:
1089
+ """The population standard deviation of a numeric field.
1090
+
1091
+ :param number:
1092
+ """
1093
+ return InstrumentedExpression(f"STD_DEV({_render(number)})")
1094
+
1095
+
1096
+ def st_centroid_agg(field: ExpressionType) -> InstrumentedExpression:
1097
+ """Calculate the spatial centroid over a field with spatial point geometry type.
1098
+
1099
+ :param field:
1100
+ """
1101
+ return InstrumentedExpression(f"ST_CENTROID_AGG({_render(field)})")
1102
+
1103
+
1104
+ def st_contains(
1105
+ geom_a: ExpressionType, geom_b: ExpressionType
1106
+ ) -> InstrumentedExpression:
1107
+ """Returns whether the first geometry contains the second geometry. This is
1108
+ the inverse of the ST_WITHIN function.
1109
+
1110
+ :param geom_a: Expression of type `geo_point`, `cartesian_point`,
1111
+ `geo_shape` or `cartesian_shape`. If `null`, the function returns
1112
+ `null`.
1113
+ :param geom_b: Expression of type `geo_point`, `cartesian_point`, `geo_shape`
1114
+ or `cartesian_shape`. If `null`, the function returns `null`. The
1115
+ second parameter must also have the same coordinate system as the
1116
+ first. This means it is not possible to combine `geo_*` and
1117
+ `cartesian_*` parameters.
1118
+ """
1119
+ return InstrumentedExpression(f"ST_CONTAINS({geom_a}, {geom_b})")
1120
+
1121
+
1122
+ def st_disjoint(
1123
+ geom_a: ExpressionType, geom_b: ExpressionType
1124
+ ) -> InstrumentedExpression:
1125
+ """Returns whether the two geometries or geometry columns are disjoint.
1126
+ This is the inverse of the ST_INTERSECTS function. In mathematical terms:
1127
+ ST_Disjoint(A, B) ⇔ A ⋂ B = ∅
1128
+
1129
+ :param geom_a: Expression of type `geo_point`, `cartesian_point`,
1130
+ `geo_shape` or `cartesian_shape`. If `null`, the function returns
1131
+ `null`.
1132
+ :param geom_b: Expression of type `geo_point`, `cartesian_point`, `geo_shape`
1133
+ or `cartesian_shape`. If `null`, the function returns `null`. The
1134
+ second parameter must also have the same coordinate system as the
1135
+ first. This means it is not possible to combine `geo_*` and
1136
+ `cartesian_*` parameters.
1137
+ """
1138
+ return InstrumentedExpression(f"ST_DISJOINT({geom_a}, {geom_b})")
1139
+
1140
+
1141
+ def st_distance(
1142
+ geom_a: ExpressionType, geom_b: ExpressionType
1143
+ ) -> InstrumentedExpression:
1144
+ """Computes the distance between two points. For cartesian geometries, this
1145
+ is the pythagorean distance in the same units as the original coordinates.
1146
+ For geographic geometries, this is the circular distance along the great
1147
+ circle in meters.
1148
+
1149
+ :param geom_a: Expression of type `geo_point` or `cartesian_point`. If
1150
+ `null`, the function returns `null`.
1151
+ :param geom_b: Expression of type `geo_point` or `cartesian_point`. If
1152
+ `null`, the function returns `null`. The second parameter must
1153
+ also have the same coordinate system as the first. This means it
1154
+ is not possible to combine `geo_point` and `cartesian_point` parameters.
1155
+ """
1156
+ return InstrumentedExpression(f"ST_DISTANCE({geom_a}, {geom_b})")
1157
+
1158
+
1159
+ def st_envelope(geometry: ExpressionType) -> InstrumentedExpression:
1160
+ """Determines the minimum bounding box of the supplied geometry.
1161
+
1162
+ :param geometry: Expression of type `geo_point`, `geo_shape`,
1163
+ `cartesian_point` or `cartesian_shape`. If `null`, the function
1164
+ returns `null`.
1165
+ """
1166
+ return InstrumentedExpression(f"ST_ENVELOPE({_render(geometry)})")
1167
+
1168
+
1169
+ def st_extent_agg(field: ExpressionType) -> InstrumentedExpression:
1170
+ """Calculate the spatial extent over a field with geometry type. Returns a
1171
+ bounding box for all values of the field.
1172
+
1173
+ :param field:
1174
+ """
1175
+ return InstrumentedExpression(f"ST_EXTENT_AGG({_render(field)})")
1176
+
1177
+
1178
+ def st_geohash(
1179
+ geometry: ExpressionType, precision: ExpressionType, bounds: ExpressionType = None
1180
+ ) -> InstrumentedExpression:
1181
+ """Calculates the `geohash` of the supplied geo_point at the specified
1182
+ precision. The result is long encoded. Use ST_GEOHASH_TO_STRING to convert
1183
+ the result to a string. These functions are related to the `geo_grid`
1184
+ query and the `geohash_grid` aggregation.
1185
+
1186
+ :param geometry: Expression of type `geo_point`. If `null`, the function
1187
+ returns `null`.
1188
+ :param precision: Expression of type `integer`. If `null`, the function
1189
+ returns `null`. Valid values are between 1 and 12.
1190
+ :param bounds: Optional bounds to filter the grid tiles, a `geo_shape` of
1191
+ type `BBOX`. Use `ST_ENVELOPE` if the `geo_shape` is of any
1192
+ other type.
1193
+ """
1194
+ if bounds is not None:
1195
+ return InstrumentedExpression(
1196
+ f"ST_GEOHASH({_render(geometry)}, {_render(precision)}, {_render(bounds)})"
1197
+ )
1198
+ else:
1199
+ return InstrumentedExpression(
1200
+ f"ST_GEOHASH({_render(geometry)}, {_render(precision)})"
1201
+ )
1202
+
1203
+
1204
+ def st_geohash_to_long(grid_id: ExpressionType) -> InstrumentedExpression:
1205
+ """Converts an input value representing a geohash grid-ID in string format
1206
+ into a long.
1207
+
1208
+ :param grid_id: Input geohash grid-id. The input can be a single- or
1209
+ multi-valued column or an expression.
1210
+ """
1211
+ return InstrumentedExpression(f"ST_GEOHASH_TO_LONG({grid_id})")
1212
+
1213
+
1214
+ def st_geohash_to_string(grid_id: ExpressionType) -> InstrumentedExpression:
1215
+ """Converts an input value representing a geohash grid-ID in long format
1216
+ into a string.
1217
+
1218
+ :param grid_id: Input geohash grid-id. The input can be a single- or
1219
+ multi-valued column or an expression.
1220
+ """
1221
+ return InstrumentedExpression(f"ST_GEOHASH_TO_STRING({grid_id})")
1222
+
1223
+
1224
+ def st_geohex(
1225
+ geometry: ExpressionType, precision: ExpressionType, bounds: ExpressionType = None
1226
+ ) -> InstrumentedExpression:
1227
+ """Calculates the `geohex`, the H3 cell-id, of the supplied geo_point at
1228
+ the specified precision. The result is long encoded. Use
1229
+ ST_GEOHEX_TO_STRING to convert the result to a string. These functions are
1230
+ related to the `geo_grid` query and the `geohex_grid` aggregation.
1231
+
1232
+ :param geometry: Expression of type `geo_point`. If `null`, the function
1233
+ returns `null`.
1234
+ :param precision: Expression of type `integer`. If `null`, the function
1235
+ returns `null`. Valid values are between 0 and 15.
1236
+ :param bounds: Optional bounds to filter the grid tiles, a `geo_shape` of
1237
+ type `BBOX`. Use `ST_ENVELOPE` if the `geo_shape`
1238
+ is of any other type.
1239
+ """
1240
+ if bounds is not None:
1241
+ return InstrumentedExpression(
1242
+ f"ST_GEOHEX({_render(geometry)}, {_render(precision)}, {_render(bounds)})"
1243
+ )
1244
+ else:
1245
+ return InstrumentedExpression(
1246
+ f"ST_GEOHEX({_render(geometry)}, {_render(precision)})"
1247
+ )
1248
+
1249
+
1250
+ def st_geohex_to_long(grid_id: ExpressionType) -> InstrumentedExpression:
1251
+ """Converts an input value representing a geohex grid-ID in string format
1252
+ into a long.
1253
+
1254
+ :param grid_id: Input geohex grid-id. The input can be a single- or
1255
+ multi-valued column or an expression.
1256
+ """
1257
+ return InstrumentedExpression(f"ST_GEOHEX_TO_LONG({grid_id})")
1258
+
1259
+
1260
+ def st_geohex_to_string(grid_id: ExpressionType) -> InstrumentedExpression:
1261
+ """Converts an input value representing a Geohex grid-ID in long format
1262
+ into a string.
1263
+
1264
+ :param grid_id: Input Geohex grid-id. The input can be a single- or
1265
+ multi-valued column or an expression.
1266
+ """
1267
+ return InstrumentedExpression(f"ST_GEOHEX_TO_STRING({grid_id})")
1268
+
1269
+
1270
+ def st_geotile(
1271
+ geometry: ExpressionType, precision: ExpressionType, bounds: ExpressionType = None
1272
+ ) -> InstrumentedExpression:
1273
+ """Calculates the `geotile` of the supplied geo_point at the specified
1274
+ precision. The result is long encoded. Use ST_GEOTILE_TO_STRING to convert
1275
+ the result to a string. These functions are related to the `geo_grid`
1276
+ query and the `geotile_grid` aggregation.
1277
+
1278
+ :param geometry: Expression of type `geo_point`. If `null`, the function
1279
+ returns `null`.
1280
+ :param precision: Expression of type `integer`. If `null`, the function
1281
+ returns `null`. Valid values are between 0 and 29.
1282
+ :param bounds: Optional bounds to filter the grid tiles, a `geo_shape` of
1283
+ type `BBOX`. Use `ST_ENVELOPE` if the `geo_shape` is of any
1284
+ other type.
1285
+ """
1286
+ if bounds is not None:
1287
+ return InstrumentedExpression(
1288
+ f"ST_GEOTILE({_render(geometry)}, {_render(precision)}, {_render(bounds)})"
1289
+ )
1290
+ else:
1291
+ return InstrumentedExpression(
1292
+ f"ST_GEOTILE({_render(geometry)}, {_render(precision)})"
1293
+ )
1294
+
1295
+
1296
+ def st_geotile_to_long(grid_id: ExpressionType) -> InstrumentedExpression:
1297
+ """Converts an input value representing a geotile grid-ID in string format
1298
+ into a long.
1299
+
1300
+ :param grid_id: Input geotile grid-id. The input can be a single- or
1301
+ multi-valued column or an expression.
1302
+ """
1303
+ return InstrumentedExpression(f"ST_GEOTILE_TO_LONG({grid_id})")
1304
+
1305
+
1306
+ def st_geotile_to_string(grid_id: ExpressionType) -> InstrumentedExpression:
1307
+ """Converts an input value representing a geotile grid-ID in long format
1308
+ into a string.
1309
+
1310
+ :param grid_id: Input geotile grid-id. The input can be a single- or
1311
+ multi-valued column or an expression.
1312
+ """
1313
+ return InstrumentedExpression(f"ST_GEOTILE_TO_STRING({grid_id})")
1314
+
1315
+
1316
+ def st_intersects(
1317
+ geom_a: ExpressionType, geom_b: ExpressionType
1318
+ ) -> InstrumentedExpression:
1319
+ """Returns true if two geometries intersect. They intersect if they have
1320
+ any point in common, including their interior points (points along lines or
1321
+ within polygons). This is the inverse of the ST_DISJOINT function. In
1322
+ mathematical terms: ST_Intersects(A, B) ⇔ A ⋂ B ≠ ∅
1323
+
1324
+ :param geom_a: Expression of type `geo_point`, `cartesian_point`,
1325
+ `geo_shape` or `cartesian_shape`. If `null`, the function returns
1326
+ `null`.
1327
+ :param geom_b: Expression of type `geo_point`, `cartesian_point`, `geo_shape`
1328
+ or `cartesian_shape`. If `null`, the function returns `null`. The
1329
+ second parameter must also have the same coordinate system as the
1330
+ first. This means it is not possible to combine `geo_*` and
1331
+ `cartesian_*` parameters.
1332
+ """
1333
+ return InstrumentedExpression(f"ST_INTERSECTS({geom_a}, {geom_b})")
1334
+
1335
+
1336
+ def st_within(geom_a: ExpressionType, geom_b: ExpressionType) -> InstrumentedExpression:
1337
+ """Returns whether the first geometry is within the second geometry. This
1338
+ is the inverse of the ST_CONTAINS function.
1339
+
1340
+ :param geom_a: Expression of type `geo_point`, `cartesian_point`,
1341
+ `geo_shape` or `cartesian_shape`. If `null`, the function returns
1342
+ `null`.
1343
+ :param geom_b: Expression of type `geo_point`, `cartesian_point`, `geo_shape`
1344
+ or `cartesian_shape`. If `null`, the function returns `null`. The
1345
+ second parameter must also have the same coordinate system as the
1346
+ first. This means it is not possible to combine `geo_*` and
1347
+ `cartesian_*` parameters.
1348
+ """
1349
+ return InstrumentedExpression(f"ST_WITHIN({geom_a}, {geom_b})")
1350
+
1351
+
1352
+ def st_x(point: ExpressionType) -> InstrumentedExpression:
1353
+ """Extracts the `x` coordinate from the supplied point. If the points is of
1354
+ type `geo_point` this is equivalent to extracting the `longitude` value.
1355
+
1356
+ :param point: Expression of type `geo_point` or `cartesian_point`. If
1357
+ `null`, the function returns `null`.
1358
+ """
1359
+ return InstrumentedExpression(f"ST_X({_render(point)})")
1360
+
1361
+
1362
+ def st_xmax(point: ExpressionType) -> InstrumentedExpression:
1363
+ """Extracts the maximum value of the `x` coordinates from the supplied
1364
+ geometry. If the geometry is of type `geo_point` or `geo_shape` this is
1365
+ equivalent to extracting the maximum `longitude` value.
1366
+
1367
+ :param point: Expression of type `geo_point`, `geo_shape`, `cartesian_point`
1368
+ or `cartesian_shape`. If `null`, the function returns `null`.
1369
+ """
1370
+ return InstrumentedExpression(f"ST_XMAX({_render(point)})")
1371
+
1372
+
1373
+ def st_xmin(point: ExpressionType) -> InstrumentedExpression:
1374
+ """Extracts the minimum value of the `x` coordinates from the supplied
1375
+ geometry. If the geometry is of type `geo_point` or `geo_shape` this is
1376
+ equivalent to extracting the minimum `longitude` value.
1377
+
1378
+ :param point: Expression of type `geo_point`, `geo_shape`, `cartesian_point`
1379
+ or `cartesian_shape`. If `null`, the function returns `null`.
1380
+ """
1381
+ return InstrumentedExpression(f"ST_XMIN({_render(point)})")
1382
+
1383
+
1384
+ def st_y(point: ExpressionType) -> InstrumentedExpression:
1385
+ """Extracts the `y` coordinate from the supplied point. If the points is of
1386
+ type `geo_point` this is equivalent to extracting the `latitude` value.
1387
+
1388
+ :param point: Expression of type `geo_point` or `cartesian_point`. If
1389
+ `null`, the function returns `null`.
1390
+ """
1391
+ return InstrumentedExpression(f"ST_Y({_render(point)})")
1392
+
1393
+
1394
+ def st_ymax(point: ExpressionType) -> InstrumentedExpression:
1395
+ """Extracts the maximum value of the `y` coordinates from the supplied
1396
+ geometry. If the geometry is of type `geo_point` or `geo_shape` this is
1397
+ equivalent to extracting the maximum `latitude` value.
1398
+
1399
+ :param point: Expression of type `geo_point`, `geo_shape`, `cartesian_point`
1400
+ or `cartesian_shape`. If `null`, the function returns `null`.
1401
+ """
1402
+ return InstrumentedExpression(f"ST_YMAX({_render(point)})")
1403
+
1404
+
1405
+ def st_ymin(point: ExpressionType) -> InstrumentedExpression:
1406
+ """Extracts the minimum value of the `y` coordinates from the supplied
1407
+ geometry. If the geometry is of type `geo_point` or `geo_shape` this is
1408
+ equivalent to extracting the minimum `latitude` value.
1409
+
1410
+ :param point: Expression of type `geo_point`, `geo_shape`, `cartesian_point`
1411
+ or `cartesian_shape`. If `null`, the function returns `null`.
1412
+ """
1413
+ return InstrumentedExpression(f"ST_YMIN({_render(point)})")
1414
+
1415
+
1416
+ def substring(
1417
+ string: ExpressionType, start: ExpressionType, length: ExpressionType = None
1418
+ ) -> InstrumentedExpression:
1419
+ """Returns a substring of a string, specified by a start position and an
1420
+ optional length.
1421
+
1422
+ :param string: String expression. If `null`, the function returns `null`.
1423
+ :param start: Start position.
1424
+ :param length: Length of the substring from the start position. Optional; if
1425
+ omitted, all positions after `start` are returned.
1426
+ """
1427
+ if length is not None:
1428
+ return InstrumentedExpression(
1429
+ f"SUBSTRING({_render(string)}, {_render(start)}, {_render(length)})"
1430
+ )
1431
+ else:
1432
+ return InstrumentedExpression(f"SUBSTRING({_render(string)}, {_render(start)})")
1433
+
1434
+
1435
+ def sum(number: ExpressionType) -> InstrumentedExpression:
1436
+ """The sum of a numeric expression.
1437
+
1438
+ :param number:
1439
+ """
1440
+ return InstrumentedExpression(f"SUM({_render(number)})")
1441
+
1442
+
1443
+ def tan(angle: ExpressionType) -> InstrumentedExpression:
1444
+ """Returns the tangent of an angle.
1445
+
1446
+ :param angle: An angle, in radians. If `null`, the function returns `null`.
1447
+ """
1448
+ return InstrumentedExpression(f"TAN({_render(angle)})")
1449
+
1450
+
1451
+ def tanh(number: ExpressionType) -> InstrumentedExpression:
1452
+ """Returns the hyperbolic tangent of a number.
1453
+
1454
+ :param number: Numeric expression. If `null`, the function returns `null`.
1455
+ """
1456
+ return InstrumentedExpression(f"TANH({_render(number)})")
1457
+
1458
+
1459
+ def tau() -> InstrumentedExpression:
1460
+ """Returns the ratio of a circle’s circumference to its radius."""
1461
+ return InstrumentedExpression("TAU()")
1462
+
1463
+
1464
+ def term(field: ExpressionType, query: ExpressionType) -> InstrumentedExpression:
1465
+ """Performs a Term query on the specified field. Returns true if the
1466
+ provided term matches the row.
1467
+
1468
+ :param field: Field that the query will target.
1469
+ :param query: Term you wish to find in the provided field.
1470
+ """
1471
+ return InstrumentedExpression(f"TERM({_render(field)}, {_render(query)})")
1472
+
1473
+
1474
+ def top(
1475
+ field: ExpressionType, limit: ExpressionType, order: ExpressionType
1476
+ ) -> InstrumentedExpression:
1477
+ """Collects the top values for a field. Includes repeated values.
1478
+
1479
+ :param field: The field to collect the top values for.
1480
+ :param limit: The maximum number of values to collect.
1481
+ :param order: The order to calculate the top values. Either `asc` or `desc`.
1482
+ """
1483
+ return InstrumentedExpression(
1484
+ f"TOP({_render(field)}, {_render(limit)}, {_render(order)})"
1485
+ )
1486
+
1487
+
1488
+ def to_aggregate_metric_double(number: ExpressionType) -> InstrumentedExpression:
1489
+ """Encode a numeric to an aggregate_metric_double.
1490
+
1491
+ :param number: Input value. The input can be a single- or multi-valued
1492
+ column or an expression.
1493
+ """
1494
+ return InstrumentedExpression(f"TO_AGGREGATE_METRIC_DOUBLE({_render(number)})")
1495
+
1496
+
1497
+ def to_base64(string: ExpressionType) -> InstrumentedExpression:
1498
+ """Encode a string to a base64 string.
1499
+
1500
+ :param string: A string.
1501
+ """
1502
+ return InstrumentedExpression(f"TO_BASE64({_render(string)})")
1503
+
1504
+
1505
+ def to_boolean(field: ExpressionType) -> InstrumentedExpression:
1506
+ """Converts an input value to a boolean value. A string value of `true`
1507
+ will be case-insensitive converted to the Boolean `true`. For anything
1508
+ else, including the empty string, the function will return `false`. The
1509
+ numerical value of `0` will be converted to `false`, anything else will be
1510
+ converted to `true`.
1511
+
1512
+ :param field: Input value. The input can be a single- or multi-valued column
1513
+ or an expression.
1514
+ """
1515
+ return InstrumentedExpression(f"TO_BOOLEAN({_render(field)})")
1516
+
1517
+
1518
+ def to_cartesianpoint(field: ExpressionType) -> InstrumentedExpression:
1519
+ """Converts an input value to a `cartesian_point` value. A string will only
1520
+ be successfully converted if it respects the WKT Point format.
1521
+
1522
+ :param field: Input value. The input can be a single- or multi-valued column
1523
+ or an expression.
1524
+ """
1525
+ return InstrumentedExpression(f"TO_CARTESIANPOINT({_render(field)})")
1526
+
1527
+
1528
+ def to_cartesianshape(field: ExpressionType) -> InstrumentedExpression:
1529
+ """Converts an input value to a `cartesian_shape` value. A string will only
1530
+ be successfully converted if it respects the WKT format.
1531
+
1532
+ :param field: Input value. The input can be a single- or multi-valued column
1533
+ or an expression.
1534
+ """
1535
+ return InstrumentedExpression(f"TO_CARTESIANSHAPE({_render(field)})")
1536
+
1537
+
1538
+ def to_dateperiod(field: ExpressionType) -> InstrumentedExpression:
1539
+ """Converts an input value into a `date_period` value.
1540
+
1541
+ :param field: Input value. The input is a valid constant date period expression.
1542
+ """
1543
+ return InstrumentedExpression(f"TO_DATEPERIOD({_render(field)})")
1544
+
1545
+
1546
+ def to_datetime(field: ExpressionType) -> InstrumentedExpression:
1547
+ """Converts an input value to a date value. A string will only be
1548
+ successfully converted if it’s respecting the format
1549
+ `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. To convert dates in other formats, use `DATE_PARSE`.
1550
+
1551
+ :param field: Input value. The input can be a single- or multi-valued column
1552
+ or an expression.
1553
+ """
1554
+ return InstrumentedExpression(f"TO_DATETIME({_render(field)})")
1555
+
1556
+
1557
+ def to_date_nanos(field: ExpressionType) -> InstrumentedExpression:
1558
+ """Converts an input to a nanosecond-resolution date value (aka date_nanos).
1559
+
1560
+ :param field: Input value. The input can be a single- or multi-valued column
1561
+ or an expression.
1562
+ """
1563
+ return InstrumentedExpression(f"TO_DATE_NANOS({_render(field)})")
1564
+
1565
+
1566
+ def to_degrees(number: ExpressionType) -> InstrumentedExpression:
1567
+ """Converts a number in radians to degrees).
1568
+
1569
+ :param number: Input value. The input can be a single- or multi-valued
1570
+ column or an expression.
1571
+ """
1572
+ return InstrumentedExpression(f"TO_DEGREES({_render(number)})")
1573
+
1574
+
1575
+ def to_double(field: ExpressionType) -> InstrumentedExpression:
1576
+ """Converts an input value to a double value. If the input parameter is of
1577
+ a date type, its value will be interpreted as milliseconds since the Unix
1578
+ epoch, converted to double. Boolean `true` will be converted to double
1579
+ `1.0`, `false` to `0.0`.
1580
+
1581
+ :param field: Input value. The input can be a single- or multi-valued column
1582
+ or an expression.
1583
+ """
1584
+ return InstrumentedExpression(f"TO_DOUBLE({_render(field)})")
1585
+
1586
+
1587
+ def to_geopoint(field: ExpressionType) -> InstrumentedExpression:
1588
+ """Converts an input value to a `geo_point` value. A string will only be
1589
+ successfully converted if it respects the WKT Point format.
1590
+
1591
+ :param field: Input value. The input can be a single- or multi-valued column
1592
+ or an expression.
1593
+ """
1594
+ return InstrumentedExpression(f"TO_GEOPOINT({_render(field)})")
1595
+
1596
+
1597
+ def to_geoshape(field: ExpressionType) -> InstrumentedExpression:
1598
+ """Converts an input value to a `geo_shape` value. A string will only be
1599
+ successfully converted if it respects the WKT format.
1600
+
1601
+ :param field: Input value. The input can be a single- or multi-valued column
1602
+ or an expression.
1603
+ """
1604
+ return InstrumentedExpression(f"TO_GEOSHAPE({_render(field)})")
1605
+
1606
+
1607
+ def to_integer(field: ExpressionType) -> InstrumentedExpression:
1608
+ """Converts an input value to an integer value. If the input parameter is
1609
+ of a date type, its value will be interpreted as milliseconds since the
1610
+ Unix epoch, converted to integer. Boolean `true` will be converted to
1611
+ integer `1`, `false` to `0`.
1612
+
1613
+ :param field: Input value. The input can be a single- or multi-valued column
1614
+ or an expression.
1615
+ """
1616
+ return InstrumentedExpression(f"TO_INTEGER({_render(field)})")
1617
+
1618
+
1619
+ def to_ip(
1620
+ field: ExpressionType, options: ExpressionType = None
1621
+ ) -> InstrumentedExpression:
1622
+ """Converts an input string to an IP value.
1623
+
1624
+ :param field: Input value. The input can be a single- or multi-valued column
1625
+ or an expression.
1626
+ :param options: (Optional) Additional options.
1627
+ """
1628
+ if options is not None:
1629
+ return InstrumentedExpression(f"TO_IP({_render(field)}, {_render(options)})")
1630
+ else:
1631
+ return InstrumentedExpression(f"TO_IP({_render(field)})")
1632
+
1633
+
1634
+ def to_long(field: ExpressionType) -> InstrumentedExpression:
1635
+ """Converts an input value to a long value. If the input parameter is of a
1636
+ date type, its value will be interpreted as milliseconds since the Unix
1637
+ epoch, converted to long. Boolean `true` will be converted to long `1`,
1638
+ `false` to `0`.
1639
+
1640
+ :param field: Input value. The input can be a single- or multi-valued column
1641
+ or an expression.
1642
+ """
1643
+ return InstrumentedExpression(f"TO_LONG({_render(field)})")
1644
+
1645
+
1646
+ def to_lower(str: ExpressionType) -> InstrumentedExpression:
1647
+ """Returns a new string representing the input string converted to lower case.
1648
+
1649
+ :param str: String expression. If `null`, the function returns `null`. The
1650
+ input can be a single-valued column or expression, or a multi-valued
1651
+ column or expression.
1652
+ """
1653
+ return InstrumentedExpression(f"TO_LOWER({_render(str)})")
1654
+
1655
+
1656
+ def to_radians(number: ExpressionType) -> InstrumentedExpression:
1657
+ """Converts a number in degrees) to radians.
1658
+
1659
+ :param number: Input value. The input can be a single- or multi-valued
1660
+ column or an expression.
1661
+ """
1662
+ return InstrumentedExpression(f"TO_RADIANS({_render(number)})")
1663
+
1664
+
1665
+ def to_string(field: ExpressionType) -> InstrumentedExpression:
1666
+ """Converts an input value into a string.
1667
+
1668
+ :param field: Input value. The input can be a single- or multi-valued column
1669
+ or an expression.
1670
+ """
1671
+ return InstrumentedExpression(f"TO_STRING({_render(field)})")
1672
+
1673
+
1674
+ def to_timeduration(field: ExpressionType) -> InstrumentedExpression:
1675
+ """Converts an input value into a `time_duration` value.
1676
+
1677
+ :param field: Input value. The input is a valid constant time duration expression.
1678
+ """
1679
+ return InstrumentedExpression(f"TO_TIMEDURATION({_render(field)})")
1680
+
1681
+
1682
+ def to_unsigned_long(field: ExpressionType) -> InstrumentedExpression:
1683
+ """Converts an input value to an unsigned long value. If the input
1684
+ parameter is of a date type, its value will be interpreted as milliseconds
1685
+ since the Unix epoch, converted to unsigned long. Boolean `true` will be
1686
+ converted to unsigned long `1`, `false` to `0`.
1687
+
1688
+ :param field: Input value. The input can be a single- or multi-valued column
1689
+ or an expression.
1690
+ """
1691
+ return InstrumentedExpression(f"TO_UNSIGNED_LONG({_render(field)})")
1692
+
1693
+
1694
+ def to_upper(str: ExpressionType) -> InstrumentedExpression:
1695
+ """Returns a new string representing the input string converted to upper case.
1696
+
1697
+ :param str: String expression. If `null`, the function returns `null`. The
1698
+ input can be a single-valued column or expression, or a multi-valued
1699
+ column or expression.
1700
+ """
1701
+ return InstrumentedExpression(f"TO_UPPER({_render(str)})")
1702
+
1703
+
1704
+ def to_version(field: ExpressionType) -> InstrumentedExpression:
1705
+ """Converts an input string to a version value.
1706
+
1707
+ :param field: Input value. The input can be a single- or multi-valued column
1708
+ or an expression.
1709
+ """
1710
+ return InstrumentedExpression(f"TO_VERSION({_render(field)})")
1711
+
1712
+
1713
+ def trim(string: ExpressionType) -> InstrumentedExpression:
1714
+ """Removes leading and trailing whitespaces from a string.
1715
+
1716
+ :param string: String expression. If `null`, the function returns `null`.
1717
+ """
1718
+ return InstrumentedExpression(f"TRIM({_render(string)})")
1719
+
1720
+
1721
+ def values(field: ExpressionType) -> InstrumentedExpression:
1722
+ """Returns unique values as a multivalued field. The order of the returned
1723
+ values isn’t guaranteed. If you need the values returned in order use `MV_SORT`.
1724
+
1725
+ :param field:
1726
+ """
1727
+ return InstrumentedExpression(f"VALUES({_render(field)})")
1728
+
1729
+
1730
+ def weighted_avg(
1731
+ number: ExpressionType, weight: ExpressionType
1732
+ ) -> InstrumentedExpression:
1733
+ """The weighted average of a numeric expression.
1734
+
1735
+ :param number: A numeric value.
1736
+ :param weight: A numeric weight.
1737
+ """
1738
+ return InstrumentedExpression(f"WEIGHTED_AVG({_render(number)}, {_render(weight)})")