spark-connect 0.3.0 → 0.4.0

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +144 -27
  3. data/README.md +29 -11
  4. data/lib/spark_connect/catalog.rb +157 -12
  5. data/lib/spark_connect/channel_builder.rb +119 -12
  6. data/lib/spark_connect/client.rb +233 -17
  7. data/lib/spark_connect/column.rb +143 -10
  8. data/lib/spark_connect/conf.rb +16 -0
  9. data/lib/spark_connect/data_frame.rb +428 -23
  10. data/lib/spark_connect/functions.rb +1947 -493
  11. data/lib/spark_connect/grouped_data.rb +33 -7
  12. data/lib/spark_connect/merge.rb +146 -0
  13. data/lib/spark_connect/na_functions.rb +43 -9
  14. data/lib/spark_connect/observation.rb +26 -5
  15. data/lib/spark_connect/pipelines.rb +101 -0
  16. data/lib/spark_connect/plan.rb +52 -0
  17. data/lib/spark_connect/proto/spark/connect/base_pb.rb +6 -1
  18. data/lib/spark_connect/proto/spark/connect/base_services_pb.rb +2 -0
  19. data/lib/spark_connect/proto/spark/connect/catalog_pb.rb +11 -1
  20. data/lib/spark_connect/proto/spark/connect/commands_pb.rb +1 -1
  21. data/lib/spark_connect/proto/spark/connect/expressions_pb.rb +3 -1
  22. data/lib/spark_connect/proto/spark/connect/pipelines_pb.rb +5 -1
  23. data/lib/spark_connect/proto/spark/connect/relations_pb.rb +4 -1
  24. data/lib/spark_connect/proto/spark/connect/types_pb.rb +3 -1
  25. data/lib/spark_connect/reader.rb +98 -17
  26. data/lib/spark_connect/session.rb +232 -30
  27. data/lib/spark_connect/stat_functions.rb +19 -9
  28. data/lib/spark_connect/storage_level.rb +79 -0
  29. data/lib/spark_connect/streaming.rb +335 -20
  30. data/lib/spark_connect/table_arg.rb +73 -0
  31. data/lib/spark_connect/tvf.rb +78 -0
  32. data/lib/spark_connect/types.rb +149 -0
  33. data/lib/spark_connect/version.rb +2 -2
  34. data/lib/spark_connect/writer.rb +80 -10
  35. data/lib/spark_connect.rb +4 -0
  36. data/proto/spark/connect/base.proto +93 -1
  37. data/proto/spark/connect/catalog.proto +81 -0
  38. data/proto/spark/connect/commands.proto +7 -0
  39. data/proto/spark/connect/expressions.proto +28 -0
  40. data/proto/spark/connect/pipelines.proto +92 -5
  41. data/proto/spark/connect/relations.proto +71 -1
  42. data/proto/spark/connect/types.proto +19 -0
  43. metadata +6 -2
@@ -2,15 +2,27 @@
2
2
 
3
3
  module SparkConnect
4
4
  # The standard Spark SQL function library, mirroring PySpark's
5
- # `pyspark.sql.functions`. Every function returns a {Column}.
5
+ # `pyspark.sql.functions` (Spark Connect flavour). Every function returns a
6
+ # {Column}.
6
7
  #
7
8
  # Available both as `SparkConnect::Functions` and the shorthand
8
9
  # `SparkConnect::F`. All methods are module functions.
9
10
  #
10
- # Following PySpark's convention, a {String} argument denotes a **column name**
11
- # for most functions (e.g. `F.sum("salary")` aggregates the `salary` column),
12
- # while functions whose parameters are genuinely literal (regex patterns, date
13
- # formats, JSON paths, ...) treat their {String} arguments as literal values.
11
+ # Arguments follow PySpark's typing exactly, so PySpark code ports verbatim:
12
+ #
13
+ # * A parameter that PySpark types as `ColumnOrName` treats a {String} (or
14
+ # Symbol) as a **column name** (e.g. `F.sum("salary")`,
15
+ # `F.regexp_like("s", "pattern_col")`); wrap a literal with {lit}
16
+ # (`F.regexp_like("s", F.lit("a.*"))`). Non-String values such as numbers
17
+ # and booleans become literals.
18
+ # * A parameter that PySpark types as a plain Python value (`str`, `int`, ...)
19
+ # is always a **literal** (e.g. the format of {date_format}, the pattern of
20
+ # {regexp_extract}, the delimiter of {concat_ws}).
21
+ #
22
+ # Functions that PySpark seeds on the client when no seed is given ({rand},
23
+ # {randn}, {uuid}, {shuffle}, {randstr}, {uniform}, {count_min_sketch}) do the
24
+ # same here, so a DataFrame built with them returns the same values on every
25
+ # action.
14
26
  #
15
27
  # @example
16
28
  # F = SparkConnect::F
@@ -23,7 +35,8 @@ module SparkConnect
23
35
 
24
36
  # ---- Core constructors -------------------------------------------------
25
37
 
26
- # A column reference by name. `"*"` selects all columns.
38
+ # A column reference by name. `"*"` selects all columns and `"t.*"` all
39
+ # columns of the (aliased) relation `t`.
27
40
  # @return [Column]
28
41
  def col(name) = Column.from_name(name.to_s)
29
42
  alias column col
@@ -40,29 +53,64 @@ module SparkConnect
40
53
 
41
54
  # @return [Column] an ascending sort order for the named/given column.
42
55
  def asc(col) = _col(col).asc
56
+ # @return [Column] a descending sort order for the named/given column.
43
57
  def desc(col) = _col(col).desc
58
+ # @return [Column] ascending, nulls first.
44
59
  def asc_nulls_first(col) = _col(col).asc_nulls_first
60
+ # @return [Column] ascending, nulls last.
45
61
  def asc_nulls_last(col) = _col(col).asc_nulls_last
62
+ # @return [Column] descending, nulls first.
46
63
  def desc_nulls_first(col) = _col(col).desc_nulls_first
64
+ # @return [Column] descending, nulls last.
47
65
  def desc_nulls_last(col) = _col(col).desc_nulls_last
48
66
 
49
67
  # Start a CASE WHEN expression. Chain {Column#when} / {Column#otherwise}.
68
+ #
69
+ # @param condition [Column] a boolean column.
70
+ # @param value [Object] the value (a {Column} or a literal) for this branch.
50
71
  # @return [Column]
51
72
  def when(condition, value)
52
- Column.invoke("when", condition, value)
73
+ raise IllegalArgumentError, "when() condition must be a Column, got #{condition.class}" unless condition.is_a?(Column)
74
+
75
+ Column.invoke("when", condition, lit(value))
76
+ end
77
+
78
+ # Call a SQL function (built-in or registered) by name. Unlike
79
+ # {call_udf}, this resolves the name through the session catalog, so a
80
+ # qualified name (`"catalog.db.fn"`) or a built-in works.
81
+ #
82
+ # @param func_name [String]
83
+ # @param cols [Array<Column, String>] arguments; Strings are column names.
84
+ # @return [Column]
85
+ def call_function(func_name, *cols)
86
+ Column.new(Proto::Expression.new(
87
+ call_function: Proto::CallFunction.new(
88
+ function_name: func_name.to_s, arguments: cols.map { |c| _col(c).to_expr }
89
+ )
90
+ ))
53
91
  end
54
92
 
93
+ # Call a function registered on the server (e.g. a UDF registered through
94
+ # another client) by name.
95
+ #
96
+ # @param udf_name [String]
97
+ # @param cols [Array<Column, String>] arguments; Strings are column names.
98
+ # @return [Column]
99
+ def call_udf(udf_name, *cols) = _invoke(udf_name.to_s, *cols)
100
+
55
101
  # ---- Aggregate / counting ---------------------------------------------
56
102
 
57
103
  # @return [Column] count of rows (or non-null values of a column). `"*"`
58
- # counts all rows.
104
+ # (or `F.col("*")`) counts all rows.
59
105
  def count(col)
60
- col.to_s == "*" ? Column.invoke("count", lit(1)) : Column.invoke("count", _col(col))
106
+ return Column.invoke("count", lit(1)) if col.to_s == "*" || _star?(col)
107
+
108
+ Column.invoke("count", _col(col))
61
109
  end
62
110
 
63
111
  # @return [Column] count of distinct combinations of the given columns.
64
- def count_distinct(*cols)
65
- Column.invoke("count", *cols.map { |c| _col(c) }, is_distinct: true)
112
+ def count_distinct(col, *cols)
113
+ Column.invoke("count", *[col, *cols].map { |c| _col(c) }, is_distinct: true)
66
114
  end
67
115
  alias countDistinct count_distinct
68
116
 
@@ -70,38 +118,320 @@ module SparkConnect
70
118
  def approx_count_distinct(col, rsd = nil)
71
119
  rsd.nil? ? Column.invoke("approx_count_distinct", _col(col)) : Column.invoke("approx_count_distinct", _col(col), lit(rsd))
72
120
  end
121
+ alias approxCountDistinct approx_count_distinct
73
122
 
74
123
  # @return [Column] sum of distinct values.
75
124
  def sum_distinct(col) = Column.invoke("sum", _col(col), is_distinct: true)
125
+ alias sumDistinct sum_distinct
126
+
127
+ # @return [Column] the average of a column (alias of {avg}).
128
+ def mean(col) = avg(col)
129
+
130
+ # @param ignorenulls [Boolean] skip nulls and return the first non-null value.
131
+ # @return [Column] the first value in a group.
132
+ def first(col, ignorenulls = false) = Column.invoke("first", _col(col), lit(ignorenulls))
133
+
134
+ # @param ignorenulls [Boolean] skip nulls and return the last non-null value.
135
+ # @return [Column] the last value in a group.
136
+ def last(col, ignorenulls = false) = Column.invoke("last", _col(col), lit(ignorenulls))
137
+
138
+ # The most frequent value in a group.
139
+ #
140
+ # @param deterministic [Boolean] break ties deterministically (lowest value).
141
+ # @note The two-argument form requires a Spark 4.0+ server.
142
+ # @return [Column]
143
+ def mode(col, deterministic = false) = Column.invoke("mode", _col(col), lit(deterministic))
144
+
145
+ # The value of `col` associated with the maximum `ord`. With `k`, returns an
146
+ # array of the values for the top `k` orderings (Spark 4.2+).
147
+ # @return [Column]
148
+ def max_by(col, ord, k = nil)
149
+ k.nil? ? _invoke("max_by", col, ord) : Column.invoke("max_by", _col(col), _col(ord), lit(k))
150
+ end
151
+
152
+ # The value of `col` associated with the minimum `ord`. With `k`, returns an
153
+ # array of the values for the bottom `k` orderings (Spark 4.2+).
154
+ # @return [Column]
155
+ def min_by(col, ord, k = nil)
156
+ k.nil? ? _invoke("min_by", col, ord) : Column.invoke("min_by", _col(col), _col(ord), lit(k))
157
+ end
158
+
159
+ # The exact percentile(s) of a numeric column.
160
+ #
161
+ # @param percentage [Float, Array<Float>, Column] value(s) in 0.0..1.0.
162
+ # @param frequency [Integer, Column] a positive weight per row.
163
+ # @return [Column]
164
+ def percentile(col, percentage, frequency = 1)
165
+ unless frequency.is_a?(Integer) || frequency.is_a?(Column)
166
+ raise IllegalArgumentError, "percentile frequency must be an Integer or Column, got #{frequency.class}"
167
+ end
168
+
169
+ Column.invoke("percentile", _col(col), _percentage(percentage), lit(frequency))
170
+ end
171
+
172
+ # The approximate percentile(s) of a numeric column.
173
+ #
174
+ # @param percentage [Float, Array<Float>, Column] value(s) in 0.0..1.0.
175
+ # @param accuracy [Integer, Column] higher is more accurate (default 10000).
176
+ # @return [Column]
177
+ def percentile_approx(col, percentage, accuracy = 10_000)
178
+ Column.invoke("percentile_approx", _col(col), _percentage(percentage), lit(accuracy))
179
+ end
180
+
181
+ # Alias of {percentile_approx} under the `approx_percentile` SQL name.
182
+ # @return [Column]
183
+ def approx_percentile(col, percentage, accuracy = 10_000)
184
+ Column.invoke("approx_percentile", _col(col), _percentage(percentage), lit(accuracy))
185
+ end
186
+
187
+ # A count-min sketch of a column (binary), for approximate frequencies.
188
+ #
189
+ # @param eps [Float, Column] relative error, in (0, 1).
190
+ # @param confidence [Float, Column] confidence, in (0, 1).
191
+ # @param seed [Integer, Column, nil] random seed (generated when omitted).
192
+ # @return [Column]
193
+ def count_min_sketch(col, eps, confidence, seed = nil)
194
+ Column.invoke("count_min_sketch", _col(col), lit(eps), lit(confidence), _seed(seed))
195
+ end
196
+
197
+ # Concatenate the non-null values of a group, separated by `delimiter`.
198
+ # @param delimiter [String, Column, nil] a literal separator.
199
+ # @return [Column]
200
+ def listagg(col, delimiter = nil) = _agg_with_delimiter("listagg", col, delimiter)
201
+
202
+ # Like {listagg} over distinct values.
203
+ # @return [Column]
204
+ def listagg_distinct(col, delimiter = nil) = _agg_with_delimiter("listagg", col, delimiter, is_distinct: true)
205
+
206
+ # Alias of {listagg} under the `string_agg` SQL name.
207
+ # @return [Column]
208
+ def string_agg(col, delimiter = nil) = _agg_with_delimiter("string_agg", col, delimiter)
209
+
210
+ # Like {string_agg} over distinct values.
211
+ # @return [Column]
212
+ def string_agg_distinct(col, delimiter = nil) = _agg_with_delimiter("string_agg", col, delimiter, is_distinct: true)
213
+
214
+ # ---- Sketches: HLL, KLL, Theta, Tuple ---------------------------------
215
+
216
+ # An HLL sketch (binary) of a column.
217
+ # @param lg_config_k [Integer, Column, nil] log2 of the number of buckets.
218
+ # @return [Column]
219
+ def hll_sketch_agg(col, lg_config_k = nil) = _optional_literal_tail("hll_sketch_agg", [col], [lg_config_k])
220
+
221
+ # The union of two HLL sketches.
222
+ # @param allow_different_lg_config_k [Boolean, nil]
223
+ # @return [Column]
224
+ def hll_union(col1, col2, allow_different_lg_config_k = nil)
225
+ _optional_literal_tail("hll_union", [col1, col2], [allow_different_lg_config_k])
226
+ end
227
+
228
+ # Aggregate union of HLL sketches.
229
+ # @param allow_different_lg_config_k [Boolean, Column, nil]
230
+ # @return [Column]
231
+ def hll_union_agg(col, allow_different_lg_config_k = nil)
232
+ _optional_literal_tail("hll_union_agg", [col], [allow_different_lg_config_k])
233
+ end
234
+
235
+ %w[bigint double float].each do |kind|
236
+ define_method("kll_sketch_agg_#{kind}") { |col, k = nil| _optional_literal_tail("kll_sketch_agg_#{kind}", [col], [k]) }
237
+ define_method("kll_merge_agg_#{kind}") { |col, k = nil| _optional_literal_tail("kll_merge_agg_#{kind}", [col], [k]) }
238
+ end
239
+
240
+ # @!method kll_sketch_agg_bigint(col, k = nil)
241
+ # A KLL quantiles sketch of BIGINT values. @return [Column]
242
+ # @!method kll_sketch_agg_double(col, k = nil)
243
+ # A KLL quantiles sketch of DOUBLE values. @return [Column]
244
+ # @!method kll_sketch_agg_float(col, k = nil)
245
+ # A KLL quantiles sketch of FLOAT values. @return [Column]
246
+ # @!method kll_merge_agg_bigint(col, k = nil)
247
+ # Merge BIGINT KLL sketches. @return [Column]
248
+ # @!method kll_merge_agg_double(col, k = nil)
249
+ # Merge DOUBLE KLL sketches. @return [Column]
250
+ # @!method kll_merge_agg_float(col, k = nil)
251
+ # Merge FLOAT KLL sketches. @return [Column]
252
+
253
+ # A Theta sketch (binary) of a column.
254
+ # @param lg_nom_entries [Integer, Column, nil]
255
+ # @return [Column]
256
+ def theta_sketch_agg(col, lg_nom_entries = nil) = _optional_literal_tail("theta_sketch_agg", [col], [lg_nom_entries])
257
+
258
+ # The union of two Theta sketches.
259
+ # @return [Column]
260
+ def theta_union(col1, col2, lg_nom_entries = nil) = _optional_literal_tail("theta_union", [col1, col2], [lg_nom_entries])
261
+
262
+ # Aggregate union of Theta sketches.
263
+ # @return [Column]
264
+ def theta_union_agg(col, lg_nom_entries = nil) = _optional_literal_tail("theta_union_agg", [col], [lg_nom_entries])
265
+
266
+ %w[double integer].each do |kind|
267
+ define_method("tuple_intersection_agg_#{kind}") do |col, mode = nil|
268
+ _optional_literal_tail("tuple_intersection_agg_#{kind}", [col], [mode])
269
+ end
270
+ define_method("tuple_intersection_#{kind}") do |col1, col2, mode = nil|
271
+ _optional_literal_tail("tuple_intersection_#{kind}", [col1, col2], [mode])
272
+ end
273
+ define_method("tuple_intersection_theta_#{kind}") do |col1, col2, mode = nil|
274
+ _optional_literal_tail("tuple_intersection_theta_#{kind}", [col1, col2], [mode])
275
+ end
276
+ define_method("tuple_sketch_summary_#{kind}") do |col, mode = nil|
277
+ _optional_literal_tail("tuple_sketch_summary_#{kind}", [col], [mode])
278
+ end
279
+ define_method("tuple_sketch_agg_#{kind}") do |key, summary, lg_nom_entries = nil, mode = nil|
280
+ Column.invoke("tuple_sketch_agg_#{kind}", _col(key), _col(summary), *_tuple_defaults(lg_nom_entries, mode))
281
+ end
282
+ define_method("tuple_union_agg_#{kind}") do |col, lg_nom_entries = nil, mode = nil|
283
+ Column.invoke("tuple_union_agg_#{kind}", _col(col), *_tuple_defaults(lg_nom_entries, mode))
284
+ end
285
+ define_method("tuple_union_#{kind}") do |col1, col2, lg_nom_entries = nil, mode = nil|
286
+ Column.invoke("tuple_union_#{kind}", _col(col1), _col(col2), *_tuple_defaults(lg_nom_entries, mode))
287
+ end
288
+ define_method("tuple_union_theta_#{kind}") do |col1, col2, lg_nom_entries = nil, mode = nil|
289
+ Column.invoke("tuple_union_theta_#{kind}", _col(col1), _col(col2), *_tuple_defaults(lg_nom_entries, mode))
290
+ end
291
+ end
292
+
293
+ # @!method tuple_sketch_agg_double(key, summary, lg_nom_entries = nil, mode = nil)
294
+ # A Tuple sketch with DOUBLE summaries (`lg_nom_entries` defaults to 12, `mode` to `"sum"`). @return [Column]
295
+ # @!method tuple_sketch_agg_integer(key, summary, lg_nom_entries = nil, mode = nil)
296
+ # A Tuple sketch with INTEGER summaries (`lg_nom_entries` defaults to 12, `mode` to `"sum"`). @return [Column]
297
+ # @!method tuple_union_agg_double(col, lg_nom_entries = nil, mode = nil)
298
+ # Aggregate union of DOUBLE Tuple sketches. @return [Column]
299
+ # @!method tuple_union_agg_integer(col, lg_nom_entries = nil, mode = nil)
300
+ # Aggregate union of INTEGER Tuple sketches. @return [Column]
301
+ # @!method tuple_union_double(col1, col2, lg_nom_entries = nil, mode = nil)
302
+ # Union of two DOUBLE Tuple sketches. @return [Column]
303
+ # @!method tuple_union_integer(col1, col2, lg_nom_entries = nil, mode = nil)
304
+ # Union of two INTEGER Tuple sketches. @return [Column]
305
+ # @!method tuple_union_theta_double(col1, col2, lg_nom_entries = nil, mode = nil)
306
+ # Union of a DOUBLE Tuple sketch with a Theta sketch. @return [Column]
307
+ # @!method tuple_union_theta_integer(col1, col2, lg_nom_entries = nil, mode = nil)
308
+ # Union of an INTEGER Tuple sketch with a Theta sketch. @return [Column]
309
+ # @!method tuple_intersection_agg_double(col, mode = nil)
310
+ # Aggregate intersection of DOUBLE Tuple sketches. @return [Column]
311
+ # @!method tuple_intersection_agg_integer(col, mode = nil)
312
+ # Aggregate intersection of INTEGER Tuple sketches. @return [Column]
313
+ # @!method tuple_intersection_double(col1, col2, mode = nil)
314
+ # Intersection of two DOUBLE Tuple sketches. @return [Column]
315
+ # @!method tuple_intersection_integer(col1, col2, mode = nil)
316
+ # Intersection of two INTEGER Tuple sketches. @return [Column]
317
+ # @!method tuple_intersection_theta_double(col1, col2, mode = nil)
318
+ # Intersection of a DOUBLE Tuple sketch with a Theta sketch. @return [Column]
319
+ # @!method tuple_intersection_theta_integer(col1, col2, mode = nil)
320
+ # Intersection of an INTEGER Tuple sketch with a Theta sketch. @return [Column]
321
+ # @!method tuple_sketch_summary_double(col, mode = nil)
322
+ # The aggregated DOUBLE summary of a Tuple sketch. @return [Column]
323
+ # @!method tuple_sketch_summary_integer(col, mode = nil)
324
+ # The aggregated INTEGER summary of a Tuple sketch. @return [Column]
325
+
326
+ # ---- Math / rounding ---------------------------------------------------
327
+
328
+ # HALF_UP rounding to `scale` decimal places (0 when omitted).
329
+ # @param scale [Integer, Column, String, nil]
330
+ # @return [Column]
331
+ def round(col, scale = nil) = scale.nil? ? _invoke("round", col) : _invoke("round", col, scale)
332
+
333
+ # HALF_EVEN ("banker's") rounding to `scale` decimal places.
334
+ # @param scale [Integer, Column, String, nil]
335
+ # @return [Column]
336
+ def bround(col, scale = nil) = scale.nil? ? _invoke("bround", col) : _invoke("bround", col, scale)
337
+
338
+ # Logarithm. With one argument, the natural logarithm of `arg1`; with two,
339
+ # the logarithm of `arg2` in base `arg1` (a literal).
340
+ # @return [Column]
341
+ def log(arg1, arg2 = nil)
342
+ arg2.nil? ? Column.invoke("ln", _col(arg1)) : Column.invoke("log", lit(arg1), _col(arg2))
343
+ end
344
+
345
+ # `col1` raised to the power of `col2` (numbers are literals, Strings columns).
346
+ # @return [Column]
347
+ def pow(col1, col2) = _invoke("power", col1, col2)
348
+ alias power pow
349
+
350
+ # @return [Column] the bitwise NOT of a column.
351
+ def bitwise_not(col) = _invoke("~", col)
352
+ alias bitwiseNOT bitwise_not
353
+
354
+ # @return [Column] the negation of a column (alias of {negative}).
355
+ def negate(col) = negative(col)
356
+
357
+ # @return [Column] left shift by a literal bit count.
358
+ def shiftleft(col, num_bits) = Column.invoke("shiftleft", _col(col), lit(num_bits))
359
+ # @return [Column] signed right shift by a literal bit count.
360
+ def shiftright(col, num_bits) = Column.invoke("shiftright", _col(col), lit(num_bits))
361
+ # @return [Column] unsigned right shift by a literal bit count.
362
+ def shiftrightunsigned(col, num_bits) = Column.invoke("shiftrightunsigned", _col(col), lit(num_bits))
363
+ alias shiftLeft shiftleft
364
+ alias shiftRight shiftright
365
+ alias shiftRightUnsigned shiftrightunsigned
76
366
 
77
- # ---- Rounding ----------------------------------------------------------
367
+ # @return [Column] radians converted to degrees (deprecated PySpark alias of {degrees}).
368
+ def toDegrees(col) = degrees(col)
369
+ # @return [Column] degrees converted to radians (deprecated PySpark alias of {radians}).
370
+ def toRadians(col) = radians(col)
78
371
 
79
- # @return [Column] HALF_UP rounding to `scale` decimal places.
80
- def round(col, scale = 0) = Column.invoke("round", _col(col), lit(scale))
81
- # @return [Column] HALF_EVEN ("banker's") rounding to `scale` places.
82
- def bround(col, scale = 0) = Column.invoke("bround", _col(col), lit(scale))
372
+ # @return [Column] convert a number string from `from_base` to `to_base`.
373
+ def conv(col, from_base, to_base) = Column.invoke("conv", _col(col), lit(from_base), lit(to_base))
374
+
375
+ SHA2_BIT_LENGTHS = [0, 224, 256, 384, 512].freeze
376
+
377
+ # SHA-2 hash with the given bit length.
378
+ # @param num_bits [Integer] one of 0 (=256), 224, 256, 384, 512.
379
+ # @return [Column]
380
+ def sha2(col, num_bits)
381
+ unless SHA2_BIT_LENGTHS.include?(num_bits)
382
+ raise IllegalArgumentError, "sha2 num_bits must be one of #{SHA2_BIT_LENGTHS.inspect}, got #{num_bits.inspect}"
383
+ end
384
+
385
+ Column.invoke("sha2", _col(col), lit(num_bits))
386
+ end
83
387
 
84
- # ---- Conditionals / null handling -------------------------------------
388
+ # @return [Column] the greatest value of the given columns (at least two), skipping nulls.
389
+ def greatest(*cols) = _at_least_two("greatest", cols)
390
+
391
+ # @return [Column] the least value of the given columns (at least two), skipping nulls.
392
+ def least(*cols) = _at_least_two("least", cols)
393
+
394
+ # ---- Conditionals / null handling / errors ----------------------------
85
395
 
86
396
  # @return [Column] first non-null among the given columns.
87
- def coalesce(*cols) = Column.invoke("coalesce", *cols.map { |c| _col(c) })
397
+ def coalesce(*cols) = _invoke("coalesce", *cols)
88
398
  # @return [Column] `col1` if it is not NaN, else `col2`.
89
- def nanvl(col1, col2) = Column.invoke("nanvl", _col(col1), _col(col2))
399
+ def nanvl(col1, col2) = _invoke("nanvl", col1, col2)
400
+
401
+ # Raise an error when `col` is not true.
402
+ # @param err_msg [String, Column, nil] the error message (a literal).
403
+ # @return [Column]
404
+ def assert_true(col, err_msg = nil)
405
+ return _invoke("assert_true", col) if err_msg.nil?
406
+
407
+ _check_str_or_col("err_msg", err_msg)
408
+ Column.invoke("assert_true", _col(col), lit(err_msg))
409
+ end
410
+
411
+ # Raise an error with the given message.
412
+ # @param err_msg [String, Column] the error message (a literal).
413
+ # @return [Column]
414
+ def raise_error(err_msg)
415
+ _check_str_or_col("err_msg", err_msg)
416
+ Column.invoke("raise_error", lit(err_msg))
417
+ end
90
418
 
91
419
  # ---- Constructors of complex types ------------------------------------
92
420
 
93
- # @return [Column] a struct from the given columns.
94
- def struct(*cols) = Column.invoke("struct", *cols.map { |c| _col(c) })
95
- # @return [Column] an array from the given columns.
96
- def array(*cols) = Column.invoke("array", *cols.map { |c| _col(c) })
97
- # @return [Column] a map from alternating key/value columns.
98
- def create_map(*cols) = Column.invoke("map", *cols.map { |c| _col(c) })
421
+ # @return [Column] a struct from the given columns (or one Array of them).
422
+ def struct(*cols) = _invoke("struct", *_unwrap_list(cols))
423
+ # @return [Column] an array from the given columns (or one Array of them).
424
+ def array(*cols) = _invoke("array", *_unwrap_list(cols))
425
+ # @return [Column] a map from alternating key/value columns (or one Array of them).
426
+ def create_map(*cols) = _invoke("map", *_unwrap_list(cols))
99
427
  # @return [Column] a map from two array columns (keys, values).
100
- def map_from_arrays(keys, values) = Column.invoke("map_from_arrays", _col(keys), _col(values))
428
+ def map_from_arrays(keys, values) = _invoke("map_from_arrays", keys, values)
101
429
  # @return [Column] a named struct from alternating name/value arguments.
102
- def named_struct(*cols) = Column.invoke("named_struct", *cols.map { |c| _col(c) })
430
+ def named_struct(*cols) = _invoke("named_struct", *cols)
431
+ # @return [Column] the union of the given maps (or one Array of them).
432
+ def map_concat(*cols) = _invoke("map_concat", *_unwrap_list(cols))
103
433
 
104
- # ---- String functions with literal arguments --------------------------
434
+ # ---- String functions --------------------------------------------------
105
435
 
106
436
  # @return [Column] concatenation of columns separated by literal `sep`.
107
437
  def concat_ws(sep, *cols) = Column.invoke("concat_ws", lit(sep), *cols.map { |c| _col(c) })
@@ -109,219 +439,769 @@ module SparkConnect
109
439
  def format_string(fmt, *cols) = Column.invoke("format_string", lit(fmt), *cols.map { |c| _col(c) })
110
440
  # @return [Column] number formatted to `d` decimal places.
111
441
  def format_number(col, d) = Column.invoke("format_number", _col(col), lit(d))
112
- # @return [Column] substring of length `len` from 1-based `pos`.
113
- def substring(col, pos, len) = Column.invoke("substring", _col(col), lit(pos), lit(len))
114
- # @return [Column] substring before the `count`-th occurrence of `delim`.
442
+
443
+ # Substring of length `len` from 1-based `pos`.
444
+ # @param pos [Integer, Column, String] Strings are column names.
445
+ # @param len [Integer, Column, String] Strings are column names.
446
+ # @return [Column]
447
+ def substring(col, pos, len) = _invoke("substring", col, pos, len)
448
+
449
+ # @return [Column] substring before the `count`-th occurrence of literal `delim`.
115
450
  def substring_index(col, delim, count) = Column.invoke("substring_index", _col(col), lit(delim), lit(count))
116
- # @return [Column] 1-based position of literal `substr` within `col` (0 if absent).
117
- def instr(col, substr) = Column.invoke("instr", _col(col), lit(substr))
118
- # @return [Column] 1-based position of `substr` in `col` at/after `pos`.
451
+
452
+ # The 1-based position of `substr` within `col` (0 if absent). `start`
453
+ # begins the search at a 1-based position and `occurrence` picks the n-th
454
+ # match (Spark 4.3+ for those two).
455
+ #
456
+ # @param substr [String, Column] a literal substring.
457
+ # @param start [Integer, Column, nil]
458
+ # @param occurrence [Integer, Column, nil]
459
+ # @return [Column]
460
+ def instr(col, substr, start = nil, occurrence = nil)
461
+ if start.nil? && occurrence.nil?
462
+ Column.invoke("instr", _col(col), lit(substr))
463
+ elsif occurrence.nil?
464
+ Column.invoke("instr", _col(col), lit(substr), lit(start))
465
+ else
466
+ Column.invoke("instr", _col(col), lit(substr), lit(start.nil? ? 1 : start), lit(occurrence))
467
+ end
468
+ end
469
+
470
+ # @return [Column] 1-based position of literal `substr` in `col` at/after `pos`.
119
471
  def locate(substr, col, pos = 1) = Column.invoke("locate", lit(substr), _col(col), lit(pos))
120
- # @return [Column] left-padded string.
472
+ # @return [Column] left-padded string (`len` and `pad` are literals).
121
473
  def lpad(col, len, pad) = Column.invoke("lpad", _col(col), lit(len), lit(pad))
122
- # @return [Column] right-padded string.
474
+ # @return [Column] right-padded string (`len` and `pad` are literals).
123
475
  def rpad(col, len, pad) = Column.invoke("rpad", _col(col), lit(len), lit(pad))
476
+
477
+ # @param n [Integer, Column, String] repeat count; Strings are column names.
124
478
  # @return [Column] the string repeated `n` times.
125
- def repeat(col, n) = Column.invoke("repeat", _col(col), lit(n))
126
- # @return [Column] split `col` by the literal regex `pattern`.
127
- def split(col, pattern, limit = -1) = Column.invoke("split", _col(col), lit(pattern), lit(limit))
128
- # @return [Column] characters of `col` matching `matching` replaced per `replace`.
479
+ def repeat(col, n) = _invoke("repeat", col, n)
480
+
481
+ # Split `col` around matches of the literal regex `pattern`.
482
+ # @param limit [Integer, Column, String] at most `limit` parts (-1 = no
483
+ # limit); Strings are column names.
484
+ # @return [Column]
485
+ def split(col, pattern, limit = -1) = Column.invoke("split", _col(col), lit(pattern), _col(limit))
486
+
487
+ # @return [Column] characters of `col` matching `matching` replaced per `replace` (literals).
129
488
  def translate(col, matching, replace) = Column.invoke("translate", _col(col), lit(matching), lit(replace))
130
- # @return [Column] the `idx`-th group of `pattern` matched in `col`.
489
+
490
+ # The `idx`-th group of the literal regex `pattern` matched in `col`.
491
+ # @return [Column]
131
492
  def regexp_extract(col, pattern, idx = 0) = Column.invoke("regexp_extract", _col(col), lit(pattern), lit(idx))
132
- # @return [Column] all matches of group `idx` of `pattern`.
133
- def regexp_extract_all(col, pattern, idx = 1) = Column.invoke("regexp_extract_all", _col(col), lit(pattern), lit(idx))
134
- # @return [Column] `col` with `pattern` replaced by `replacement`.
135
- def regexp_replace(col, pattern, replacement) = Column.invoke("regexp_replace", _col(col), lit(pattern), lit(replacement))
136
- # @return [Column] whether `col` matches `pattern`.
137
- def regexp_like(col, pattern) = Column.invoke("regexp_like", _col(col), lit(pattern))
138
- def regexp_count(col, pattern) = Column.invoke("regexp_count", _col(col), lit(pattern))
139
- def regexp_substr(col, pattern) = Column.invoke("regexp_substr", _col(col), lit(pattern))
140
- # @return [Column] overlay `replace` into `col` at `pos` for `len` chars.
141
- def overlay(col, replace, pos, len = -1) = Column.invoke("overlay", _col(col), _col(replace), lit(pos), lit(len))
142
- # @return [Column] SHA-2 hash with the given bit length (224/256/384/512).
143
- def sha2(col, num_bits) = Column.invoke("sha2", _col(col), lit(num_bits))
144
- # @return [Column] convert a number string from `from_base` to `to_base`.
145
- def conv(col, from_base, to_base) = Column.invoke("conv", _col(col), lit(from_base), lit(to_base))
146
- # @return [Column] left shift / right shift by literal bit counts.
147
- def shiftleft(col, num_bits) = Column.invoke("shiftleft", _col(col), lit(num_bits))
148
- def shiftright(col, num_bits) = Column.invoke("shiftright", _col(col), lit(num_bits))
149
- def shiftrightunsigned(col, num_bits) = Column.invoke("shiftrightunsigned", _col(col), lit(num_bits))
150
493
 
151
- # ---- Date / time functions with literal arguments ---------------------
494
+ # All matches of group `idx` of `regexp` in `col`.
495
+ # @param regexp [Column, String] a Column (e.g. `F.lit("(\\d+)")`); Strings are column names.
496
+ # @param idx [Integer, Column, nil] the group index (1 when omitted).
497
+ # @return [Column]
498
+ def regexp_extract_all(col, regexp, idx = nil)
499
+ idx.nil? ? _invoke("regexp_extract_all", col, regexp) : Column.invoke("regexp_extract_all", _col(col), _col(regexp), lit(idx))
500
+ end
501
+
502
+ # Replace all substrings of `col` matching `pattern` with `replacement`
503
+ # (both literals or Columns). `position` starts the search at a 1-based
504
+ # character position (Spark 4.3+).
505
+ # @return [Column]
506
+ def regexp_replace(col, pattern, replacement, position = nil)
507
+ args = [_col(col), lit(pattern), lit(replacement)]
508
+ args << lit(position) unless position.nil?
509
+ Column.invoke("regexp_replace", *args)
510
+ end
511
+
512
+ # The 1-based position of the first match of `regexp` in `str` (0 if none).
513
+ # @param regexp [Column, String] Strings are column names.
514
+ # @param idx [Integer, Column, nil] the regex group index.
515
+ # @return [Column]
516
+ def regexp_instr(str, regexp, idx = nil)
517
+ idx.nil? ? _invoke("regexp_instr", str, regexp) : Column.invoke("regexp_instr", _col(str), _col(regexp), lit(idx))
518
+ end
519
+
520
+ # Overlay `replace` into `src` at 1-based `pos` for `len` characters.
521
+ # @param pos [Integer, Column, String] Strings are column names.
522
+ # @param len [Integer, Column, String] -1 replaces `replace.length` characters.
523
+ # @return [Column]
524
+ def overlay(src, replace, pos, len = -1) = _invoke("overlay", src, replace, pos, len)
525
+
526
+ # Trim spaces (or the characters of `trim`) from both ends of `col`.
527
+ # @param trim [Column, String, nil] the trim characters; Strings are column names.
528
+ # @return [Column]
529
+ def trim(col, trim = nil) = _trim("trim", col, trim)
530
+ # Trim spaces (or the characters of `trim`) from the start of `col`.
531
+ # @return [Column]
532
+ def ltrim(col, trim = nil) = _trim("ltrim", col, trim)
533
+ # Trim spaces (or the characters of `trim`) from the end of `col`.
534
+ # @return [Column]
535
+ def rtrim(col, trim = nil) = _trim("rtrim", col, trim)
536
+
537
+ # The Levenshtein distance between two strings; with `threshold`, -1 when
538
+ # the distance exceeds it.
539
+ # @return [Column]
540
+ def levenshtein(left, right, threshold = nil)
541
+ _optional_literal_tail("levenshtein", [left, right], [threshold])
542
+ end
543
+
544
+ # @return [Column] `col` decoded from binary using the literal `charset`.
545
+ def decode(col, charset) = Column.invoke("decode", _col(col), lit(charset))
546
+ # @return [Column] `col` encoded to binary using the literal `charset`.
547
+ def encode(col, charset) = Column.invoke("encode", _col(col), lit(charset))
548
+ # @return [Column] `col` with the literal `collation` applied.
549
+ def collate(col, collation) = Column.invoke("collate", _col(col), lit(collation))
550
+
551
+ # Split a string into arrays of sentences of words.
552
+ # @param language [Column, String, nil] Strings are column names (default `""`).
553
+ # @param country [Column, String, nil] Strings are column names (default `""`).
554
+ # @return [Column]
555
+ def sentences(string, language = nil, country = nil)
556
+ Column.invoke("sentences", _col(string), _col_or_default(language, ""), _col_or_default(country, ""))
557
+ end
558
+
559
+ # Convert a delimited string into a map.
560
+ # @param pair_delim [Column, String, nil] Strings are column names (default `","`).
561
+ # @param key_value_delim [Column, String, nil] Strings are column names (default `":"`).
562
+ # @return [Column]
563
+ def str_to_map(text, pair_delim = nil, key_value_delim = nil)
564
+ Column.invoke("str_to_map", _col(text), _col_or_default(pair_delim, ","), _col_or_default(key_value_delim, ":"))
565
+ end
566
+
567
+ # Mask a string: upper-case letters to `upper_char` (default `"X"`),
568
+ # lower-case to `lower_char` (`"x"`), digits to `digit_char` (`"n"`), and
569
+ # other characters to `other_char` (unchanged). Given values are Columns
570
+ # or column names.
571
+ # @return [Column]
572
+ def mask(col, upper_char = nil, lower_char = nil, digit_char = nil, other_char = nil)
573
+ Column.invoke("mask", _col(col), _col_or_default(upper_char, "X"), _col_or_default(lower_char, "x"),
574
+ _col_or_default(digit_char, "n"), other_char.nil? ? lit(nil) : _col(other_char))
575
+ end
576
+
577
+ # AES-encrypt `input` with `key` (`mode` defaults to `"GCM"`, `padding` to
578
+ # `"DEFAULT"`, `iv` and `aad` to empty). Given values are Columns or column names.
579
+ # @return [Column]
580
+ def aes_encrypt(input, key, mode = nil, padding = nil, iv = nil, aad = nil)
581
+ Column.invoke("aes_encrypt", _col(input), _col(key), _col_or_default(mode, "GCM"),
582
+ _col_or_default(padding, "DEFAULT"), _col_or_default(iv, ""), _col_or_default(aad, ""))
583
+ end
584
+
585
+ # AES-decrypt `input` with `key` (see {aes_encrypt} for the defaults).
586
+ # @return [Column]
587
+ def aes_decrypt(input, key, mode = nil, padding = nil, aad = nil) = _aes_decrypt("aes_decrypt", input, key, mode, padding, aad)
588
+
589
+ # Like {aes_decrypt} but returns null on failure.
590
+ # @return [Column]
591
+ def try_aes_decrypt(input, key, mode = nil, padding = nil, aad = nil)
592
+ _aes_decrypt("try_aes_decrypt", input, key, mode, padding, aad)
593
+ end
594
+
595
+ # ---- Date / time functions --------------------------------------------
152
596
 
597
+ # @return [Column] `col` formatted with the literal `fmt`.
153
598
  def date_format(col, fmt) = Column.invoke("date_format", _col(col), lit(fmt))
599
+ # @return [Column] `col` parsed to a date (optionally with literal `fmt`).
154
600
  def to_date(col, fmt = nil) = fmt ? Column.invoke("to_date", _col(col), lit(fmt)) : Column.invoke("to_date", _col(col))
601
+ # @return [Column] `col` parsed to a timestamp (optionally with literal `fmt`).
155
602
  def to_timestamp(col, fmt = nil) = fmt ? Column.invoke("to_timestamp", _col(col), lit(fmt)) : Column.invoke("to_timestamp", _col(col))
156
- def date_add(col, days) = Column.invoke("date_add", _col(col), lit(days))
157
- def date_sub(col, days) = Column.invoke("date_sub", _col(col), lit(days))
158
- def datediff(end_col, start_col) = Column.invoke("datediff", _col(end_col), _col(start_col))
159
- def add_months(col, months) = Column.invoke("add_months", _col(col), lit(months))
603
+ # @return [Column] like {to_date} but null on failure.
604
+ def try_to_date(col, fmt = nil) = fmt ? Column.invoke("try_to_date", _col(col), lit(fmt)) : Column.invoke("try_to_date", _col(col))
605
+
606
+ # @param days [Integer, Column, String] Strings are column names.
607
+ # @return [Column] the date `days` days after `col`.
608
+ def date_add(col, days) = _invoke("date_add", col, days)
609
+ # @return [Column] alias of {date_add} under the `dateadd` SQL name.
610
+ def dateadd(col, days) = _invoke("dateadd", col, days)
611
+ # @return [Column] the date `days` days before `col`.
612
+ def date_sub(col, days) = _invoke("date_sub", col, days)
613
+ # @param months [Integer, Column, String] Strings are column names.
614
+ # @return [Column] the date `months` months after `col`.
615
+ def add_months(col, months) = _invoke("add_months", col, months)
616
+ # @return [Column] the number of days from `start_col` to `end_col`.
617
+ def datediff(end_col, start_col) = _invoke("datediff", end_col, start_col)
618
+ # @return [Column] months between two dates (rounded to 8 digits unless `round_off` is false).
160
619
  def months_between(d1, d2, round_off = true) = Column.invoke("months_between", _col(d1), _col(d2), lit(round_off))
620
+ # @return [Column] the first date after `col` that is the literal `day_of_week`.
161
621
  def next_day(col, day_of_week) = Column.invoke("next_day", _col(col), lit(day_of_week))
622
+ # @return [Column] the date truncated to the literal unit `fmt`.
162
623
  def trunc(col, fmt) = Column.invoke("trunc", _col(col), lit(fmt))
624
+ # @return [Column] the timestamp truncated to the literal unit `fmt`.
163
625
  def date_trunc(fmt, col) = Column.invoke("date_trunc", lit(fmt), _col(col))
626
+ # @return [Column] epoch seconds formatted with the literal `fmt`.
164
627
  def from_unixtime(col, fmt = "yyyy-MM-dd HH:mm:ss") = Column.invoke("from_unixtime", _col(col), lit(fmt))
165
628
 
629
+ # @return [Column] the current epoch seconds, or `col` parsed with the literal `fmt`.
166
630
  def unix_timestamp(col = nil, fmt = "yyyy-MM-dd HH:mm:ss")
167
631
  col.nil? ? Column.invoke("unix_timestamp") : Column.invoke("unix_timestamp", _col(col), lit(fmt))
168
632
  end
169
633
 
634
+ # @param tz [String, Column] a literal time zone.
635
+ # @return [Column] a UTC timestamp rendered in `tz`.
170
636
  def from_utc_timestamp(col, tz) = Column.invoke("from_utc_timestamp", _col(col), lit(tz))
637
+ # @param tz [String, Column] a literal time zone.
638
+ # @return [Column] a `tz` timestamp rendered in UTC.
171
639
  def to_utc_timestamp(col, tz) = Column.invoke("to_utc_timestamp", _col(col), lit(tz))
172
- def make_date(year, month, day) = Column.invoke("make_date", _col(year), _col(month), _col(day))
640
+ # @return [Column] a date from year, month, and day columns.
641
+ def make_date(year, month, day) = _invoke("make_date", year, month, day)
173
642
 
174
- # ---- JSON / CSV --------------------------------------------------------
643
+ # A day-time interval. Omitted parts are 0; given parts are Columns or column names.
644
+ # @return [Column]
645
+ def make_dt_interval(days = nil, hours = nil, mins = nil, secs = nil)
646
+ Column.invoke("make_dt_interval", _col_or_default(days, 0), _col_or_default(hours, 0), _col_or_default(mins, 0),
647
+ _col_or_default(secs, BigDecimal("0")))
648
+ end
175
649
 
176
- def get_json_object(col, path) = Column.invoke("get_json_object", _col(col), lit(path))
177
- def json_tuple(col, *fields) = Column.invoke("json_tuple", _col(col), *fields.map { |f| lit(f) })
650
+ # A calendar interval. Omitted parts are 0; given parts are Columns or column names.
651
+ # @return [Column]
652
+ def make_interval(years = nil, months = nil, weeks = nil, days = nil, hours = nil, mins = nil, secs = nil)
653
+ _make_interval("make_interval", years, months, weeks, days, hours, mins, secs)
654
+ end
178
655
 
179
- # @param schema [Types::DataType, String]
180
- def from_json(col, schema, options = {})
181
- schema_col = schema.is_a?(Types::DataType) ? lit(schema.json) : lit(schema.to_s)
182
- args = [_col(col), schema_col] + options.flat_map { |k, v| [lit(k.to_s), lit(v.to_s)] }
183
- Column.invoke("from_json", *args)
656
+ # Like {make_interval} but null on overflow.
657
+ # @return [Column]
658
+ def try_make_interval(years = nil, months = nil, weeks = nil, days = nil, hours = nil, mins = nil, secs = nil)
659
+ _make_interval("try_make_interval", years, months, weeks, days, hours, mins, secs)
184
660
  end
185
661
 
186
- def to_json(col, options = {})
187
- args = [_col(col)] + options.flat_map { |k, v| [lit(k.to_s), lit(v.to_s)] }
188
- Column.invoke("to_json", *args)
662
+ # A year-month interval. Omitted parts are 0.
663
+ # @return [Column]
664
+ def make_ym_interval(years = nil, months = nil)
665
+ Column.invoke("make_ym_interval", _col_or_default(years, 0), _col_or_default(months, 0))
189
666
  end
190
667
 
191
- def schema_of_json(json, options = {})
192
- Column.invoke("schema_of_json", _lit_or_col(json), *options.flat_map { |k, v| [lit(k.to_s), lit(v.to_s)] })
668
+ # A timestamp from parts, either `(years, months, days, hours, mins, secs[, timezone])`
669
+ # or `(date:, time:[, timezone:])` (the latter requires Spark 4.1+).
670
+ #
671
+ # @example
672
+ # F.make_timestamp("y", "mo", "d", "h", "mi", "s")
673
+ # F.make_timestamp(date: "d", time: "t", timezone: F.lit("UTC"))
674
+ # @return [Column]
675
+ def make_timestamp(*parts, date: nil, time: nil, timezone: nil)
676
+ _make_timestamp("make_timestamp", parts, date, time, timezone, allow_timezone: true)
193
677
  end
194
678
 
195
- # ---- Array / map functions with value arguments -----------------------
679
+ # Like {make_timestamp} but null on invalid input.
680
+ # @return [Column]
681
+ def try_make_timestamp(*parts, date: nil, time: nil, timezone: nil)
682
+ _make_timestamp("try_make_timestamp", parts, date, time, timezone, allow_timezone: true)
683
+ end
196
684
 
197
- def array_contains(col, value) = Column.invoke("array_contains", _col(col), lit(value))
198
- def array_position(col, value) = Column.invoke("array_position", _col(col), lit(value))
199
- def array_remove(col, element) = Column.invoke("array_remove", _col(col), lit(element))
200
- def array_repeat(col, count) = Column.invoke("array_repeat", _col(col), lit(count))
201
- def array_append(col, value) = Column.invoke("array_append", _col(col), lit(value))
202
- def array_prepend(col, value) = Column.invoke("array_prepend", _col(col), lit(value))
203
- def array_insert(col, pos, value) = Column.invoke("array_insert", _col(col), lit(pos), lit(value))
685
+ # A TIMESTAMP_NTZ from `(years, months, days, hours, mins, secs)` or `(date:, time:)`.
686
+ # @return [Column]
687
+ def make_timestamp_ntz(*parts, date: nil, time: nil)
688
+ _make_timestamp("make_timestamp_ntz", parts, date, time, nil, allow_timezone: false)
689
+ end
204
690
 
205
- def array_join(col, delimiter, null_replacement = nil)
206
- if null_replacement.nil?
207
- Column.invoke("array_join", _col(col),
208
- lit(delimiter))
209
- else
210
- Column.invoke("array_join", _col(col), lit(delimiter), lit(null_replacement))
211
- end
691
+ # Like {make_timestamp_ntz} but null on invalid input.
692
+ # @return [Column]
693
+ def try_make_timestamp_ntz(*parts, date: nil, time: nil)
694
+ _make_timestamp("try_make_timestamp_ntz", parts, date, time, nil, allow_timezone: false)
212
695
  end
213
696
 
214
- def element_at(col, extraction) = Column.invoke("element_at", _col(col), lit(extraction))
215
- def slice(col, start, length) = Column.invoke("slice", _col(col), _lit_or_col(start), _lit_or_col(length))
697
+ # The current time of day (TIME type, Spark 4.1+), optionally with a
698
+ # literal fractional-seconds `precision` (0-6).
699
+ # @return [Column]
700
+ def current_time(precision = nil) = precision.nil? ? Column.invoke("current_time") : Column.invoke("current_time", lit(precision))
701
+
702
+ # Add `quantity` units (a literal such as `"HOUR"`) to `ts`.
703
+ # @return [Column]
704
+ def timestamp_add(unit, quantity, ts) = Column.invoke("timestampadd", lit(unit), _col(quantity), _col(ts))
705
+
706
+ # The difference between two timestamps in the literal `unit`.
707
+ # @return [Column]
708
+ def timestamp_diff(unit, start, end_) = Column.invoke("timestampdiff", lit(unit), _col(start), _col(end_))
216
709
 
217
- def sequence(start, stop, step = nil)
218
- step.nil? ? Column.invoke("sequence", _col(start), _col(stop)) : Column.invoke("sequence", _col(start), _col(stop), _col(step))
710
+ # Convert `source_ts` from `source_tz` (or the session time zone when nil)
711
+ # to `target_tz`. Time zones are Columns (e.g. `F.lit("UTC")`) or column names.
712
+ # @return [Column]
713
+ def convert_timezone(source_tz, target_tz, source_ts)
714
+ source_tz.nil? ? _invoke("convert_timezone", target_tz, source_ts) : _invoke("convert_timezone", source_tz, target_tz, source_ts)
219
715
  end
220
716
 
221
- def map_contains_key(col, key) = Column.invoke("map_contains_key", _col(col), lit(key))
717
+ # Bucketize rows into (tumbling or sliding) time windows.
718
+ #
719
+ # @param time_column [Column, String]
720
+ # @param window_duration [String] e.g. `"10 minutes"`.
721
+ # @param slide_duration [String, nil] sliding interval (tumbling when nil).
722
+ # @param start_time [String, nil] offset of window starts.
723
+ # @return [Column]
724
+ def window(time_column, window_duration, slide_duration = nil, start_time = nil)
725
+ _check_str("window_duration", window_duration)
726
+ _check_str("slide_duration", slide_duration) unless slide_duration.nil?
727
+ _check_str("start_time", start_time) unless start_time.nil?
728
+ args = [_col(time_column), lit(window_duration)]
729
+ if slide_duration && start_time then args += [lit(slide_duration), lit(start_time)]
730
+ elsif slide_duration then args << lit(slide_duration)
731
+ elsif start_time then args += [lit(window_duration), lit(start_time)]
732
+ end
733
+ Column.invoke("window", *args)
734
+ end
222
735
 
223
- # ---- Window / analytic functions --------------------------------------
736
+ # Bucketize rows into session windows closed after a gap of inactivity.
737
+ # @param gap_duration [String, Column] e.g. `"5 minutes"` (a literal) or a Column.
738
+ # @return [Column]
739
+ def session_window(time_column, gap_duration)
740
+ _check_str_or_col("gap_duration", gap_duration)
741
+ Column.invoke("session_window", _col(time_column), lit(gap_duration))
742
+ end
224
743
 
225
- def lag(col, offset = 1, default = nil) = Column.invoke("lag", _col(col), lit(offset), lit(default))
226
- def lead(col, offset = 1, default = nil) = Column.invoke("lead", _col(col), lit(offset), lit(default))
227
- def ntile(n) = Column.invoke("ntile", lit(n))
228
- def nth_value(col, offset, ignore_nulls = false) = Column.invoke("nth_value", _col(col), lit(offset), lit(ignore_nulls))
744
+ # The `bucket(num_buckets, col)` partition transform for
745
+ # {DataFrameWriterV2#partitioned_by}.
746
+ # @param num_buckets [Integer, Column]
747
+ # @return [Column]
748
+ def bucket(num_buckets, col)
749
+ unless num_buckets.is_a?(Integer) || num_buckets.is_a?(Column)
750
+ raise IllegalArgumentError, "bucket num_buckets must be an Integer or Column, got #{num_buckets.class}"
751
+ end
229
752
 
230
- # ---- Sorting helpers ---------------------------------------------------
753
+ Column.invoke("bucket", lit(num_buckets), _col(col))
754
+ end
231
755
 
232
- def sort_array(col, asc = true) = Column.invoke("sort_array", _col(col), lit(asc))
756
+ # ---- JSON / CSV / XML --------------------------------------------------
233
757
 
234
- # ---- Randomness --------------------------------------------------------
758
+ # @return [Column] the value at the literal JSON `path` in `col`.
759
+ def get_json_object(col, path) = Column.invoke("get_json_object", _col(col), lit(path))
235
760
 
236
- def rand(seed = nil) = seed.nil? ? Column.invoke("rand") : Column.invoke("rand", lit(seed))
237
- def randn(seed = nil) = seed.nil? ? Column.invoke("randn") : Column.invoke("randn", lit(seed))
761
+ # @return [Column] the given top-level literal `fields` of a JSON string.
762
+ def json_tuple(col, *fields)
763
+ raise IllegalArgumentError, "json_tuple requires at least one field" if fields.empty?
238
764
 
239
- # ---- Higher-order (lambda) functions -----------------------------------
765
+ Column.invoke("json_tuple", _col(col), *fields.map { |f| lit(f) })
766
+ end
240
767
 
241
- # Transform each element of an array. The block receives a {Column} (and
242
- # optionally the index) and returns a {Column}.
243
- # @yieldparam element [Column]
768
+ # Parse a JSON string column into a struct/array/map.
769
+ # @param schema [Types::DataType, String, Column] a DataType, or a DDL/JSON schema string (a literal).
770
+ # @param options [Hash, nil] JSON options.
244
771
  # @return [Column]
245
- def transform(col, &block) = Column.invoke("transform", _col(col), _lambda(block))
246
- def exists(col, &block) = Column.invoke("exists", _col(col), _lambda(block))
247
- def forall(col, &block) = Column.invoke("forall", _col(col), _lambda(block))
248
- def filter(col, &block) = Column.invoke("filter", _col(col), _lambda(block))
249
- def zip_with(left, right, &block) = Column.invoke("zip_with", _col(left), _col(right), _lambda(block))
250
- def transform_keys(col, &block) = Column.invoke("transform_keys", _col(col), _lambda(block))
251
- def transform_values(col, &block) = Column.invoke("transform_values", _col(col), _lambda(block))
252
- def map_filter(col, &block) = Column.invoke("map_filter", _col(col), _lambda(block))
253
- def map_zip_with(c1, c2, &block) = Column.invoke("map_zip_with", _col(c1), _col(c2), _lambda(block))
772
+ def from_json(col, schema, options = nil) = _from_text("from_json", col, _schema_literal(schema), options)
254
773
 
255
- # Aggregate (fold) an array. `merge` combines accumulator and element;
256
- # optional `finish` post-processes the result.
774
+ # @param options [Hash, nil] JSON options.
775
+ # @return [Column] `col` (a struct/array/map) as a JSON string.
776
+ def to_json(col, options = nil) = _with_options("to_json", [_col(col)], options)
777
+
778
+ # @param json [String, Column] a literal JSON sample.
779
+ # @return [Column] the DDL schema of `json`.
780
+ def schema_of_json(json, options = nil) = _schema_of("schema_of_json", "json", json, options)
781
+
782
+ # Parse a CSV string column into a struct.
783
+ # @param schema [String, Column] a DDL schema string (a literal) or Column.
257
784
  # @return [Column]
258
- def aggregate(col, initial, merge, finish = nil)
259
- args = [_col(col), _col(initial), _lambda(merge)]
260
- args << _lambda(finish) if finish
261
- Column.invoke("aggregate", *args)
785
+ def from_csv(col, schema, options = nil)
786
+ _check_str_or_col("schema", schema)
787
+ _from_text("from_csv", col, lit(schema), options)
262
788
  end
263
789
 
264
- # ---- DataFrame-level helper -------------------------------------------
790
+ # @return [Column] `col` (a struct) as a CSV string.
791
+ def to_csv(col, options = nil) = _with_options("to_csv", [_col(col)], options)
265
792
 
266
- # Mark a DataFrame for broadcast (map-side) join.
267
- # @param df [DataFrame]
268
- # @return [DataFrame]
269
- def broadcast(df) = df.hint("broadcast")
793
+ # @param csv [String, Column] a literal CSV sample.
794
+ # @return [Column] the DDL schema of `csv`.
795
+ def schema_of_csv(csv, options = nil) = _schema_of("schema_of_csv", "csv", csv, options)
270
796
 
271
- # UDFs require a server-side execution environment (Python/Scala) and are not
272
- # supported by the pure-Ruby client.
273
- def udf(*)
274
- raise NotImplementedError, "User-defined functions are not supported by the Ruby Spark Connect client"
275
- end
797
+ # Parse an XML string column into a struct.
798
+ # @param schema [Types::StructType, String, Column] a StructType, or a DDL/JSON schema string (a literal).
799
+ # @return [Column]
800
+ def from_xml(col, schema, options = nil) = _from_text("from_xml", col, _schema_literal(schema), options)
276
801
 
277
- # The following functions are generated programmatically below
278
- # (`UNIFORM` and `NO_ARG`). The `@!method` directives document them so they
279
- # appear in the API reference; each returns a {Column}.
280
- #
281
- # @!method sum(*cols)
282
- # The Spark SQL `sum` function. String arguments are treated as column names.
283
- # @return [Column]
284
- # @!method avg(*cols)
285
- # The Spark SQL `avg` function. String arguments are treated as column names.
286
- # @return [Column]
287
- # @!method mean(*cols)
288
- # The Spark SQL `mean` function. String arguments are treated as column names.
289
- # @return [Column]
290
- # @!method max(*cols)
291
- # The Spark SQL `max` function. String arguments are treated as column names.
802
+ # @return [Column] `col` (a struct) as an XML string.
803
+ def to_xml(col, options = nil) = _with_options("to_xml", [_col(col)], options)
804
+
805
+ # @param xml [String, Column] a literal XML sample.
806
+ # @return [Column] the DDL schema of `xml`.
807
+ def schema_of_xml(xml, options = nil) = _schema_of("schema_of_xml", "xml", xml, options)
808
+
809
+ # ---- Variant -----------------------------------------------------------
810
+
811
+ # Extract the value at `path` of a VARIANT column, cast to the literal `target_type`.
812
+ # @param path [String, Column] a literal path (e.g. `"$.a"`) or a Column.
813
+ # @return [Column]
814
+ def variant_get(v, path, target_type) = Column.invoke("variant_get", _col(v), lit(path), lit(target_type))
815
+ # Like {variant_get} but null on cast failure.
816
+ # @return [Column]
817
+ def try_variant_get(v, path, target_type) = Column.invoke("try_variant_get", _col(v), lit(path), lit(target_type))
818
+
819
+ # Append `value` to the array at `path` of a VARIANT (Spark 4.3+).
820
+ # @return [Column]
821
+ def variant_array_append(v, path, value) = Column.invoke("variant_array_append", _col(v), lit(path), _col(value))
822
+ # Like {variant_array_append} but null on failure.
823
+ # @return [Column]
824
+ def try_variant_array_append(v, path, value) = Column.invoke("try_variant_array_append", _col(v), lit(path), _col(value))
825
+ # Insert `value` at `path` of a VARIANT (Spark 4.3+).
826
+ # @return [Column]
827
+ def variant_insert(v, path, value) = Column.invoke("variant_insert", _col(v), lit(path), _col(value))
828
+ # Like {variant_insert} but null on failure.
829
+ # @return [Column]
830
+ def try_variant_insert(v, path, value) = Column.invoke("try_variant_insert", _col(v), lit(path), _col(value))
831
+
832
+ # Set `value` at `path` of a VARIANT, creating missing parents unless
833
+ # `create_if_missing` is false (Spark 4.3+).
834
+ # @return [Column]
835
+ def variant_set(v, path, value, create_if_missing = true)
836
+ Column.invoke("variant_set", _col(v), lit(path), _col(value), lit(create_if_missing))
837
+ end
838
+
839
+ # Like {variant_set} but null on failure.
840
+ # @return [Column]
841
+ def try_variant_set(v, path, value, create_if_missing = true)
842
+ Column.invoke("try_variant_set", _col(v), lit(path), _col(value), lit(create_if_missing))
843
+ end
844
+
845
+ # Delete one or more `paths` (literals or Columns) from a VARIANT (Spark 4.3+).
846
+ # @return [Column]
847
+ def variant_delete(v, *paths)
848
+ raise IllegalArgumentError, "variant_delete requires at least one path" if paths.empty?
849
+
850
+ Column.invoke("variant_delete", _col(v), *paths.map { |p| lit(p) })
851
+ end
852
+
853
+ # Remove null object fields (and, unless `include_arrays` is false, null
854
+ # array elements) from a VARIANT (Spark 4.3+).
855
+ # @return [Column]
856
+ def variant_strip_nulls(v, include_arrays = true) = Column.invoke("variant_strip_nulls", _col(v), lit(include_arrays))
857
+
858
+ # ---- Array / map functions ---------------------------------------------
859
+
860
+ # @return [Column] whether the array contains the literal `value`.
861
+ def array_contains(col, value) = Column.invoke("array_contains", _col(col), lit(value))
862
+ # @return [Column] the 1-based position of the literal `value` in the array (0 if absent).
863
+ def array_position(col, value) = Column.invoke("array_position", _col(col), lit(value))
864
+ # @return [Column] the array without the literal `element`.
865
+ def array_remove(col, element) = Column.invoke("array_remove", _col(col), lit(element))
866
+ # @param count [Integer, Column, String] Strings are column names.
867
+ # @return [Column] an array with `col` repeated `count` times.
868
+ def array_repeat(col, count) = _invoke("array_repeat", col, count)
869
+ # @return [Column] the array with the literal `value` appended.
870
+ def array_append(col, value) = Column.invoke("array_append", _col(col), lit(value))
871
+ # @return [Column] the array with the literal `value` prepended.
872
+ def array_prepend(col, value) = Column.invoke("array_prepend", _col(col), lit(value))
873
+ # @param pos [Integer, Column, String] 1-based position; Strings are column names.
874
+ # @return [Column] the array with the literal `value` inserted at `pos`.
875
+ def array_insert(col, pos, value) = Column.invoke("array_insert", _col(col), _col(pos), lit(value))
876
+
877
+ # @return [Column] the array elements joined by the literal `delimiter`.
878
+ def array_join(col, delimiter, null_replacement = nil)
879
+ if null_replacement.nil?
880
+ Column.invoke("array_join", _col(col), lit(delimiter))
881
+ else
882
+ Column.invoke("array_join", _col(col), lit(delimiter), lit(null_replacement))
883
+ end
884
+ end
885
+
886
+ # @return [Column] the element at the literal 1-based index (or map key) `extraction`.
887
+ def element_at(col, extraction) = Column.invoke("element_at", _col(col), lit(extraction))
888
+
889
+ # @param start [Integer, Column, String] Strings are column names.
890
+ # @param length [Integer, Column, String] Strings are column names.
891
+ # @return [Column] a sub-array from 1-based `start` of `length` elements.
892
+ def slice(col, start, length)
893
+ [start, length].each do |v|
894
+ next if v.is_a?(Integer) || v.is_a?(Column) || v.is_a?(String) || v.is_a?(Symbol)
895
+
896
+ raise IllegalArgumentError, "slice start/length must be an Integer, Column, or String, got #{v.class}"
897
+ end
898
+ _invoke("slice", col, start, length)
899
+ end
900
+
901
+ # @return [Column] an array from `start` to `stop` (inclusive), by `step`.
902
+ def sequence(start, stop, step = nil) = step.nil? ? _invoke("sequence", start, stop) : _invoke("sequence", start, stop, step)
903
+
904
+ # @return [Column] whether the map contains the literal `key`.
905
+ def map_contains_key(col, key) = Column.invoke("map_contains_key", _col(col), lit(key))
906
+
907
+ # The element at 0-based `index` (null when out of bounds).
908
+ # @param index [Integer, Column, String] Strings are column names.
909
+ # @return [Column]
910
+ def get(col, index) = _invoke("get", col, index)
911
+
912
+ # Sort an array ascending (nulls last), or with a comparator lambda/block
913
+ # returning a negative, zero, or positive integer.
914
+ #
915
+ # @example
916
+ # F.array_sort("arr") { |l, r| F.when(l < r, 1).otherwise(-1) }
917
+ # @return [Column]
918
+ def array_sort(col, comparator = nil, &block)
919
+ fn = comparator || block
920
+ fn ? Column.invoke("array_sort", _col(col), _lambda(fn)) : _invoke("array_sort", col)
921
+ end
922
+
923
+ # A random permutation of an array.
924
+ # @param seed [Integer, Column, nil] random seed (generated when omitted).
925
+ # @note The seeded form requires a Spark 4.0+ server.
926
+ # @return [Column]
927
+ def shuffle(col, seed = nil) = Column.invoke("shuffle", _col(col), _seed(seed))
928
+
929
+ # @return [Column] the array sorted (ascending unless `asc` is false).
930
+ def sort_array(col, asc = true) = Column.invoke("sort_array", _col(col), lit(asc))
931
+
932
+ # ---- Window / analytic functions --------------------------------------
933
+
934
+ # @return [Column] the value `offset` rows before the current row (or `default`).
935
+ def lag(col, offset = 1, default = nil) = _offset_fn("lag", col, offset, default)
936
+ # @return [Column] the value `offset` rows after the current row (or `default`).
937
+ def lead(col, offset = 1, default = nil) = _offset_fn("lead", col, offset, default)
938
+ # @return [Column] the n-tile group id (1..n) of the row.
939
+ def ntile(n) = Column.invoke("ntile", lit(n))
940
+
941
+ # @return [Column] the value at the `offset`-th row of the window frame.
942
+ def nth_value(col, offset, ignore_nulls = false)
943
+ args = [_col(col), lit(offset)]
944
+ args << lit(ignore_nulls) unless ignore_nulls.nil?
945
+ Column.invoke("nth_value", *args)
946
+ end
947
+
948
+ # ---- Randomness --------------------------------------------------------
949
+
950
+ # Uniformly distributed values in [0.0, 1.0).
951
+ # @param seed [Integer, nil] random seed (generated when omitted).
952
+ # @return [Column]
953
+ def rand(seed = nil) = Column.invoke("rand", _seed(seed))
954
+ alias random rand
955
+
956
+ # Standard-normal distributed values.
957
+ # @param seed [Integer, nil] random seed (generated when omitted).
958
+ # @return [Column]
959
+ def randn(seed = nil) = Column.invoke("randn", _seed(seed))
960
+
961
+ # A random UUID string per row.
962
+ # @param seed [Integer, Column, nil] random seed (generated when omitted).
963
+ # @note Requires a Spark 4.0+ server, since a seed is always sent.
964
+ # @return [Column]
965
+ def uuid(seed = nil) = Column.invoke("uuid", _seed(seed))
966
+
967
+ # A random alphanumeric string of the literal `length`.
968
+ # @param seed [Integer, Column, nil] random seed (generated when omitted).
969
+ # @return [Column]
970
+ def randstr(length, seed = nil) = Column.invoke("randstr", lit(length), _seed(seed))
971
+
972
+ # Uniformly distributed values in [`min`, `max`) (literals or Columns).
973
+ # @param seed [Integer, Column, nil] random seed (generated when omitted).
974
+ # @return [Column]
975
+ def uniform(min, max, seed = nil) = Column.invoke("uniform", lit(min), lit(max), _seed(seed))
976
+
977
+ # ---- Higher-order (lambda) functions -----------------------------------
978
+
979
+ # Transform each element of an array. The block receives a {Column} (and
980
+ # optionally the index) and returns a {Column}.
981
+ # @yieldparam element [Column]
982
+ # @return [Column]
983
+ def transform(col, &block) = Column.invoke("transform", _col(col), _lambda(block))
984
+ # @return [Column] whether any element satisfies the block.
985
+ def exists(col, &block) = Column.invoke("exists", _col(col), _lambda(block))
986
+ # @return [Column] whether every element satisfies the block.
987
+ def forall(col, &block) = Column.invoke("forall", _col(col), _lambda(block))
988
+ # @return [Column] the elements satisfying the block (which may take the index too).
989
+ def filter(col, &block) = Column.invoke("filter", _col(col), _lambda(block))
990
+ # @return [Column] two arrays merged element-wise by the block.
991
+ def zip_with(left, right, &block) = Column.invoke("zip_with", _col(left), _col(right), _lambda(block))
992
+ # @return [Column] the map with keys transformed by the block `(k, v) -> k'`.
993
+ def transform_keys(col, &block) = Column.invoke("transform_keys", _col(col), _lambda(block))
994
+ # @return [Column] the map with values transformed by the block `(k, v) -> v'`.
995
+ def transform_values(col, &block) = Column.invoke("transform_values", _col(col), _lambda(block))
996
+ # @return [Column] the map entries satisfying the block `(k, v) -> bool`.
997
+ def map_filter(col, &block) = Column.invoke("map_filter", _col(col), _lambda(block))
998
+ # @return [Column] two maps merged by key with the block `(k, v1, v2) -> v`.
999
+ def map_zip_with(c1, c2, &block) = Column.invoke("map_zip_with", _col(c1), _col(c2), _lambda(block))
1000
+
1001
+ # Aggregate (fold) an array. `merge` combines accumulator and element;
1002
+ # optional `finish` post-processes the result.
1003
+ # @return [Column]
1004
+ def aggregate(col, initial, merge, finish = nil) = _fold("aggregate", col, initial, merge, finish)
1005
+
1006
+ # Alias of {aggregate} under the `reduce` SQL name.
1007
+ # @return [Column]
1008
+ def reduce(col, initial, merge, finish = nil) = _fold("reduce", col, initial, merge, finish)
1009
+
1010
+ # ---- Geospatial --------------------------------------------------------
1011
+
1012
+ # The WKB of a GEOMETRY/GEOGRAPHY value, optionally with an `endianness`
1013
+ # (`"NDR"`/`"XDR"`, a literal) (Spark 4.2+).
1014
+ # @return [Column]
1015
+ def st_asbinary(geo, endianness = nil)
1016
+ return _invoke("st_asbinary", geo) if endianness.nil?
1017
+
1018
+ Column.invoke("st_asbinary", _col(geo), endianness.is_a?(String) ? lit(endianness) : _col(endianness))
1019
+ end
1020
+
1021
+ # A GEOMETRY from WKB, optionally with a spatial reference id `srid`.
1022
+ # @param srid [Integer, Column, String, nil] Strings are column names.
1023
+ # @return [Column]
1024
+ def st_geomfromwkb(wkb, srid = nil) = srid.nil? ? _invoke("st_geomfromwkb", wkb) : _invoke("st_geomfromwkb", wkb, srid)
1025
+
1026
+ # A GEOMETRY/GEOGRAPHY with its SRID replaced by `srid`.
1027
+ # @param srid [Integer, Column, String] Strings are column names.
1028
+ # @return [Column]
1029
+ def st_setsrid(geo, srid) = _invoke("st_setsrid", geo, srid)
1030
+
1031
+ # ---- DataFrame-level helper / unsupported ------------------------------
1032
+
1033
+ # Mark a DataFrame for broadcast (map-side) join.
1034
+ # @param df [DataFrame]
1035
+ # @return [DataFrame]
1036
+ def broadcast(df)
1037
+ raise IllegalArgumentError, "broadcast expects a DataFrame, got #{df.class}" unless df.is_a?(DataFrame)
1038
+
1039
+ df.hint("broadcast")
1040
+ end
1041
+
1042
+ # UDFs require a server-side execution environment (Python/Scala) and are not
1043
+ # supported by the pure-Ruby client.
1044
+ def udf(*_args)
1045
+ raise NotImplementedError, "User-defined functions are not supported by the Ruby Spark Connect client"
1046
+ end
1047
+
1048
+ # User-defined table functions are not supported by the pure-Ruby client.
1049
+ def udtf(*_args)
1050
+ raise NotImplementedError, "User-defined table functions are not supported by the Ruby Spark Connect client"
1051
+ end
1052
+
1053
+ # Arrow user-defined table functions are not supported by the pure-Ruby client.
1054
+ def arrow_udtf(*_args)
1055
+ raise NotImplementedError, "User-defined table functions are not supported by the Ruby Spark Connect client"
1056
+ end
1057
+
1058
+ # The following functions are generated programmatically below
1059
+ # (`UNIFORM` and `NO_ARG`). The `@!method` directives document them so they
1060
+ # appear in the API reference; each returns a {Column}.
1061
+ #
1062
+ # @!method abs(*cols)
1063
+ # The Spark SQL `abs` function. String arguments are treated as column names.
292
1064
  # @return [Column]
293
- # @!method min(*cols)
294
- # The Spark SQL `min` function. String arguments are treated as column names.
1065
+ # @!method acos(*cols)
1066
+ # The Spark SQL `acos` function. String arguments are treated as column names.
295
1067
  # @return [Column]
296
- # @!method first(*cols)
297
- # The Spark SQL `first` function. String arguments are treated as column names.
1068
+ # @!method acosh(*cols)
1069
+ # The Spark SQL `acosh` function. String arguments are treated as column names.
298
1070
  # @return [Column]
299
- # @!method last(*cols)
300
- # The Spark SQL `last` function. String arguments are treated as column names.
1071
+ # @!method any_value(*cols)
1072
+ # The Spark SQL `any_value` function. String arguments are treated as column names.
301
1073
  # @return [Column]
302
- # @!method stddev(*cols)
303
- # The Spark SQL `stddev` function. String arguments are treated as column names.
1074
+ # @!method array_agg(*cols)
1075
+ # The Spark SQL `array_agg` function. String arguments are treated as column names.
304
1076
  # @return [Column]
305
- # @!method stddev_samp(*cols)
306
- # The Spark SQL `stddev_samp` function. String arguments are treated as column names.
1077
+ # @!method array_compact(*cols)
1078
+ # The Spark SQL `array_compact` function. String arguments are treated as column names.
307
1079
  # @return [Column]
308
- # @!method stddev_pop(*cols)
309
- # The Spark SQL `stddev_pop` function. String arguments are treated as column names.
1080
+ # @!method array_distinct(*cols)
1081
+ # The Spark SQL `array_distinct` function. String arguments are treated as column names.
310
1082
  # @return [Column]
311
- # @!method variance(*cols)
312
- # The Spark SQL `variance` function. String arguments are treated as column names.
1083
+ # @!method array_except(*cols)
1084
+ # The Spark SQL `array_except` function. String arguments are treated as column names.
313
1085
  # @return [Column]
314
- # @!method var_samp(*cols)
315
- # The Spark SQL `var_samp` function. String arguments are treated as column names.
1086
+ # @!method array_intersect(*cols)
1087
+ # The Spark SQL `array_intersect` function. String arguments are treated as column names.
316
1088
  # @return [Column]
317
- # @!method var_pop(*cols)
318
- # The Spark SQL `var_pop` function. String arguments are treated as column names.
1089
+ # @!method array_max(*cols)
1090
+ # The Spark SQL `array_max` function. String arguments are treated as column names.
319
1091
  # @return [Column]
320
- # @!method skewness(*cols)
321
- # The Spark SQL `skewness` function. String arguments are treated as column names.
1092
+ # @!method array_min(*cols)
1093
+ # The Spark SQL `array_min` function. String arguments are treated as column names.
322
1094
  # @return [Column]
323
- # @!method kurtosis(*cols)
324
- # The Spark SQL `kurtosis` function. String arguments are treated as column names.
1095
+ # @!method array_size(*cols)
1096
+ # The Spark SQL `array_size` function. String arguments are treated as column names.
1097
+ # @return [Column]
1098
+ # @!method array_union(*cols)
1099
+ # The Spark SQL `array_union` function. String arguments are treated as column names.
1100
+ # @return [Column]
1101
+ # @!method arrays_overlap(*cols)
1102
+ # The Spark SQL `arrays_overlap` function. String arguments are treated as column names.
1103
+ # @return [Column]
1104
+ # @!method arrays_zip(*cols)
1105
+ # The Spark SQL `arrays_zip` function. String arguments are treated as column names.
1106
+ # @return [Column]
1107
+ # @!method ascii(*cols)
1108
+ # The Spark SQL `ascii` function. String arguments are treated as column names.
1109
+ # @return [Column]
1110
+ # @!method asin(*cols)
1111
+ # The Spark SQL `asin` function. String arguments are treated as column names.
1112
+ # @return [Column]
1113
+ # @!method asinh(*cols)
1114
+ # The Spark SQL `asinh` function. String arguments are treated as column names.
1115
+ # @return [Column]
1116
+ # @!method atan(*cols)
1117
+ # The Spark SQL `atan` function. String arguments are treated as column names.
1118
+ # @return [Column]
1119
+ # @!method atan2(*cols)
1120
+ # The Spark SQL `atan2` function. String arguments are treated as column names.
1121
+ # @return [Column]
1122
+ # @!method atanh(*cols)
1123
+ # The Spark SQL `atanh` function. String arguments are treated as column names.
1124
+ # @return [Column]
1125
+ # @!method avg(*cols)
1126
+ # The Spark SQL `avg` function. String arguments are treated as column names.
1127
+ # @return [Column]
1128
+ # @!method base64(*cols)
1129
+ # The Spark SQL `base64` function. String arguments are treated as column names.
1130
+ # @return [Column]
1131
+ # @!method bin(*cols)
1132
+ # The Spark SQL `bin` function. String arguments are treated as column names.
1133
+ # @return [Column]
1134
+ # @!method bit_and(*cols)
1135
+ # The Spark SQL `bit_and` function. String arguments are treated as column names.
1136
+ # @return [Column]
1137
+ # @!method bit_count(*cols)
1138
+ # The Spark SQL `bit_count` function. String arguments are treated as column names.
1139
+ # @return [Column]
1140
+ # @!method bit_get(*cols)
1141
+ # The Spark SQL `bit_get` function. String arguments are treated as column names.
1142
+ # @return [Column]
1143
+ # @!method bit_length(*cols)
1144
+ # The Spark SQL `bit_length` function. String arguments are treated as column names.
1145
+ # @return [Column]
1146
+ # @!method bit_or(*cols)
1147
+ # The Spark SQL `bit_or` function. String arguments are treated as column names.
1148
+ # @return [Column]
1149
+ # @!method bit_xor(*cols)
1150
+ # The Spark SQL `bit_xor` function. String arguments are treated as column names.
1151
+ # @return [Column]
1152
+ # @!method bitmap_and_agg(*cols)
1153
+ # The Spark SQL `bitmap_and_agg` function. String arguments are treated as column names.
1154
+ # @return [Column]
1155
+ # @!method bitmap_bit_position(*cols)
1156
+ # The Spark SQL `bitmap_bit_position` function. String arguments are treated as column names.
1157
+ # @return [Column]
1158
+ # @!method bitmap_bucket_number(*cols)
1159
+ # The Spark SQL `bitmap_bucket_number` function. String arguments are treated as column names.
1160
+ # @return [Column]
1161
+ # @!method bitmap_construct_agg(*cols)
1162
+ # The Spark SQL `bitmap_construct_agg` function. String arguments are treated as column names.
1163
+ # @return [Column]
1164
+ # @!method bitmap_count(*cols)
1165
+ # The Spark SQL `bitmap_count` function. String arguments are treated as column names.
1166
+ # @return [Column]
1167
+ # @!method bitmap_or_agg(*cols)
1168
+ # The Spark SQL `bitmap_or_agg` function. String arguments are treated as column names.
1169
+ # @return [Column]
1170
+ # @!method bool_and(*cols)
1171
+ # The Spark SQL `bool_and` function. String arguments are treated as column names.
1172
+ # @return [Column]
1173
+ # @!method bool_or(*cols)
1174
+ # The Spark SQL `bool_or` function. String arguments are treated as column names.
1175
+ # @return [Column]
1176
+ # @!method btrim(*cols)
1177
+ # The Spark SQL `btrim` function. String arguments are treated as column names.
1178
+ # @return [Column]
1179
+ # @!method cardinality(*cols)
1180
+ # The Spark SQL `cardinality` function. String arguments are treated as column names.
1181
+ # @return [Column]
1182
+ # @!method cbrt(*cols)
1183
+ # The Spark SQL `cbrt` function. String arguments are treated as column names.
1184
+ # @return [Column]
1185
+ # @!method ceil(*cols)
1186
+ # The Spark SQL `ceil` function. String arguments are treated as column names.
1187
+ # @return [Column]
1188
+ # @!method ceiling(*cols)
1189
+ # The Spark SQL `ceiling` function. String arguments are treated as column names.
1190
+ # @return [Column]
1191
+ # @!method char(*cols)
1192
+ # The Spark SQL `char` function. String arguments are treated as column names.
1193
+ # @return [Column]
1194
+ # @!method char_length(*cols)
1195
+ # The Spark SQL `char_length` function. String arguments are treated as column names.
1196
+ # @return [Column]
1197
+ # @!method character_length(*cols)
1198
+ # The Spark SQL `character_length` function. String arguments are treated as column names.
1199
+ # @return [Column]
1200
+ # @!method chr(*cols)
1201
+ # The Spark SQL `chr` function. String arguments are treated as column names.
1202
+ # @return [Column]
1203
+ # @!method collation(*cols)
1204
+ # The Spark SQL `collation` function. String arguments are treated as column names.
325
1205
  # @return [Column]
326
1206
  # @!method collect_list(*cols)
327
1207
  # The Spark SQL `collect_list` function. String arguments are treated as column names.
@@ -329,171 +1209,459 @@ module SparkConnect
329
1209
  # @!method collect_set(*cols)
330
1210
  # The Spark SQL `collect_set` function. String arguments are treated as column names.
331
1211
  # @return [Column]
332
- # @!method first_value(*cols)
333
- # The Spark SQL `first_value` function. String arguments are treated as column names.
1212
+ # @!method collect_union(*cols)
1213
+ # The Spark SQL `collect_union` function. String arguments are treated as column names.
1214
+ # @return [Column]
1215
+ # @!method concat(*cols)
1216
+ # The Spark SQL `concat` function. String arguments are treated as column names.
1217
+ # @return [Column]
1218
+ # @!method contains(*cols)
1219
+ # The Spark SQL `contains` function. String arguments are treated as column names.
1220
+ # @return [Column]
1221
+ # @!method corr(*cols)
1222
+ # The Spark SQL `corr` function. String arguments are treated as column names.
1223
+ # @return [Column]
1224
+ # @!method cos(*cols)
1225
+ # The Spark SQL `cos` function. String arguments are treated as column names.
1226
+ # @return [Column]
1227
+ # @!method cosh(*cols)
1228
+ # The Spark SQL `cosh` function. String arguments are treated as column names.
1229
+ # @return [Column]
1230
+ # @!method cot(*cols)
1231
+ # The Spark SQL `cot` function. String arguments are treated as column names.
1232
+ # @return [Column]
1233
+ # @!method count_if(*cols)
1234
+ # The Spark SQL `count_if` function. String arguments are treated as column names.
1235
+ # @return [Column]
1236
+ # @!method counter_diff(*cols)
1237
+ # The Spark SQL `counter_diff` function. String arguments are treated as column names.
1238
+ # @return [Column]
1239
+ # @!method covar_pop(*cols)
1240
+ # The Spark SQL `covar_pop` function. String arguments are treated as column names.
1241
+ # @return [Column]
1242
+ # @!method covar_samp(*cols)
1243
+ # The Spark SQL `covar_samp` function. String arguments are treated as column names.
1244
+ # @return [Column]
1245
+ # @!method crc32(*cols)
1246
+ # The Spark SQL `crc32` function. String arguments are treated as column names.
1247
+ # @return [Column]
1248
+ # @!method csc(*cols)
1249
+ # The Spark SQL `csc` function. String arguments are treated as column names.
1250
+ # @return [Column]
1251
+ # @!method date_diff(*cols)
1252
+ # The Spark SQL `date_diff` function. String arguments are treated as column names.
1253
+ # @return [Column]
1254
+ # @!method date_from_unix_date(*cols)
1255
+ # The Spark SQL `date_from_unix_date` function. String arguments are treated as column names.
1256
+ # @return [Column]
1257
+ # @!method date_part(*cols)
1258
+ # The Spark SQL `date_part` function. String arguments are treated as column names.
1259
+ # @return [Column]
1260
+ # @!method datepart(*cols)
1261
+ # The Spark SQL `datepart` function. String arguments are treated as column names.
1262
+ # @return [Column]
1263
+ # @!method day(*cols)
1264
+ # The Spark SQL `day` function. String arguments are treated as column names.
1265
+ # @return [Column]
1266
+ # @!method dayname(*cols)
1267
+ # The Spark SQL `dayname` function. String arguments are treated as column names.
1268
+ # @return [Column]
1269
+ # @!method dayofmonth(*cols)
1270
+ # The Spark SQL `dayofmonth` function. String arguments are treated as column names.
1271
+ # @return [Column]
1272
+ # @!method dayofweek(*cols)
1273
+ # The Spark SQL `dayofweek` function. String arguments are treated as column names.
1274
+ # @return [Column]
1275
+ # @!method dayofyear(*cols)
1276
+ # The Spark SQL `dayofyear` function. String arguments are treated as column names.
1277
+ # @return [Column]
1278
+ # @!method days(*cols)
1279
+ # The Spark SQL `days` function. String arguments are treated as column names.
1280
+ # @return [Column]
1281
+ # @!method degrees(*cols)
1282
+ # The Spark SQL `degrees` function. String arguments are treated as column names.
1283
+ # @return [Column]
1284
+ # @!method elt(*cols)
1285
+ # The Spark SQL `elt` function. String arguments are treated as column names.
1286
+ # @return [Column]
1287
+ # @!method endswith(*cols)
1288
+ # The Spark SQL `endswith` function. String arguments are treated as column names.
1289
+ # @return [Column]
1290
+ # @!method equal_null(*cols)
1291
+ # The Spark SQL `equal_null` function. String arguments are treated as column names.
1292
+ # @return [Column]
1293
+ # @!method every(*cols)
1294
+ # The Spark SQL `every` function. String arguments are treated as column names.
1295
+ # @return [Column]
1296
+ # @!method exp(*cols)
1297
+ # The Spark SQL `exp` function. String arguments are treated as column names.
1298
+ # @return [Column]
1299
+ # @!method explode(*cols)
1300
+ # The Spark SQL `explode` function. String arguments are treated as column names.
1301
+ # @return [Column]
1302
+ # @!method explode_outer(*cols)
1303
+ # The Spark SQL `explode_outer` function. String arguments are treated as column names.
1304
+ # @return [Column]
1305
+ # @!method expm1(*cols)
1306
+ # The Spark SQL `expm1` function. String arguments are treated as column names.
1307
+ # @return [Column]
1308
+ # @!method extract(*cols)
1309
+ # The Spark SQL `extract` function. String arguments are treated as column names.
1310
+ # @return [Column]
1311
+ # @!method factorial(*cols)
1312
+ # The Spark SQL `factorial` function. String arguments are treated as column names.
1313
+ # @return [Column]
1314
+ # @!method find_in_set(*cols)
1315
+ # The Spark SQL `find_in_set` function. String arguments are treated as column names.
1316
+ # @return [Column]
1317
+ # @!method first_value(*cols)
1318
+ # The Spark SQL `first_value` function. String arguments are treated as column names.
1319
+ # @return [Column]
1320
+ # @!method flatten(*cols)
1321
+ # The Spark SQL `flatten` function. String arguments are treated as column names.
1322
+ # @return [Column]
1323
+ # @!method floor(*cols)
1324
+ # The Spark SQL `floor` function. String arguments are treated as column names.
1325
+ # @return [Column]
1326
+ # @!method from_base32(*cols)
1327
+ # The Spark SQL `from_base32` function. String arguments are treated as column names.
1328
+ # @return [Column]
1329
+ # @!method getbit(*cols)
1330
+ # The Spark SQL `getbit` function. String arguments are treated as column names.
1331
+ # @return [Column]
1332
+ # @!method grouping(*cols)
1333
+ # The Spark SQL `grouping` function. String arguments are treated as column names.
1334
+ # @return [Column]
1335
+ # @!method grouping_id(*cols)
1336
+ # The Spark SQL `grouping_id` function. String arguments are treated as column names.
1337
+ # @return [Column]
1338
+ # @!method hash(*cols)
1339
+ # The Spark SQL `hash` function. String arguments are treated as column names.
1340
+ # @return [Column]
1341
+ # @!method hex(*cols)
1342
+ # The Spark SQL `hex` function. String arguments are treated as column names.
1343
+ # @return [Column]
1344
+ # @!method histogram_numeric(*cols)
1345
+ # The Spark SQL `histogram_numeric` function. String arguments are treated as column names.
1346
+ # @return [Column]
1347
+ # @!method hll_sketch_estimate(*cols)
1348
+ # The Spark SQL `hll_sketch_estimate` function. String arguments are treated as column names.
1349
+ # @return [Column]
1350
+ # @!method hmac(*cols)
1351
+ # The Spark SQL `hmac` function. String arguments are treated as column names.
1352
+ # @return [Column]
1353
+ # @!method hour(*cols)
1354
+ # The Spark SQL `hour` function. String arguments are treated as column names.
1355
+ # @return [Column]
1356
+ # @!method hours(*cols)
1357
+ # The Spark SQL `hours` function. String arguments are treated as column names.
1358
+ # @return [Column]
1359
+ # @!method hypot(*cols)
1360
+ # The Spark SQL `hypot` function. String arguments are treated as column names.
1361
+ # @return [Column]
1362
+ # @!method ifnull(*cols)
1363
+ # The Spark SQL `ifnull` function. String arguments are treated as column names.
1364
+ # @return [Column]
1365
+ # @!method ilike(*cols)
1366
+ # The Spark SQL `ilike` function. String arguments are treated as column names.
1367
+ # @return [Column]
1368
+ # @!method initcap(*cols)
1369
+ # The Spark SQL `initcap` function. String arguments are treated as column names.
1370
+ # @return [Column]
1371
+ # @!method inline(*cols)
1372
+ # The Spark SQL `inline` function. String arguments are treated as column names.
1373
+ # @return [Column]
1374
+ # @!method inline_outer(*cols)
1375
+ # The Spark SQL `inline_outer` function. String arguments are treated as column names.
1376
+ # @return [Column]
1377
+ # @!method is_valid_utf8(*cols)
1378
+ # The Spark SQL `is_valid_utf8` function. String arguments are treated as column names.
1379
+ # @return [Column]
1380
+ # @!method is_valid_variant(*cols)
1381
+ # The Spark SQL `is_valid_variant` function. String arguments are treated as column names.
1382
+ # @return [Column]
1383
+ # @!method is_variant_null(*cols)
1384
+ # The Spark SQL `is_variant_null` function. String arguments are treated as column names.
1385
+ # @return [Column]
1386
+ # @!method isnan(*cols)
1387
+ # The Spark SQL `isnan` function. String arguments are treated as column names.
1388
+ # @return [Column]
1389
+ # @!method isnotnull(*cols)
1390
+ # The Spark SQL `isnotnull` function. String arguments are treated as column names.
1391
+ # @return [Column]
1392
+ # @!method isnull(*cols)
1393
+ # The Spark SQL `isnull` function. String arguments are treated as column names.
1394
+ # @return [Column]
1395
+ # @!method jaro_winkler_similarity(*cols)
1396
+ # The Spark SQL `jaro_winkler_similarity` function. String arguments are treated as column names.
1397
+ # @return [Column]
1398
+ # @!method java_method(*cols)
1399
+ # The Spark SQL `java_method` function. String arguments are treated as column names.
1400
+ # @return [Column]
1401
+ # @!method json_array_length(*cols)
1402
+ # The Spark SQL `json_array_length` function. String arguments are treated as column names.
1403
+ # @return [Column]
1404
+ # @!method json_object_keys(*cols)
1405
+ # The Spark SQL `json_object_keys` function. String arguments are treated as column names.
1406
+ # @return [Column]
1407
+ # @!method kll_sketch_get_n_bigint(*cols)
1408
+ # The Spark SQL `kll_sketch_get_n_bigint` function. String arguments are treated as column names.
1409
+ # @return [Column]
1410
+ # @!method kll_sketch_get_n_double(*cols)
1411
+ # The Spark SQL `kll_sketch_get_n_double` function. String arguments are treated as column names.
1412
+ # @return [Column]
1413
+ # @!method kll_sketch_get_n_float(*cols)
1414
+ # The Spark SQL `kll_sketch_get_n_float` function. String arguments are treated as column names.
1415
+ # @return [Column]
1416
+ # @!method kll_sketch_get_quantile_bigint(*cols)
1417
+ # The Spark SQL `kll_sketch_get_quantile_bigint` function. String arguments are treated as column names.
1418
+ # @return [Column]
1419
+ # @!method kll_sketch_get_quantile_double(*cols)
1420
+ # The Spark SQL `kll_sketch_get_quantile_double` function. String arguments are treated as column names.
1421
+ # @return [Column]
1422
+ # @!method kll_sketch_get_quantile_float(*cols)
1423
+ # The Spark SQL `kll_sketch_get_quantile_float` function. String arguments are treated as column names.
1424
+ # @return [Column]
1425
+ # @!method kll_sketch_get_rank_bigint(*cols)
1426
+ # The Spark SQL `kll_sketch_get_rank_bigint` function. String arguments are treated as column names.
1427
+ # @return [Column]
1428
+ # @!method kll_sketch_get_rank_double(*cols)
1429
+ # The Spark SQL `kll_sketch_get_rank_double` function. String arguments are treated as column names.
1430
+ # @return [Column]
1431
+ # @!method kll_sketch_get_rank_float(*cols)
1432
+ # The Spark SQL `kll_sketch_get_rank_float` function. String arguments are treated as column names.
1433
+ # @return [Column]
1434
+ # @!method kll_sketch_merge_bigint(*cols)
1435
+ # The Spark SQL `kll_sketch_merge_bigint` function. String arguments are treated as column names.
1436
+ # @return [Column]
1437
+ # @!method kll_sketch_merge_double(*cols)
1438
+ # The Spark SQL `kll_sketch_merge_double` function. String arguments are treated as column names.
1439
+ # @return [Column]
1440
+ # @!method kll_sketch_merge_float(*cols)
1441
+ # The Spark SQL `kll_sketch_merge_float` function. String arguments are treated as column names.
1442
+ # @return [Column]
1443
+ # @!method kll_sketch_to_string_bigint(*cols)
1444
+ # The Spark SQL `kll_sketch_to_string_bigint` function. String arguments are treated as column names.
1445
+ # @return [Column]
1446
+ # @!method kll_sketch_to_string_double(*cols)
1447
+ # The Spark SQL `kll_sketch_to_string_double` function. String arguments are treated as column names.
1448
+ # @return [Column]
1449
+ # @!method kll_sketch_to_string_float(*cols)
1450
+ # The Spark SQL `kll_sketch_to_string_float` function. String arguments are treated as column names.
1451
+ # @return [Column]
1452
+ # @!method kurtosis(*cols)
1453
+ # The Spark SQL `kurtosis` function. String arguments are treated as column names.
1454
+ # @return [Column]
1455
+ # @!method last_day(*cols)
1456
+ # The Spark SQL `last_day` function. String arguments are treated as column names.
1457
+ # @return [Column]
1458
+ # @!method last_value(*cols)
1459
+ # The Spark SQL `last_value` function. String arguments are treated as column names.
1460
+ # @return [Column]
1461
+ # @!method lcase(*cols)
1462
+ # The Spark SQL `lcase` function. String arguments are treated as column names.
1463
+ # @return [Column]
1464
+ # @!method left(*cols)
1465
+ # The Spark SQL `left` function. String arguments are treated as column names.
1466
+ # @return [Column]
1467
+ # @!method length(*cols)
1468
+ # The Spark SQL `length` function. String arguments are treated as column names.
1469
+ # @return [Column]
1470
+ # @!method like(*cols)
1471
+ # The Spark SQL `like` function. String arguments are treated as column names.
1472
+ # @return [Column]
1473
+ # @!method ln(*cols)
1474
+ # The Spark SQL `ln` function. String arguments are treated as column names.
1475
+ # @return [Column]
1476
+ # @!method log10(*cols)
1477
+ # The Spark SQL `log10` function. String arguments are treated as column names.
1478
+ # @return [Column]
1479
+ # @!method log1p(*cols)
1480
+ # The Spark SQL `log1p` function. String arguments are treated as column names.
334
1481
  # @return [Column]
335
- # @!method last_value(*cols)
336
- # The Spark SQL `last_value` function. String arguments are treated as column names.
1482
+ # @!method log2(*cols)
1483
+ # The Spark SQL `log2` function. String arguments are treated as column names.
337
1484
  # @return [Column]
338
- # @!method max_by(*cols)
339
- # The Spark SQL `max_by` function. String arguments are treated as column names.
1485
+ # @!method lower(*cols)
1486
+ # The Spark SQL `lower` function. String arguments are treated as column names.
340
1487
  # @return [Column]
341
- # @!method min_by(*cols)
342
- # The Spark SQL `min_by` function. String arguments are treated as column names.
1488
+ # @!method make_time(*cols)
1489
+ # The Spark SQL `make_time` function. String arguments are treated as column names.
343
1490
  # @return [Column]
344
- # @!method corr(*cols)
345
- # The Spark SQL `corr` function. String arguments are treated as column names.
1491
+ # @!method make_timestamp_ltz(*cols)
1492
+ # The Spark SQL `make_timestamp_ltz` function. String arguments are treated as column names.
346
1493
  # @return [Column]
347
- # @!method covar_pop(*cols)
348
- # The Spark SQL `covar_pop` function. String arguments are treated as column names.
1494
+ # @!method make_valid_utf8(*cols)
1495
+ # The Spark SQL `make_valid_utf8` function. String arguments are treated as column names.
349
1496
  # @return [Column]
350
- # @!method covar_samp(*cols)
351
- # The Spark SQL `covar_samp` function. String arguments are treated as column names.
1497
+ # @!method map_entries(*cols)
1498
+ # The Spark SQL `map_entries` function. String arguments are treated as column names.
352
1499
  # @return [Column]
353
- # @!method median(*cols)
354
- # The Spark SQL `median` function. String arguments are treated as column names.
1500
+ # @!method map_from_entries(*cols)
1501
+ # The Spark SQL `map_from_entries` function. String arguments are treated as column names.
355
1502
  # @return [Column]
356
- # @!method mode(*cols)
357
- # The Spark SQL `mode` function. String arguments are treated as column names.
1503
+ # @!method map_keys(*cols)
1504
+ # The Spark SQL `map_keys` function. String arguments are treated as column names.
358
1505
  # @return [Column]
359
- # @!method any_value(*cols)
360
- # The Spark SQL `any_value` function. String arguments are treated as column names.
1506
+ # @!method map_values(*cols)
1507
+ # The Spark SQL `map_values` function. String arguments are treated as column names.
361
1508
  # @return [Column]
362
- # @!method every(*cols)
363
- # The Spark SQL `every` function. String arguments are treated as column names.
1509
+ # @!method max(*cols)
1510
+ # The Spark SQL `max` function. String arguments are treated as column names.
364
1511
  # @return [Column]
365
- # @!method some(*cols)
366
- # The Spark SQL `some` function. String arguments are treated as column names.
1512
+ # @!method md5(*cols)
1513
+ # The Spark SQL `md5` function. String arguments are treated as column names.
367
1514
  # @return [Column]
368
- # @!method bit_and(*cols)
369
- # The Spark SQL `bit_and` function. String arguments are treated as column names.
1515
+ # @!method median(*cols)
1516
+ # The Spark SQL `median` function. String arguments are treated as column names.
370
1517
  # @return [Column]
371
- # @!method bit_or(*cols)
372
- # The Spark SQL `bit_or` function. String arguments are treated as column names.
1518
+ # @!method min(*cols)
1519
+ # The Spark SQL `min` function. String arguments are treated as column names.
373
1520
  # @return [Column]
374
- # @!method bit_xor(*cols)
375
- # The Spark SQL `bit_xor` function. String arguments are treated as column names.
1521
+ # @!method minute(*cols)
1522
+ # The Spark SQL `minute` function. String arguments are treated as column names.
376
1523
  # @return [Column]
377
- # @!method bool_and(*cols)
378
- # The Spark SQL `bool_and` function. String arguments are treated as column names.
1524
+ # @!method month(*cols)
1525
+ # The Spark SQL `month` function. String arguments are treated as column names.
379
1526
  # @return [Column]
380
- # @!method bool_or(*cols)
381
- # The Spark SQL `bool_or` function. String arguments are treated as column names.
1527
+ # @!method monthname(*cols)
1528
+ # The Spark SQL `monthname` function. String arguments are treated as column names.
382
1529
  # @return [Column]
383
- # @!method product(*cols)
384
- # The Spark SQL `product` function. String arguments are treated as column names.
1530
+ # @!method months(*cols)
1531
+ # The Spark SQL `months` function. String arguments are treated as column names.
385
1532
  # @return [Column]
386
- # @!method count_if(*cols)
387
- # The Spark SQL `count_if` function. String arguments are treated as column names.
1533
+ # @!method negative(*cols)
1534
+ # The Spark SQL `negative` function. String arguments are treated as column names.
388
1535
  # @return [Column]
389
- # @!method grouping(*cols)
390
- # The Spark SQL `grouping` function. String arguments are treated as column names.
1536
+ # @!method nullif(*cols)
1537
+ # The Spark SQL `nullif` function. String arguments are treated as column names.
391
1538
  # @return [Column]
392
- # @!method abs(*cols)
393
- # The Spark SQL `abs` function. String arguments are treated as column names.
1539
+ # @!method nullifzero(*cols)
1540
+ # The Spark SQL `nullifzero` function. String arguments are treated as column names.
394
1541
  # @return [Column]
395
- # @!method acos(*cols)
396
- # The Spark SQL `acos` function. String arguments are treated as column names.
1542
+ # @!method nvl(*cols)
1543
+ # The Spark SQL `nvl` function. String arguments are treated as column names.
397
1544
  # @return [Column]
398
- # @!method acosh(*cols)
399
- # The Spark SQL `acosh` function. String arguments are treated as column names.
1545
+ # @!method nvl2(*cols)
1546
+ # The Spark SQL `nvl2` function. String arguments are treated as column names.
400
1547
  # @return [Column]
401
- # @!method asin(*cols)
402
- # The Spark SQL `asin` function. String arguments are treated as column names.
1548
+ # @!method octet_length(*cols)
1549
+ # The Spark SQL `octet_length` function. String arguments are treated as column names.
403
1550
  # @return [Column]
404
- # @!method asinh(*cols)
405
- # The Spark SQL `asinh` function. String arguments are treated as column names.
1551
+ # @!method parse_json(*cols)
1552
+ # The Spark SQL `parse_json` function. String arguments are treated as column names.
406
1553
  # @return [Column]
407
- # @!method atan(*cols)
408
- # The Spark SQL `atan` function. String arguments are treated as column names.
1554
+ # @!method parse_url(*cols)
1555
+ # The Spark SQL `parse_url` function. String arguments are treated as column names.
409
1556
  # @return [Column]
410
- # @!method atanh(*cols)
411
- # The Spark SQL `atanh` function. String arguments are treated as column names.
1557
+ # @!method pmod(*cols)
1558
+ # The Spark SQL `pmod` function. String arguments are treated as column names.
412
1559
  # @return [Column]
413
- # @!method atan2(*cols)
414
- # The Spark SQL `atan2` function. String arguments are treated as column names.
1560
+ # @!method posexplode(*cols)
1561
+ # The Spark SQL `posexplode` function. String arguments are treated as column names.
415
1562
  # @return [Column]
416
- # @!method bin(*cols)
417
- # The Spark SQL `bin` function. String arguments are treated as column names.
1563
+ # @!method posexplode_outer(*cols)
1564
+ # The Spark SQL `posexplode_outer` function. String arguments are treated as column names.
418
1565
  # @return [Column]
419
- # @!method cbrt(*cols)
420
- # The Spark SQL `cbrt` function. String arguments are treated as column names.
1566
+ # @!method position(*cols)
1567
+ # The Spark SQL `position` function. String arguments are treated as column names.
421
1568
  # @return [Column]
422
- # @!method ceil(*cols)
423
- # The Spark SQL `ceil` function. String arguments are treated as column names.
1569
+ # @!method positive(*cols)
1570
+ # The Spark SQL `positive` function. String arguments are treated as column names.
424
1571
  # @return [Column]
425
- # @!method ceiling(*cols)
426
- # The Spark SQL `ceiling` function. String arguments are treated as column names.
1572
+ # @!method printf(*cols)
1573
+ # The Spark SQL `printf` function. String arguments are treated as column names.
427
1574
  # @return [Column]
428
- # @!method cos(*cols)
429
- # The Spark SQL `cos` function. String arguments are treated as column names.
1575
+ # @!method product(*cols)
1576
+ # The Spark SQL `product` function. String arguments are treated as column names.
430
1577
  # @return [Column]
431
- # @!method cosh(*cols)
432
- # The Spark SQL `cosh` function. String arguments are treated as column names.
1578
+ # @!method quarter(*cols)
1579
+ # The Spark SQL `quarter` function. String arguments are treated as column names.
433
1580
  # @return [Column]
434
- # @!method cot(*cols)
435
- # The Spark SQL `cot` function. String arguments are treated as column names.
1581
+ # @!method quote(*cols)
1582
+ # The Spark SQL `quote` function. String arguments are treated as column names.
436
1583
  # @return [Column]
437
- # @!method csc(*cols)
438
- # The Spark SQL `csc` function. String arguments are treated as column names.
1584
+ # @!method radians(*cols)
1585
+ # The Spark SQL `radians` function. String arguments are treated as column names.
439
1586
  # @return [Column]
440
- # @!method degrees(*cols)
441
- # The Spark SQL `degrees` function. String arguments are treated as column names.
1587
+ # @!method reflect(*cols)
1588
+ # The Spark SQL `reflect` function. String arguments are treated as column names.
442
1589
  # @return [Column]
443
- # @!method exp(*cols)
444
- # The Spark SQL `exp` function. String arguments are treated as column names.
1590
+ # @!method regexp(*cols)
1591
+ # The Spark SQL `regexp` function. String arguments are treated as column names.
445
1592
  # @return [Column]
446
- # @!method expm1(*cols)
447
- # The Spark SQL `expm1` function. String arguments are treated as column names.
1593
+ # @!method regexp_count(*cols)
1594
+ # The Spark SQL `regexp_count` function. String arguments are treated as column names.
448
1595
  # @return [Column]
449
- # @!method factorial(*cols)
450
- # The Spark SQL `factorial` function. String arguments are treated as column names.
1596
+ # @!method regexp_like(*cols)
1597
+ # The Spark SQL `regexp_like` function. String arguments are treated as column names.
451
1598
  # @return [Column]
452
- # @!method floor(*cols)
453
- # The Spark SQL `floor` function. String arguments are treated as column names.
1599
+ # @!method regexp_substr(*cols)
1600
+ # The Spark SQL `regexp_substr` function. String arguments are treated as column names.
454
1601
  # @return [Column]
455
- # @!method hypot(*cols)
456
- # The Spark SQL `hypot` function. String arguments are treated as column names.
1602
+ # @!method regr_avgx(*cols)
1603
+ # The Spark SQL `regr_avgx` function. String arguments are treated as column names.
457
1604
  # @return [Column]
458
- # @!method ln(*cols)
459
- # The Spark SQL `ln` function. String arguments are treated as column names.
1605
+ # @!method regr_avgy(*cols)
1606
+ # The Spark SQL `regr_avgy` function. String arguments are treated as column names.
460
1607
  # @return [Column]
461
- # @!method log(*cols)
462
- # The Spark SQL `log` function. String arguments are treated as column names.
1608
+ # @!method regr_count(*cols)
1609
+ # The Spark SQL `regr_count` function. String arguments are treated as column names.
463
1610
  # @return [Column]
464
- # @!method log2(*cols)
465
- # The Spark SQL `log2` function. String arguments are treated as column names.
1611
+ # @!method regr_intercept(*cols)
1612
+ # The Spark SQL `regr_intercept` function. String arguments are treated as column names.
466
1613
  # @return [Column]
467
- # @!method log10(*cols)
468
- # The Spark SQL `log10` function. String arguments are treated as column names.
1614
+ # @!method regr_r2(*cols)
1615
+ # The Spark SQL `regr_r2` function. String arguments are treated as column names.
469
1616
  # @return [Column]
470
- # @!method log1p(*cols)
471
- # The Spark SQL `log1p` function. String arguments are treated as column names.
1617
+ # @!method regr_slope(*cols)
1618
+ # The Spark SQL `regr_slope` function. String arguments are treated as column names.
472
1619
  # @return [Column]
473
- # @!method negative(*cols)
474
- # The Spark SQL `negative` function. String arguments are treated as column names.
1620
+ # @!method regr_sxx(*cols)
1621
+ # The Spark SQL `regr_sxx` function. String arguments are treated as column names.
475
1622
  # @return [Column]
476
- # @!method negate(*cols)
477
- # The Spark SQL `negate` function. String arguments are treated as column names.
1623
+ # @!method regr_sxy(*cols)
1624
+ # The Spark SQL `regr_sxy` function. String arguments are treated as column names.
478
1625
  # @return [Column]
479
- # @!method positive(*cols)
480
- # The Spark SQL `positive` function. String arguments are treated as column names.
1626
+ # @!method regr_syy(*cols)
1627
+ # The Spark SQL `regr_syy` function. String arguments are treated as column names.
481
1628
  # @return [Column]
482
- # @!method pow(*cols)
483
- # The Spark SQL `pow` function. String arguments are treated as column names.
1629
+ # @!method replace(*cols)
1630
+ # The Spark SQL `replace` function. String arguments are treated as column names.
484
1631
  # @return [Column]
485
- # @!method power(*cols)
486
- # The Spark SQL `power` function. String arguments are treated as column names.
1632
+ # @!method reverse(*cols)
1633
+ # The Spark SQL `reverse` function. String arguments are treated as column names.
487
1634
  # @return [Column]
488
- # @!method radians(*cols)
489
- # The Spark SQL `radians` function. String arguments are treated as column names.
1635
+ # @!method right(*cols)
1636
+ # The Spark SQL `right` function. String arguments are treated as column names.
490
1637
  # @return [Column]
491
1638
  # @!method rint(*cols)
492
1639
  # The Spark SQL `rint` function. String arguments are treated as column names.
493
1640
  # @return [Column]
1641
+ # @!method rlike(*cols)
1642
+ # The Spark SQL `rlike` function. String arguments are treated as column names.
1643
+ # @return [Column]
1644
+ # @!method schema_of_variant(*cols)
1645
+ # The Spark SQL `schema_of_variant` function. String arguments are treated as column names.
1646
+ # @return [Column]
1647
+ # @!method schema_of_variant_agg(*cols)
1648
+ # The Spark SQL `schema_of_variant_agg` function. String arguments are treated as column names.
1649
+ # @return [Column]
494
1650
  # @!method sec(*cols)
495
1651
  # The Spark SQL `sec` function. String arguments are treated as column names.
496
1652
  # @return [Column]
1653
+ # @!method second(*cols)
1654
+ # The Spark SQL `second` function. String arguments are treated as column names.
1655
+ # @return [Column]
1656
+ # @!method sha(*cols)
1657
+ # The Spark SQL `sha` function. String arguments are treated as column names.
1658
+ # @return [Column]
1659
+ # @!method sha1(*cols)
1660
+ # The Spark SQL `sha1` function. String arguments are treated as column names.
1661
+ # @return [Column]
1662
+ # @!method sign(*cols)
1663
+ # The Spark SQL `sign` function. String arguments are treated as column names.
1664
+ # @return [Column]
497
1665
  # @!method signum(*cols)
498
1666
  # The Spark SQL `signum` function. String arguments are treated as column names.
499
1667
  # @return [Column]
@@ -503,224 +1671,230 @@ module SparkConnect
503
1671
  # @!method sinh(*cols)
504
1672
  # The Spark SQL `sinh` function. String arguments are treated as column names.
505
1673
  # @return [Column]
506
- # @!method sqrt(*cols)
507
- # The Spark SQL `sqrt` function. String arguments are treated as column names.
1674
+ # @!method size(*cols)
1675
+ # The Spark SQL `size` function. String arguments are treated as column names.
508
1676
  # @return [Column]
509
- # @!method tan(*cols)
510
- # The Spark SQL `tan` function. String arguments are treated as column names.
1677
+ # @!method skewness(*cols)
1678
+ # The Spark SQL `skewness` function. String arguments are treated as column names.
511
1679
  # @return [Column]
512
- # @!method tanh(*cols)
513
- # The Spark SQL `tanh` function. String arguments are treated as column names.
1680
+ # @!method some(*cols)
1681
+ # The Spark SQL `some` function. String arguments are treated as column names.
514
1682
  # @return [Column]
515
- # @!method hex(*cols)
516
- # The Spark SQL `hex` function. String arguments are treated as column names.
1683
+ # @!method soundex(*cols)
1684
+ # The Spark SQL `soundex` function. String arguments are treated as column names.
517
1685
  # @return [Column]
518
- # @!method unhex(*cols)
519
- # The Spark SQL `unhex` function. String arguments are treated as column names.
1686
+ # @!method split_part(*cols)
1687
+ # The Spark SQL `split_part` function. String arguments are treated as column names.
520
1688
  # @return [Column]
521
- # @!method pmod(*cols)
522
- # The Spark SQL `pmod` function. String arguments are treated as column names.
1689
+ # @!method sqrt(*cols)
1690
+ # The Spark SQL `sqrt` function. String arguments are treated as column names.
523
1691
  # @return [Column]
524
- # @!method isnan(*cols)
525
- # The Spark SQL `isnan` function. String arguments are treated as column names.
1692
+ # @!method st_geogfromwkb(*cols)
1693
+ # The Spark SQL `st_geogfromwkb` function. String arguments are treated as column names.
526
1694
  # @return [Column]
527
- # @!method isnull(*cols)
528
- # The Spark SQL `isnull` function. String arguments are treated as column names.
1695
+ # @!method st_srid(*cols)
1696
+ # The Spark SQL `st_srid` function. String arguments are treated as column names.
529
1697
  # @return [Column]
530
- # @!method upper(*cols)
531
- # The Spark SQL `upper` function. String arguments are treated as column names.
1698
+ # @!method stack(*cols)
1699
+ # The Spark SQL `stack` function. String arguments are treated as column names.
532
1700
  # @return [Column]
533
- # @!method lower(*cols)
534
- # The Spark SQL `lower` function. String arguments are treated as column names.
1701
+ # @!method startswith(*cols)
1702
+ # The Spark SQL `startswith` function. String arguments are treated as column names.
535
1703
  # @return [Column]
536
- # @!method ltrim(*cols)
537
- # The Spark SQL `ltrim` function. String arguments are treated as column names.
1704
+ # @!method std(*cols)
1705
+ # The Spark SQL `std` function. String arguments are treated as column names.
538
1706
  # @return [Column]
539
- # @!method rtrim(*cols)
540
- # The Spark SQL `rtrim` function. String arguments are treated as column names.
1707
+ # @!method stddev(*cols)
1708
+ # The Spark SQL `stddev` function. String arguments are treated as column names.
541
1709
  # @return [Column]
542
- # @!method trim(*cols)
543
- # The Spark SQL `trim` function. String arguments are treated as column names.
1710
+ # @!method stddev_pop(*cols)
1711
+ # The Spark SQL `stddev_pop` function. String arguments are treated as column names.
544
1712
  # @return [Column]
545
- # @!method length(*cols)
546
- # The Spark SQL `length` function. String arguments are treated as column names.
1713
+ # @!method stddev_samp(*cols)
1714
+ # The Spark SQL `stddev_samp` function. String arguments are treated as column names.
547
1715
  # @return [Column]
548
- # @!method char_length(*cols)
549
- # The Spark SQL `char_length` function. String arguments are treated as column names.
1716
+ # @!method substr(*cols)
1717
+ # The Spark SQL `substr` function. String arguments are treated as column names.
550
1718
  # @return [Column]
551
- # @!method character_length(*cols)
552
- # The Spark SQL `character_length` function. String arguments are treated as column names.
1719
+ # @!method sum(*cols)
1720
+ # The Spark SQL `sum` function. String arguments are treated as column names.
553
1721
  # @return [Column]
554
- # @!method octet_length(*cols)
555
- # The Spark SQL `octet_length` function. String arguments are treated as column names.
1722
+ # @!method tan(*cols)
1723
+ # The Spark SQL `tan` function. String arguments are treated as column names.
556
1724
  # @return [Column]
557
- # @!method bit_length(*cols)
558
- # The Spark SQL `bit_length` function. String arguments are treated as column names.
1725
+ # @!method tanh(*cols)
1726
+ # The Spark SQL `tanh` function. String arguments are treated as column names.
559
1727
  # @return [Column]
560
- # @!method reverse(*cols)
561
- # The Spark SQL `reverse` function. String arguments are treated as column names.
1728
+ # @!method theta_difference(*cols)
1729
+ # The Spark SQL `theta_difference` function. String arguments are treated as column names.
562
1730
  # @return [Column]
563
- # @!method ascii(*cols)
564
- # The Spark SQL `ascii` function. String arguments are treated as column names.
1731
+ # @!method theta_intersection(*cols)
1732
+ # The Spark SQL `theta_intersection` function. String arguments are treated as column names.
565
1733
  # @return [Column]
566
- # @!method base64(*cols)
567
- # The Spark SQL `base64` function. String arguments are treated as column names.
1734
+ # @!method theta_intersection_agg(*cols)
1735
+ # The Spark SQL `theta_intersection_agg` function. String arguments are treated as column names.
568
1736
  # @return [Column]
569
- # @!method unbase64(*cols)
570
- # The Spark SQL `unbase64` function. String arguments are treated as column names.
1737
+ # @!method theta_sketch_estimate(*cols)
1738
+ # The Spark SQL `theta_sketch_estimate` function. String arguments are treated as column names.
571
1739
  # @return [Column]
572
- # @!method initcap(*cols)
573
- # The Spark SQL `initcap` function. String arguments are treated as column names.
1740
+ # @!method time_bucket(*cols)
1741
+ # The Spark SQL `time_bucket` function. String arguments are treated as column names.
574
1742
  # @return [Column]
575
- # @!method soundex(*cols)
576
- # The Spark SQL `soundex` function. String arguments are treated as column names.
1743
+ # @!method time_diff(*cols)
1744
+ # The Spark SQL `time_diff` function. String arguments are treated as column names.
577
1745
  # @return [Column]
578
- # @!method crc32(*cols)
579
- # The Spark SQL `crc32` function. String arguments are treated as column names.
1746
+ # @!method time_from_micros(*cols)
1747
+ # The Spark SQL `time_from_micros` function. String arguments are treated as column names.
580
1748
  # @return [Column]
581
- # @!method md5(*cols)
582
- # The Spark SQL `md5` function. String arguments are treated as column names.
1749
+ # @!method time_from_millis(*cols)
1750
+ # The Spark SQL `time_from_millis` function. String arguments are treated as column names.
583
1751
  # @return [Column]
584
- # @!method sha1(*cols)
585
- # The Spark SQL `sha1` function. String arguments are treated as column names.
1752
+ # @!method time_from_seconds(*cols)
1753
+ # The Spark SQL `time_from_seconds` function. String arguments are treated as column names.
586
1754
  # @return [Column]
587
- # @!method sha(*cols)
588
- # The Spark SQL `sha` function. String arguments are treated as column names.
1755
+ # @!method time_to_micros(*cols)
1756
+ # The Spark SQL `time_to_micros` function. String arguments are treated as column names.
589
1757
  # @return [Column]
590
- # @!method ucase(*cols)
591
- # The Spark SQL `ucase` function. String arguments are treated as column names.
1758
+ # @!method time_to_millis(*cols)
1759
+ # The Spark SQL `time_to_millis` function. String arguments are treated as column names.
592
1760
  # @return [Column]
593
- # @!method lcase(*cols)
594
- # The Spark SQL `lcase` function. String arguments are treated as column names.
1761
+ # @!method time_to_seconds(*cols)
1762
+ # The Spark SQL `time_to_seconds` function. String arguments are treated as column names.
595
1763
  # @return [Column]
596
- # @!method size(*cols)
597
- # The Spark SQL `size` function. String arguments are treated as column names.
1764
+ # @!method time_trunc(*cols)
1765
+ # The Spark SQL `time_trunc` function. String arguments are treated as column names.
598
1766
  # @return [Column]
599
- # @!method cardinality(*cols)
600
- # The Spark SQL `cardinality` function. String arguments are treated as column names.
1767
+ # @!method timestamp_micros(*cols)
1768
+ # The Spark SQL `timestamp_micros` function. String arguments are treated as column names.
601
1769
  # @return [Column]
602
- # @!method array_distinct(*cols)
603
- # The Spark SQL `array_distinct` function. String arguments are treated as column names.
1770
+ # @!method timestamp_millis(*cols)
1771
+ # The Spark SQL `timestamp_millis` function. String arguments are treated as column names.
604
1772
  # @return [Column]
605
- # @!method array_max(*cols)
606
- # The Spark SQL `array_max` function. String arguments are treated as column names.
1773
+ # @!method timestamp_nanos(*cols)
1774
+ # The Spark SQL `timestamp_nanos` function. String arguments are treated as column names.
607
1775
  # @return [Column]
608
- # @!method array_min(*cols)
609
- # The Spark SQL `array_min` function. String arguments are treated as column names.
1776
+ # @!method timestamp_seconds(*cols)
1777
+ # The Spark SQL `timestamp_seconds` function. String arguments are treated as column names.
610
1778
  # @return [Column]
611
- # @!method array_compact(*cols)
612
- # The Spark SQL `array_compact` function. String arguments are treated as column names.
1779
+ # @!method to_base32(*cols)
1780
+ # The Spark SQL `to_base32` function. String arguments are treated as column names.
613
1781
  # @return [Column]
614
- # @!method flatten(*cols)
615
- # The Spark SQL `flatten` function. String arguments are treated as column names.
1782
+ # @!method to_binary(*cols)
1783
+ # The Spark SQL `to_binary` function. String arguments are treated as column names.
616
1784
  # @return [Column]
617
- # @!method explode(*cols)
618
- # The Spark SQL `explode` function. String arguments are treated as column names.
1785
+ # @!method to_char(*cols)
1786
+ # The Spark SQL `to_char` function. String arguments are treated as column names.
619
1787
  # @return [Column]
620
- # @!method explode_outer(*cols)
621
- # The Spark SQL `explode_outer` function. String arguments are treated as column names.
1788
+ # @!method to_number(*cols)
1789
+ # The Spark SQL `to_number` function. String arguments are treated as column names.
622
1790
  # @return [Column]
623
- # @!method posexplode(*cols)
624
- # The Spark SQL `posexplode` function. String arguments are treated as column names.
1791
+ # @!method to_time(*cols)
1792
+ # The Spark SQL `to_time` function. String arguments are treated as column names.
625
1793
  # @return [Column]
626
- # @!method posexplode_outer(*cols)
627
- # The Spark SQL `posexplode_outer` function. String arguments are treated as column names.
1794
+ # @!method to_timestamp_ltz(*cols)
1795
+ # The Spark SQL `to_timestamp_ltz` function. String arguments are treated as column names.
1796
+ # @return [Column]
1797
+ # @!method to_timestamp_ntz(*cols)
1798
+ # The Spark SQL `to_timestamp_ntz` function. String arguments are treated as column names.
628
1799
  # @return [Column]
629
- # @!method inline(*cols)
630
- # The Spark SQL `inline` function. String arguments are treated as column names.
1800
+ # @!method to_unix_timestamp(*cols)
1801
+ # The Spark SQL `to_unix_timestamp` function. String arguments are treated as column names.
631
1802
  # @return [Column]
632
- # @!method inline_outer(*cols)
633
- # The Spark SQL `inline_outer` function. String arguments are treated as column names.
1803
+ # @!method to_varchar(*cols)
1804
+ # The Spark SQL `to_varchar` function. String arguments are treated as column names.
634
1805
  # @return [Column]
635
- # @!method map_keys(*cols)
636
- # The Spark SQL `map_keys` function. String arguments are treated as column names.
1806
+ # @!method to_variant_object(*cols)
1807
+ # The Spark SQL `to_variant_object` function. String arguments are treated as column names.
637
1808
  # @return [Column]
638
- # @!method map_values(*cols)
639
- # The Spark SQL `map_values` function. String arguments are treated as column names.
1809
+ # @!method try_add(*cols)
1810
+ # The Spark SQL `try_add` function. String arguments are treated as column names.
640
1811
  # @return [Column]
641
- # @!method map_entries(*cols)
642
- # The Spark SQL `map_entries` function. String arguments are treated as column names.
1812
+ # @!method try_avg(*cols)
1813
+ # The Spark SQL `try_avg` function. String arguments are treated as column names.
643
1814
  # @return [Column]
644
- # @!method map_from_entries(*cols)
645
- # The Spark SQL `map_from_entries` function. String arguments are treated as column names.
1815
+ # @!method try_divide(*cols)
1816
+ # The Spark SQL `try_divide` function. String arguments are treated as column names.
646
1817
  # @return [Column]
647
- # @!method array_sort(*cols)
648
- # The Spark SQL `array_sort` function. String arguments are treated as column names.
1818
+ # @!method try_element_at(*cols)
1819
+ # The Spark SQL `try_element_at` function. String arguments are treated as column names.
649
1820
  # @return [Column]
650
- # @!method shuffle(*cols)
651
- # The Spark SQL `shuffle` function. String arguments are treated as column names.
1821
+ # @!method try_make_timestamp_ltz(*cols)
1822
+ # The Spark SQL `try_make_timestamp_ltz` function. String arguments are treated as column names.
652
1823
  # @return [Column]
653
- # @!method arrays_zip(*cols)
654
- # The Spark SQL `arrays_zip` function. String arguments are treated as column names.
1824
+ # @!method try_mod(*cols)
1825
+ # The Spark SQL `try_mod` function. String arguments are treated as column names.
655
1826
  # @return [Column]
656
- # @!method map_concat(*cols)
657
- # The Spark SQL `map_concat` function. String arguments are treated as column names.
1827
+ # @!method try_multiply(*cols)
1828
+ # The Spark SQL `try_multiply` function. String arguments are treated as column names.
658
1829
  # @return [Column]
659
- # @!method concat(*cols)
660
- # The Spark SQL `concat` function. String arguments are treated as column names.
1830
+ # @!method try_parse_json(*cols)
1831
+ # The Spark SQL `try_parse_json` function. String arguments are treated as column names.
661
1832
  # @return [Column]
662
- # @!method greatest(*cols)
663
- # The Spark SQL `greatest` function. String arguments are treated as column names.
1833
+ # @!method try_parse_url(*cols)
1834
+ # The Spark SQL `try_parse_url` function. String arguments are treated as column names.
664
1835
  # @return [Column]
665
- # @!method least(*cols)
666
- # The Spark SQL `least` function. String arguments are treated as column names.
1836
+ # @!method try_reflect(*cols)
1837
+ # The Spark SQL `try_reflect` function. String arguments are treated as column names.
667
1838
  # @return [Column]
668
- # @!method hash(*cols)
669
- # The Spark SQL `hash` function. String arguments are treated as column names.
1839
+ # @!method try_subtract(*cols)
1840
+ # The Spark SQL `try_subtract` function. String arguments are treated as column names.
670
1841
  # @return [Column]
671
- # @!method xxhash64(*cols)
672
- # The Spark SQL `xxhash64` function. String arguments are treated as column names.
1842
+ # @!method try_sum(*cols)
1843
+ # The Spark SQL `try_sum` function. String arguments are treated as column names.
673
1844
  # @return [Column]
674
- # @!method array_union(*cols)
675
- # The Spark SQL `array_union` function. String arguments are treated as column names.
1845
+ # @!method try_to_binary(*cols)
1846
+ # The Spark SQL `try_to_binary` function. String arguments are treated as column names.
676
1847
  # @return [Column]
677
- # @!method array_intersect(*cols)
678
- # The Spark SQL `array_intersect` function. String arguments are treated as column names.
1848
+ # @!method try_to_number(*cols)
1849
+ # The Spark SQL `try_to_number` function. String arguments are treated as column names.
679
1850
  # @return [Column]
680
- # @!method array_except(*cols)
681
- # The Spark SQL `array_except` function. String arguments are treated as column names.
1851
+ # @!method try_to_time(*cols)
1852
+ # The Spark SQL `try_to_time` function. String arguments are treated as column names.
682
1853
  # @return [Column]
683
- # @!method arrays_overlap(*cols)
684
- # The Spark SQL `arrays_overlap` function. String arguments are treated as column names.
1854
+ # @!method try_to_timestamp(*cols)
1855
+ # The Spark SQL `try_to_timestamp` function. String arguments are treated as column names.
685
1856
  # @return [Column]
686
- # @!method year(*cols)
687
- # The Spark SQL `year` function. String arguments are treated as column names.
1857
+ # @!method try_url_decode(*cols)
1858
+ # The Spark SQL `try_url_decode` function. String arguments are treated as column names.
688
1859
  # @return [Column]
689
- # @!method quarter(*cols)
690
- # The Spark SQL `quarter` function. String arguments are treated as column names.
1860
+ # @!method try_validate_utf8(*cols)
1861
+ # The Spark SQL `try_validate_utf8` function. String arguments are treated as column names.
691
1862
  # @return [Column]
692
- # @!method month(*cols)
693
- # The Spark SQL `month` function. String arguments are treated as column names.
1863
+ # @!method tuple_difference_double(*cols)
1864
+ # The Spark SQL `tuple_difference_double` function. String arguments are treated as column names.
694
1865
  # @return [Column]
695
- # @!method dayofmonth(*cols)
696
- # The Spark SQL `dayofmonth` function. String arguments are treated as column names.
1866
+ # @!method tuple_difference_integer(*cols)
1867
+ # The Spark SQL `tuple_difference_integer` function. String arguments are treated as column names.
697
1868
  # @return [Column]
698
- # @!method day(*cols)
699
- # The Spark SQL `day` function. String arguments are treated as column names.
1869
+ # @!method tuple_difference_theta_double(*cols)
1870
+ # The Spark SQL `tuple_difference_theta_double` function. String arguments are treated as column names.
700
1871
  # @return [Column]
701
- # @!method dayofweek(*cols)
702
- # The Spark SQL `dayofweek` function. String arguments are treated as column names.
1872
+ # @!method tuple_difference_theta_integer(*cols)
1873
+ # The Spark SQL `tuple_difference_theta_integer` function. String arguments are treated as column names.
703
1874
  # @return [Column]
704
- # @!method dayofyear(*cols)
705
- # The Spark SQL `dayofyear` function. String arguments are treated as column names.
1875
+ # @!method tuple_sketch_estimate_double(*cols)
1876
+ # The Spark SQL `tuple_sketch_estimate_double` function. String arguments are treated as column names.
706
1877
  # @return [Column]
707
- # @!method hour(*cols)
708
- # The Spark SQL `hour` function. String arguments are treated as column names.
1878
+ # @!method tuple_sketch_estimate_integer(*cols)
1879
+ # The Spark SQL `tuple_sketch_estimate_integer` function. String arguments are treated as column names.
709
1880
  # @return [Column]
710
- # @!method minute(*cols)
711
- # The Spark SQL `minute` function. String arguments are treated as column names.
1881
+ # @!method tuple_sketch_theta_double(*cols)
1882
+ # The Spark SQL `tuple_sketch_theta_double` function. String arguments are treated as column names.
712
1883
  # @return [Column]
713
- # @!method second(*cols)
714
- # The Spark SQL `second` function. String arguments are treated as column names.
1884
+ # @!method tuple_sketch_theta_integer(*cols)
1885
+ # The Spark SQL `tuple_sketch_theta_integer` function. String arguments are treated as column names.
715
1886
  # @return [Column]
716
- # @!method weekofyear(*cols)
717
- # The Spark SQL `weekofyear` function. String arguments are treated as column names.
1887
+ # @!method typeof(*cols)
1888
+ # The Spark SQL `typeof` function. String arguments are treated as column names.
718
1889
  # @return [Column]
719
- # @!method last_day(*cols)
720
- # The Spark SQL `last_day` function. String arguments are treated as column names.
1890
+ # @!method ucase(*cols)
1891
+ # The Spark SQL `ucase` function. String arguments are treated as column names.
721
1892
  # @return [Column]
722
- # @!method weekday(*cols)
723
- # The Spark SQL `weekday` function. String arguments are treated as column names.
1893
+ # @!method unbase64(*cols)
1894
+ # The Spark SQL `unbase64` function. String arguments are treated as column names.
1895
+ # @return [Column]
1896
+ # @!method unhex(*cols)
1897
+ # The Spark SQL `unhex` function. String arguments are treated as column names.
724
1898
  # @return [Column]
725
1899
  # @!method unix_date(*cols)
726
1900
  # The Spark SQL `unix_date` function. String arguments are treated as column names.
@@ -731,44 +1905,113 @@ module SparkConnect
731
1905
  # @!method unix_millis(*cols)
732
1906
  # The Spark SQL `unix_millis` function. String arguments are treated as column names.
733
1907
  # @return [Column]
1908
+ # @!method unix_nanos(*cols)
1909
+ # The Spark SQL `unix_nanos` function. String arguments are treated as column names.
1910
+ # @return [Column]
734
1911
  # @!method unix_seconds(*cols)
735
1912
  # The Spark SQL `unix_seconds` function. String arguments are treated as column names.
736
1913
  # @return [Column]
737
- # @!method timestamp_seconds(*cols)
738
- # The Spark SQL `timestamp_seconds` function. String arguments are treated as column names.
1914
+ # @!method unwrap_udt(*cols)
1915
+ # The Spark SQL `unwrap_udt` function. String arguments are treated as column names.
739
1916
  # @return [Column]
740
- # @!method timestamp_millis(*cols)
741
- # The Spark SQL `timestamp_millis` function. String arguments are treated as column names.
1917
+ # @!method upper(*cols)
1918
+ # The Spark SQL `upper` function. String arguments are treated as column names.
742
1919
  # @return [Column]
743
- # @!method timestamp_micros(*cols)
744
- # The Spark SQL `timestamp_micros` function. String arguments are treated as column names.
1920
+ # @!method url_decode(*cols)
1921
+ # The Spark SQL `url_decode` function. String arguments are treated as column names.
745
1922
  # @return [Column]
746
- # @!method date_from_unix_date(*cols)
747
- # The Spark SQL `date_from_unix_date` function. String arguments are treated as column names.
1923
+ # @!method url_encode(*cols)
1924
+ # The Spark SQL `url_encode` function. String arguments are treated as column names.
748
1925
  # @return [Column]
749
- # @!method bitwise_not(*cols)
750
- # The Spark SQL `bitwise_not` function. String arguments are treated as column names.
1926
+ # @!method validate_utf8(*cols)
1927
+ # The Spark SQL `validate_utf8` function. String arguments are treated as column names.
751
1928
  # @return [Column]
752
- # @!method bit_count(*cols)
753
- # The Spark SQL `bit_count` function. String arguments are treated as column names.
1929
+ # @!method var_pop(*cols)
1930
+ # The Spark SQL `var_pop` function. String arguments are treated as column names.
754
1931
  # @return [Column]
755
- # @!method typeof(*cols)
756
- # The Spark SQL `typeof` function. String arguments are treated as column names.
1932
+ # @!method var_samp(*cols)
1933
+ # The Spark SQL `var_samp` function. String arguments are treated as column names.
757
1934
  # @return [Column]
758
- # @!method current_date
759
- # The Spark SQL `current_date` function (takes no arguments).
1935
+ # @!method variance(*cols)
1936
+ # The Spark SQL `variance` function. String arguments are treated as column names.
760
1937
  # @return [Column]
761
- # @!method current_timestamp
762
- # The Spark SQL `current_timestamp` function (takes no arguments).
1938
+ # @!method vector_avg(*cols)
1939
+ # The Spark SQL `vector_avg` function. String arguments are treated as column names.
763
1940
  # @return [Column]
764
- # @!method now
765
- # The Spark SQL `now` function (takes no arguments).
1941
+ # @!method vector_cosine_similarity(*cols)
1942
+ # The Spark SQL `vector_cosine_similarity` function. String arguments are treated as column names.
766
1943
  # @return [Column]
767
- # @!method current_timezone
768
- # The Spark SQL `current_timezone` function (takes no arguments).
1944
+ # @!method vector_inner_product(*cols)
1945
+ # The Spark SQL `vector_inner_product` function. String arguments are treated as column names.
769
1946
  # @return [Column]
770
- # @!method current_user
771
- # The Spark SQL `current_user` function (takes no arguments).
1947
+ # @!method vector_l2_distance(*cols)
1948
+ # The Spark SQL `vector_l2_distance` function. String arguments are treated as column names.
1949
+ # @return [Column]
1950
+ # @!method vector_norm(*cols)
1951
+ # The Spark SQL `vector_norm` function. String arguments are treated as column names.
1952
+ # @return [Column]
1953
+ # @!method vector_normalize(*cols)
1954
+ # The Spark SQL `vector_normalize` function. String arguments are treated as column names.
1955
+ # @return [Column]
1956
+ # @!method vector_sum(*cols)
1957
+ # The Spark SQL `vector_sum` function. String arguments are treated as column names.
1958
+ # @return [Column]
1959
+ # @!method weekday(*cols)
1960
+ # The Spark SQL `weekday` function. String arguments are treated as column names.
1961
+ # @return [Column]
1962
+ # @!method weekofyear(*cols)
1963
+ # The Spark SQL `weekofyear` function. String arguments are treated as column names.
1964
+ # @return [Column]
1965
+ # @!method width_bucket(*cols)
1966
+ # The Spark SQL `width_bucket` function. String arguments are treated as column names.
1967
+ # @return [Column]
1968
+ # @!method window_time(*cols)
1969
+ # The Spark SQL `window_time` function. String arguments are treated as column names.
1970
+ # @return [Column]
1971
+ # @!method xpath(*cols)
1972
+ # The Spark SQL `xpath` function. String arguments are treated as column names.
1973
+ # @return [Column]
1974
+ # @!method xpath_boolean(*cols)
1975
+ # The Spark SQL `xpath_boolean` function. String arguments are treated as column names.
1976
+ # @return [Column]
1977
+ # @!method xpath_double(*cols)
1978
+ # The Spark SQL `xpath_double` function. String arguments are treated as column names.
1979
+ # @return [Column]
1980
+ # @!method xpath_float(*cols)
1981
+ # The Spark SQL `xpath_float` function. String arguments are treated as column names.
1982
+ # @return [Column]
1983
+ # @!method xpath_int(*cols)
1984
+ # The Spark SQL `xpath_int` function. String arguments are treated as column names.
1985
+ # @return [Column]
1986
+ # @!method xpath_long(*cols)
1987
+ # The Spark SQL `xpath_long` function. String arguments are treated as column names.
1988
+ # @return [Column]
1989
+ # @!method xpath_number(*cols)
1990
+ # The Spark SQL `xpath_number` function. String arguments are treated as column names.
1991
+ # @return [Column]
1992
+ # @!method xpath_short(*cols)
1993
+ # The Spark SQL `xpath_short` function. String arguments are treated as column names.
1994
+ # @return [Column]
1995
+ # @!method xpath_string(*cols)
1996
+ # The Spark SQL `xpath_string` function. String arguments are treated as column names.
1997
+ # @return [Column]
1998
+ # @!method xxhash64(*cols)
1999
+ # The Spark SQL `xxhash64` function. String arguments are treated as column names.
2000
+ # @return [Column]
2001
+ # @!method year(*cols)
2002
+ # The Spark SQL `year` function. String arguments are treated as column names.
2003
+ # @return [Column]
2004
+ # @!method years(*cols)
2005
+ # The Spark SQL `years` function. String arguments are treated as column names.
2006
+ # @return [Column]
2007
+ # @!method zeroifnull(*cols)
2008
+ # The Spark SQL `zeroifnull` function. String arguments are treated as column names.
2009
+ # @return [Column]
2010
+ # @!method cume_dist
2011
+ # The Spark SQL `cume_dist` function (takes no arguments).
2012
+ # @return [Column]
2013
+ # @!method curdate
2014
+ # The Spark SQL `curdate` function (takes no arguments).
772
2015
  # @return [Column]
773
2016
  # @!method current_catalog
774
2017
  # The Spark SQL `current_catalog` function (takes no arguments).
@@ -776,68 +2019,114 @@ module SparkConnect
776
2019
  # @!method current_database
777
2020
  # The Spark SQL `current_database` function (takes no arguments).
778
2021
  # @return [Column]
2022
+ # @!method current_date
2023
+ # The Spark SQL `current_date` function (takes no arguments).
2024
+ # @return [Column]
2025
+ # @!method current_path
2026
+ # The Spark SQL `current_path` function (takes no arguments).
2027
+ # @return [Column]
779
2028
  # @!method current_schema
780
2029
  # The Spark SQL `current_schema` function (takes no arguments).
781
2030
  # @return [Column]
782
- # @!method monotonically_increasing_id
783
- # The Spark SQL `monotonically_increasing_id` function (takes no arguments).
2031
+ # @!method current_timestamp
2032
+ # The Spark SQL `current_timestamp` function (takes no arguments).
784
2033
  # @return [Column]
785
- # @!method spark_partition_id
786
- # The Spark SQL `spark_partition_id` function (takes no arguments).
2034
+ # @!method current_timezone
2035
+ # The Spark SQL `current_timezone` function (takes no arguments).
787
2036
  # @return [Column]
788
- # @!method input_file_name
789
- # The Spark SQL `input_file_name` function (takes no arguments).
2037
+ # @!method current_user
2038
+ # The Spark SQL `current_user` function (takes no arguments).
790
2039
  # @return [Column]
791
- # @!method input_file_block_start
792
- # The Spark SQL `input_file_block_start` function (takes no arguments).
2040
+ # @!method dense_rank
2041
+ # The Spark SQL `dense_rank` function (takes no arguments).
2042
+ # @return [Column]
2043
+ # @!method e
2044
+ # The Spark SQL `e` function (takes no arguments).
793
2045
  # @return [Column]
794
2046
  # @!method input_file_block_length
795
2047
  # The Spark SQL `input_file_block_length` function (takes no arguments).
796
2048
  # @return [Column]
797
- # @!method version
798
- # The Spark SQL `version` function (takes no arguments).
2049
+ # @!method input_file_block_start
2050
+ # The Spark SQL `input_file_block_start` function (takes no arguments).
799
2051
  # @return [Column]
800
- # @!method uuid
801
- # The Spark SQL `uuid` function (takes no arguments).
2052
+ # @!method input_file_name
2053
+ # The Spark SQL `input_file_name` function (takes no arguments).
802
2054
  # @return [Column]
803
- # @!method row_number
804
- # The Spark SQL `row_number` function (takes no arguments).
2055
+ # @!method localtimestamp
2056
+ # The Spark SQL `localtimestamp` function (takes no arguments).
805
2057
  # @return [Column]
806
- # @!method rank
807
- # The Spark SQL `rank` function (takes no arguments).
2058
+ # @!method monotonically_increasing_id
2059
+ # The Spark SQL `monotonically_increasing_id` function (takes no arguments).
808
2060
  # @return [Column]
809
- # @!method dense_rank
810
- # The Spark SQL `dense_rank` function (takes no arguments).
2061
+ # @!method now
2062
+ # The Spark SQL `now` function (takes no arguments).
811
2063
  # @return [Column]
812
2064
  # @!method percent_rank
813
2065
  # The Spark SQL `percent_rank` function (takes no arguments).
814
2066
  # @return [Column]
815
- # @!method cume_dist
816
- # The Spark SQL `cume_dist` function (takes no arguments).
2067
+ # @!method pi
2068
+ # The Spark SQL `pi` function (takes no arguments).
2069
+ # @return [Column]
2070
+ # @!method rank
2071
+ # The Spark SQL `rank` function (takes no arguments).
2072
+ # @return [Column]
2073
+ # @!method row_number
2074
+ # The Spark SQL `row_number` function (takes no arguments).
2075
+ # @return [Column]
2076
+ # @!method session_user
2077
+ # The Spark SQL `session_user` function (takes no arguments).
2078
+ # @return [Column]
2079
+ # @!method spark_partition_id
2080
+ # The Spark SQL `spark_partition_id` function (takes no arguments).
2081
+ # @return [Column]
2082
+ # @!method user
2083
+ # The Spark SQL `user` function (takes no arguments).
2084
+ # @return [Column]
2085
+ # @!method version
2086
+ # The Spark SQL `version` function (takes no arguments).
817
2087
  # @return [Column]
818
2088
  # ---- Generated uniform functions --------------------------------------
819
2089
  # Functions whose arguments are all ColumnOrName (a String denotes a column
820
- # name). Defined programmatically to keep the surface complete and compact.
2090
+ # name; other values become literals). Defined programmatically to keep the
2091
+ # surface complete and compact.
821
2092
 
822
2093
  UNIFORM = %w[
823
- sum avg mean max min first last stddev stddev_samp stddev_pop variance var_samp var_pop
824
- skewness kurtosis collect_list collect_set first_value last_value max_by min_by corr
825
- covar_pop covar_samp median mode any_value every some bit_and bit_or bit_xor bool_and bool_or
826
- product count_if grouping
827
- abs acos acosh asin asinh atan atanh atan2 bin cbrt ceil ceiling cos cosh cot csc degrees
828
- exp expm1 factorial floor hypot ln log log2 log10 log1p negative negate positive pow power
829
- radians rint sec signum sin sinh sqrt tan tanh hex unhex pmod isnan isnull positive
830
- upper lower ltrim rtrim trim length char_length character_length octet_length bit_length
831
- reverse ascii base64 unbase64 initcap soundex crc32 md5 sha1 sha ucase lcase
832
- size cardinality array_distinct array_max array_min array_compact flatten explode explode_outer
833
- posexplode posexplode_outer inline inline_outer map_keys map_values map_entries map_from_entries
834
- array_sort shuffle arrays_zip map_concat concat greatest least hash xxhash64
835
- array_union array_intersect array_except arrays_overlap
836
- year quarter month dayofmonth day dayofweek dayofyear hour minute second weekofyear last_day
837
- weekday unix_date unix_micros unix_millis unix_seconds timestamp_seconds timestamp_millis
838
- timestamp_micros date_from_unix_date
839
- bitwise_not bit_count typeof
840
- ].uniq.freeze
2094
+ abs acos acosh any_value array_agg array_compact array_distinct array_except array_intersect array_max
2095
+ array_min array_size array_union arrays_overlap arrays_zip ascii asin asinh atan atan2 atanh avg base64 bin
2096
+ bit_and bit_count bit_get bit_length bit_or bit_xor bitmap_and_agg bitmap_bit_position bitmap_bucket_number
2097
+ bitmap_construct_agg bitmap_count bitmap_or_agg bool_and bool_or btrim cardinality cbrt ceil ceiling char
2098
+ char_length character_length chr collation collect_list collect_set collect_union concat contains corr cos cosh
2099
+ cot count_if counter_diff covar_pop covar_samp crc32 csc date_diff date_from_unix_date date_part datepart day
2100
+ dayname dayofmonth dayofweek dayofyear days degrees elt endswith equal_null every exp explode explode_outer
2101
+ expm1 extract factorial find_in_set first_value flatten floor from_base32 getbit grouping grouping_id hash hex
2102
+ histogram_numeric hll_sketch_estimate hmac hour hours hypot ifnull ilike initcap inline inline_outer
2103
+ is_valid_utf8 is_valid_variant is_variant_null isnan isnotnull isnull jaro_winkler_similarity java_method
2104
+ json_array_length json_object_keys kll_sketch_get_n_bigint kll_sketch_get_n_double kll_sketch_get_n_float
2105
+ kll_sketch_get_quantile_bigint kll_sketch_get_quantile_double kll_sketch_get_quantile_float
2106
+ kll_sketch_get_rank_bigint kll_sketch_get_rank_double kll_sketch_get_rank_float kll_sketch_merge_bigint
2107
+ kll_sketch_merge_double kll_sketch_merge_float kll_sketch_to_string_bigint kll_sketch_to_string_double
2108
+ kll_sketch_to_string_float kurtosis last_day last_value lcase left length like ln log10 log1p log2 lower
2109
+ make_time make_timestamp_ltz make_valid_utf8 map_entries map_from_entries map_keys map_values max md5 median
2110
+ min minute month monthname months negative nullif nullifzero nvl nvl2 octet_length parse_json parse_url pmod
2111
+ posexplode posexplode_outer position positive printf product quarter quote radians reflect regexp regexp_count
2112
+ regexp_like regexp_substr regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy
2113
+ regr_syy replace reverse right rint rlike schema_of_variant schema_of_variant_agg sec second sha sha1 sign
2114
+ signum sin sinh size skewness some soundex split_part sqrt st_geogfromwkb st_srid stack startswith std stddev
2115
+ stddev_pop stddev_samp substr sum tan tanh theta_difference theta_intersection theta_intersection_agg
2116
+ theta_sketch_estimate time_bucket time_diff time_from_micros time_from_millis time_from_seconds time_to_micros
2117
+ time_to_millis time_to_seconds time_trunc timestamp_micros timestamp_millis timestamp_nanos timestamp_seconds
2118
+ to_base32 to_binary to_char to_number to_time to_timestamp_ltz to_timestamp_ntz to_unix_timestamp to_varchar
2119
+ to_variant_object try_add try_avg try_divide try_element_at try_make_timestamp_ltz try_mod try_multiply
2120
+ try_parse_json try_parse_url try_reflect try_subtract try_sum try_to_binary try_to_number try_to_time
2121
+ try_to_timestamp try_url_decode try_validate_utf8 tuple_difference_double tuple_difference_integer
2122
+ tuple_difference_theta_double tuple_difference_theta_integer tuple_sketch_estimate_double
2123
+ tuple_sketch_estimate_integer tuple_sketch_theta_double tuple_sketch_theta_integer typeof ucase unbase64 unhex
2124
+ unix_date unix_micros unix_millis unix_nanos unix_seconds unwrap_udt upper url_decode url_encode validate_utf8
2125
+ var_pop var_samp variance vector_avg vector_cosine_similarity vector_inner_product vector_l2_distance
2126
+ vector_norm vector_normalize vector_sum weekday weekofyear width_bucket window_time xpath xpath_boolean
2127
+ xpath_double xpath_float xpath_int xpath_long xpath_number xpath_short xpath_string xxhash64 year years
2128
+ zeroifnull
2129
+ ].freeze
841
2130
 
842
2131
  UNIFORM.each do |fn|
843
2132
  define_method(fn) { |*cols| Column.invoke(fn, *cols.map { |c| _col(c) }) }
@@ -845,10 +2134,10 @@ module SparkConnect
845
2134
 
846
2135
  # No-argument functions.
847
2136
  NO_ARG = %w[
848
- current_date current_timestamp now current_timezone current_user current_catalog
849
- current_database current_schema monotonically_increasing_id spark_partition_id
850
- input_file_name input_file_block_start input_file_block_length version uuid
851
- row_number rank dense_rank percent_rank cume_dist
2137
+ cume_dist curdate current_catalog current_database current_date current_path current_schema current_timestamp
2138
+ current_timezone current_user dense_rank e input_file_block_length input_file_block_start input_file_name
2139
+ localtimestamp monotonically_increasing_id now percent_rank pi rank row_number session_user spark_partition_id
2140
+ user version
852
2141
  ].freeze
853
2142
 
854
2143
  NO_ARG.each do |fn|
@@ -873,6 +2162,167 @@ module SparkConnect
873
2162
  value.is_a?(Column) ? value : lit(value)
874
2163
  end
875
2164
 
2165
+ # Invoke `name` over ColumnOrName arguments.
2166
+ # @api private
2167
+ def _invoke(name, *cols) = Column.invoke(name, *cols.map { |c| _col(c) })
2168
+
2169
+ # A ColumnOrName argument, or the literal `default` when omitted (nil).
2170
+ # @api private
2171
+ def _col_or_default(value, default) = value.nil? ? lit(default) : _col(value)
2172
+
2173
+ # Invoke `name` over ColumnOrName `cols` followed by the given (non-nil)
2174
+ # optional literal arguments.
2175
+ # @api private
2176
+ def _optional_literal_tail(name, cols, tail)
2177
+ Column.invoke(name, *cols.map { |c| _col(c) }, *tail.compact.map { |v| lit(v) })
2178
+ end
2179
+
2180
+ # Trailing lg_nom_entries/mode literals of the tuple sketch functions.
2181
+ # @api private
2182
+ def _tuple_defaults(lg_nom_entries, mode)
2183
+ [lit(lg_nom_entries.nil? ? 12 : lg_nom_entries), lit(mode.nil? ? "sum" : mode)]
2184
+ end
2185
+
2186
+ # Shared body of listagg/string_agg and their _distinct variants.
2187
+ # @api private
2188
+ def _agg_with_delimiter(name, col, delimiter, is_distinct: false)
2189
+ args = [_col(col)]
2190
+ args << lit(delimiter) unless delimiter.nil?
2191
+ Column.invoke(name, *args, is_distinct: is_distinct)
2192
+ end
2193
+
2194
+ # A percentage argument: a list becomes an `array(...)` of literals, like PySpark.
2195
+ # @api private
2196
+ def _percentage(percentage)
2197
+ percentage.is_a?(Array) ? array(*percentage.map { |p| lit(p) }) : lit(percentage)
2198
+ end
2199
+
2200
+ # A random seed literal (a 64-bit long, like PySpark's client-side seed) when
2201
+ # `seed` is nil, otherwise `seed` as a literal/Column.
2202
+ # @api private
2203
+ def _seed(seed)
2204
+ return lit(seed) unless seed.nil?
2205
+
2206
+ Column.new(Proto::Expression.new(literal: Proto::Expression::Literal.new(long: Random.rand(2**63))))
2207
+ end
2208
+
2209
+ # `f(*cols)` and `f([cols])` are equivalent, like PySpark.
2210
+ # @api private
2211
+ def _unwrap_list(cols) = cols.size == 1 && cols.first.is_a?(Array) ? cols.first : cols
2212
+
2213
+ # @api private
2214
+ def _at_least_two(name, cols)
2215
+ raise IllegalArgumentError, "#{name} requires at least 2 columns, got #{cols.size}" if cols.size < 2
2216
+
2217
+ _invoke(name, *cols)
2218
+ end
2219
+
2220
+ # @api private
2221
+ def _check_str_or_col(arg_name, value)
2222
+ return if value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Column)
2223
+
2224
+ raise IllegalArgumentError, "#{arg_name} must be a String or Column, got #{value.class}"
2225
+ end
2226
+
2227
+ # @api private
2228
+ def _check_str(arg_name, value)
2229
+ raise IllegalArgumentError, "#{arg_name} must be a String, got #{value.class}" unless value.is_a?(String)
2230
+ end
2231
+
2232
+ # Spark's trim functions take the trim characters first.
2233
+ # @api private
2234
+ def _trim(name, col, trim) = trim.nil? ? _invoke(name, col) : _invoke(name, trim, col)
2235
+
2236
+ # Shared body of aes_decrypt/try_aes_decrypt (trailing defaults omitted like PySpark).
2237
+ # @api private
2238
+ def _aes_decrypt(name, input, key, mode, padding, aad)
2239
+ Column.invoke(name, _col(input), _col(key), _col_or_default(mode, "GCM"), _col_or_default(padding, "DEFAULT"),
2240
+ _col_or_default(aad, ""))
2241
+ end
2242
+
2243
+ # Shared body of make_interval/try_make_interval (PySpark defaults).
2244
+ # @api private
2245
+ def _make_interval(name, years, months, weeks, days, hours, mins, secs)
2246
+ parts = [years, months, weeks, days, hours, mins].map { |v| _col_or_default(v, 0) }
2247
+ Column.invoke(name, *parts, _col_or_default(secs, BigDecimal("0")))
2248
+ end
2249
+
2250
+ # Shared body of the make_timestamp family (parts or date/time form).
2251
+ # @api private
2252
+ def _make_timestamp(name, parts, date, time, timezone, allow_timezone:)
2253
+ if parts.empty?
2254
+ raise IllegalArgumentError, "#{name} requires either the date/time parts or date: and time:" if date.nil? || time.nil?
2255
+
2256
+ args = [date, time]
2257
+ else
2258
+ unless date.nil? && time.nil?
2259
+ raise IllegalArgumentError, "#{name}: years|months|days|hours|mins|secs and date|time cannot be set together"
2260
+ end
2261
+
2262
+ allowed = allow_timezone ? [6, 7] : [6]
2263
+ raise IllegalArgumentError, "#{name} expects #{allowed.join(' or ')} parts, got #{parts.size}" unless allowed.include?(parts.size)
2264
+ raise IllegalArgumentError, "#{name}: timezone given twice" if parts.size == 7 && !timezone.nil?
2265
+
2266
+ args = parts.first(6)
2267
+ timezone = parts[6] if parts.size == 7
2268
+ end
2269
+ args << timezone unless timezone.nil?
2270
+ _invoke(name, *args)
2271
+ end
2272
+
2273
+ # Shared body of lag/lead (default value omitted when nil).
2274
+ # @api private
2275
+ def _offset_fn(name, col, offset, default)
2276
+ default.nil? ? Column.invoke(name, _col(col), lit(offset)) : Column.invoke(name, _col(col), lit(offset), lit(default))
2277
+ end
2278
+
2279
+ # Shared body of aggregate/reduce (merge and optional finish lambdas).
2280
+ # @api private
2281
+ def _fold(name, col, initial, merge, finish)
2282
+ args = [_col(col), _col(initial), _lambda(merge)]
2283
+ args << _lambda(finish) if finish
2284
+ Column.invoke(name, *args)
2285
+ end
2286
+
2287
+ # An options Hash as a `map(k1, v1, ...)` literal argument, like PySpark.
2288
+ # @api private
2289
+ def _options_to_col(options) = create_map(*options.flat_map { |k, v| [lit(k.to_s), lit(v.to_s)] })
2290
+
2291
+ # Append an options map argument. A nil or empty Hash adds nothing (an empty
2292
+ # map is equivalent to no options).
2293
+ # @api private
2294
+ def _with_options(name, args, options)
2295
+ args += [_options_to_col(options)] unless options.nil? || options.empty?
2296
+ Column.invoke(name, *args)
2297
+ end
2298
+
2299
+ # Shared body of from_json/from_csv/from_xml (options as one map).
2300
+ # @api private
2301
+ def _from_text(name, col, schema_col, options) = _with_options(name, [_col(col), schema_col], options)
2302
+
2303
+ # A schema argument: a DataType becomes its JSON, a String/Column a literal.
2304
+ # @api private
2305
+ def _schema_literal(schema)
2306
+ case schema
2307
+ when Types::DataType then lit(schema.json)
2308
+ when String, Column then lit(schema)
2309
+ when Symbol then lit(schema.to_s)
2310
+ else raise IllegalArgumentError, "schema must be a DataType, String, or Column, got #{schema.class}"
2311
+ end
2312
+ end
2313
+
2314
+ # Shared body of schema_of_json/schema_of_csv/schema_of_xml.
2315
+ # @api private
2316
+ def _schema_of(name, arg_name, sample, options)
2317
+ _check_str_or_col(arg_name, sample)
2318
+ _with_options(name, [lit(sample.is_a?(Symbol) ? sample.to_s : sample)], options)
2319
+ end
2320
+
2321
+ # @api private
2322
+ def _star?(col)
2323
+ col.is_a?(Column) && col.to_expr.expr_type == :unresolved_star
2324
+ end
2325
+
876
2326
  @lambda_counter = 0
877
2327
 
878
2328
  class << self
@@ -884,6 +2334,8 @@ module SparkConnect
884
2334
  # called with one or more lambda-variable columns and must return a {Column}.
885
2335
  # @api private
886
2336
  def _lambda(block)
2337
+ raise IllegalArgumentError, "a block (or lambda) is required" if block.nil?
2338
+
887
2339
  arity = block.arity.negative? ? 1 : [block.arity, 1].max
888
2340
  Functions.lambda_counter += 1
889
2341
  names = (0...arity).map { |i| "x_#{Functions.lambda_counter}_#{i}" }
@@ -892,6 +2344,8 @@ module SparkConnect
892
2344
  end
893
2345
  cols = vars.map { |v| Column.new(Proto::Expression.new(unresolved_named_lambda_variable: v)) }
894
2346
  body = block.call(*cols)
2347
+ raise IllegalArgumentError, "the lambda must return a Column, got #{body.class}" unless body.is_a?(Column)
2348
+
895
2349
  Column.new(Proto::Expression.new(
896
2350
  lambda_function: Proto::Expression::LambdaFunction.new(function: body.to_expr, arguments: vars)
897
2351
  ))