-
Notifications
You must be signed in to change notification settings - Fork 28k
/
functions.R
2205 lines (2072 loc) · 57.6 KB
/
functions.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#' @include generics.R column.R
NULL
#' lit
#'
#' A new \linkS4class{Column} is created to represent the literal value.
#' If the parameter is a \linkS4class{Column}, it is returned unchanged.
#'
#' @family normal_funcs
#' @rdname lit
#' @name lit
#' @export
#' @examples
#' \dontrun{
#' lit(df$name)
#' select(df, lit("x"))
#' select(df, lit("2015-01-01"))
#'}
setMethod("lit", signature("ANY"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions",
"lit",
ifelse(class(x) == "Column", x@jc, x))
column(jc)
})
#' abs
#'
#' Computes the absolute value.
#'
#' @rdname abs
#' @name abs
#' @family normal_funcs
#' @export
#' @examples \dontrun{abs(df$c)}
setMethod("abs",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "abs", x@jc)
column(jc)
})
#' acos
#'
#' Computes the cosine inverse of the given value; the returned angle is in the range
#' 0.0 through pi.
#'
#' @rdname acos
#' @name acos
#' @family math_funcs
#' @export
#' @examples \dontrun{acos(df$c)}
setMethod("acos",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "acos", x@jc)
column(jc)
})
#' approxCountDistinct
#'
#' Aggregate function: returns the approximate number of distinct items in a group.
#'
#' @rdname approxCountDistinct
#' @name approxCountDistinct
#' @family agg_funcs
#' @export
#' @examples \dontrun{approxCountDistinct(df$c)}
setMethod("approxCountDistinct",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "approxCountDistinct", x@jc)
column(jc)
})
#' ascii
#'
#' Computes the numeric value of the first character of the string column, and returns the
#' result as a int column.
#'
#' @rdname ascii
#' @name ascii
#' @family string_funcs
#' @export
#' @examples \dontrun{\dontrun{ascii(df$c)}}
setMethod("ascii",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "ascii", x@jc)
column(jc)
})
#' asin
#'
#' Computes the sine inverse of the given value; the returned angle is in the range
#' -pi/2 through pi/2.
#'
#' @rdname asin
#' @name asin
#' @family math_funcs
#' @export
#' @examples \dontrun{asin(df$c)}
setMethod("asin",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "asin", x@jc)
column(jc)
})
#' atan
#'
#' Computes the tangent inverse of the given value.
#'
#' @rdname atan
#' @name atan
#' @family math_funcs
#' @export
#' @examples \dontrun{atan(df$c)}
setMethod("atan",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "atan", x@jc)
column(jc)
})
#' avg
#'
#' Aggregate function: returns the average of the values in a group.
#'
#' @rdname avg
#' @name avg
#' @family agg_funcs
#' @export
#' @examples \dontrun{avg(df$c)}
setMethod("avg",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "avg", x@jc)
column(jc)
})
#' base64
#'
#' Computes the BASE64 encoding of a binary column and returns it as a string column.
#' This is the reverse of unbase64.
#'
#' @rdname base64
#' @name base64
#' @family string_funcs
#' @export
#' @examples \dontrun{base64(df$c)}
setMethod("base64",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "base64", x@jc)
column(jc)
})
#' bin
#'
#' An expression that returns the string representation of the binary value of the given long
#' column. For example, bin("12") returns "1100".
#'
#' @rdname bin
#' @name bin
#' @family math_funcs
#' @export
#' @examples \dontrun{bin(df$c)}
setMethod("bin",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "bin", x@jc)
column(jc)
})
#' bitwiseNOT
#'
#' Computes bitwise NOT.
#'
#' @rdname bitwiseNOT
#' @name bitwiseNOT
#' @family normal_funcs
#' @export
#' @examples \dontrun{bitwiseNOT(df$c)}
setMethod("bitwiseNOT",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "bitwiseNOT", x@jc)
column(jc)
})
#' cbrt
#'
#' Computes the cube-root of the given value.
#'
#' @rdname cbrt
#' @name cbrt
#' @family math_funcs
#' @export
#' @examples \dontrun{cbrt(df$c)}
setMethod("cbrt",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "cbrt", x@jc)
column(jc)
})
#' ceil
#'
#' Computes the ceiling of the given value.
#'
#' @rdname ceil
#' @name ceil
#' @family math_funcs
#' @export
#' @examples \dontrun{ceil(df$c)}
setMethod("ceil",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "ceil", x@jc)
column(jc)
})
#' Though scala functions has "col" function, we don't expose it in SparkR
#' because we don't want to conflict with the "col" function in the R base
#' package and we also have "column" function exported which is an alias of "col".
col <- function(x) {
column(callJStatic("org.apache.spark.sql.functions", "col", x))
}
#' column
#'
#' Returns a Column based on the given column name.
#'
#' @rdname col
#' @name column
#' @family normal_funcs
#' @export
#' @examples \dontrun{column(df)}
setMethod("column",
signature(x = "character"),
function(x) {
col(x)
})
#' cos
#'
#' Computes the cosine of the given value.
#'
#' @rdname cos
#' @name cos
#' @family math_funcs
#' @export
#' @examples \dontrun{cos(df$c)}
setMethod("cos",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "cos", x@jc)
column(jc)
})
#' cosh
#'
#' Computes the hyperbolic cosine of the given value.
#'
#' @rdname cosh
#' @name cosh
#' @family math_funcs
#' @export
#' @examples \dontrun{cosh(df$c)}
setMethod("cosh",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "cosh", x@jc)
column(jc)
})
#' count
#'
#' Aggregate function: returns the number of items in a group.
#'
#' @rdname count
#' @name count
#' @family agg_funcs
#' @export
#' @examples \dontrun{count(df$c)}
setMethod("count",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "count", x@jc)
column(jc)
})
#' crc32
#'
#' Calculates the cyclic redundancy check value (CRC32) of a binary column and
#' returns the value as a bigint.
#'
#' @rdname crc32
#' @name crc32
#' @family misc_funcs
#' @export
#' @examples \dontrun{crc32(df$c)}
setMethod("crc32",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "crc32", x@jc)
column(jc)
})
#' dayofmonth
#'
#' Extracts the day of the month as an integer from a given date/timestamp/string.
#'
#' @rdname dayofmonth
#' @name dayofmonth
#' @family datetime_funcs
#' @export
#' @examples \dontrun{dayofmonth(df$c)}
setMethod("dayofmonth",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "dayofmonth", x@jc)
column(jc)
})
#' dayofyear
#'
#' Extracts the day of the year as an integer from a given date/timestamp/string.
#'
#' @rdname dayofyear
#' @name dayofyear
#' @family datetime_funcs
#' @export
#' @examples \dontrun{dayofyear(df$c)}
setMethod("dayofyear",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "dayofyear", x@jc)
column(jc)
})
#' exp
#'
#' Computes the exponential of the given value.
#'
#' @rdname exp
#' @name exp
#' @family math_funcs
#' @export
#' @examples \dontrun{exp(df$c)}
setMethod("exp",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "exp", x@jc)
column(jc)
})
#' explode
#'
#' Creates a new row for each element in the given array or map column.
#'
#' @rdname explode
#' @name explode
#' @family collection_funcs
#' @export
#' @examples \dontrun{explode(df$c)}
setMethod("explode",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "explode", x@jc)
column(jc)
})
#' expm1
#'
#' Computes the exponential of the given value minus one.
#'
#' @rdname expm1
#' @name expm1
#' @family math_funcs
#' @export
#' @examples \dontrun{expm1(df$c)}
setMethod("expm1",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "expm1", x@jc)
column(jc)
})
#' factorial
#'
#' Computes the factorial of the given value.
#'
#' @rdname factorial
#' @name factorial
#' @family math_funcs
#' @export
#' @examples \dontrun{factorial(df$c)}
setMethod("factorial",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "factorial", x@jc)
column(jc)
})
#' first
#'
#' Aggregate function: returns the first value in a group.
#'
#' @rdname first
#' @name first
#' @family agg_funcs
#' @export
#' @examples \dontrun{first(df$c)}
setMethod("first",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "first", x@jc)
column(jc)
})
#' floor
#'
#' Computes the floor of the given value.
#'
#' @rdname floor
#' @name floor
#' @family math_funcs
#' @export
#' @examples \dontrun{floor(df$c)}
setMethod("floor",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "floor", x@jc)
column(jc)
})
#' hex
#'
#' Computes hex value of the given column.
#'
#' @rdname hex
#' @name hex
#' @family math_funcs
#' @export
#' @examples \dontrun{hex(df$c)}
setMethod("hex",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "hex", x@jc)
column(jc)
})
#' hour
#'
#' Extracts the hours as an integer from a given date/timestamp/string.
#'
#' @rdname hour
#' @name hour
#' @family datetime_funcs
#' @export
#' @examples \dontrun{hour(df$c)}
setMethod("hour",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "hour", x@jc)
column(jc)
})
#' initcap
#'
#' Returns a new string column by converting the first letter of each word to uppercase.
#' Words are delimited by whitespace.
#'
#' For example, "hello world" will become "Hello World".
#'
#' @rdname initcap
#' @name initcap
#' @family string_funcs
#' @export
#' @examples \dontrun{initcap(df$c)}
setMethod("initcap",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "initcap", x@jc)
column(jc)
})
#' isNaN
#'
#' Return true iff the column is NaN.
#'
#' @rdname isNaN
#' @name isNaN
#' @family normal_funcs
#' @export
#' @examples \dontrun{isNaN(df$c)}
setMethod("isNaN",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "isNaN", x@jc)
column(jc)
})
#' last
#'
#' Aggregate function: returns the last value in a group.
#'
#' @rdname last
#' @name last
#' @family agg_funcs
#' @export
#' @examples \dontrun{last(df$c)}
setMethod("last",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "last", x@jc)
column(jc)
})
#' last_day
#'
#' Given a date column, returns the last day of the month which the given date belongs to.
#' For example, input "2015-07-27" returns "2015-07-31" since July 31 is the last day of the
#' month in July 2015.
#'
#' @rdname last_day
#' @name last_day
#' @family datetime_funcs
#' @export
#' @examples \dontrun{last_day(df$c)}
setMethod("last_day",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "last_day", x@jc)
column(jc)
})
#' length
#'
#' Computes the length of a given string or binary column.
#'
#' @rdname length
#' @name length
#' @family string_funcs
#' @export
#' @examples \dontrun{length(df$c)}
setMethod("length",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "length", x@jc)
column(jc)
})
#' log
#'
#' Computes the natural logarithm of the given value.
#'
#' @rdname log
#' @name log
#' @family math_funcs
#' @export
#' @examples \dontrun{log(df$c)}
setMethod("log",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "log", x@jc)
column(jc)
})
#' log10
#'
#' Computes the logarithm of the given value in base 10.
#'
#' @rdname log10
#' @name log10
#' @family math_funcs
#' @export
#' @examples \dontrun{log10(df$c)}
setMethod("log10",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "log10", x@jc)
column(jc)
})
#' log1p
#'
#' Computes the natural logarithm of the given value plus one.
#'
#' @rdname log1p
#' @name log1p
#' @family math_funcs
#' @export
#' @examples \dontrun{log1p(df$c)}
setMethod("log1p",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "log1p", x@jc)
column(jc)
})
#' log2
#'
#' Computes the logarithm of the given column in base 2.
#'
#' @rdname log2
#' @name log2
#' @family math_funcs
#' @export
#' @examples \dontrun{log2(df$c)}
setMethod("log2",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "log2", x@jc)
column(jc)
})
#' lower
#'
#' Converts a string column to lower case.
#'
#' @rdname lower
#' @name lower
#' @family string_funcs
#' @export
#' @examples \dontrun{lower(df$c)}
setMethod("lower",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "lower", x@jc)
column(jc)
})
#' ltrim
#'
#' Trim the spaces from left end for the specified string value.
#'
#' @rdname ltrim
#' @name ltrim
#' @family string_funcs
#' @export
#' @examples \dontrun{ltrim(df$c)}
setMethod("ltrim",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "ltrim", x@jc)
column(jc)
})
#' max
#'
#' Aggregate function: returns the maximum value of the expression in a group.
#'
#' @rdname max
#' @name max
#' @family agg_funcs
#' @export
#' @examples \dontrun{max(df$c)}
setMethod("max",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "max", x@jc)
column(jc)
})
#' md5
#'
#' Calculates the MD5 digest of a binary column and returns the value
#' as a 32 character hex string.
#'
#' @rdname md5
#' @name md5
#' @family misc_funcs
#' @export
#' @examples \dontrun{md5(df$c)}
setMethod("md5",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "md5", x@jc)
column(jc)
})
#' mean
#'
#' Aggregate function: returns the average of the values in a group.
#' Alias for avg.
#'
#' @rdname mean
#' @name mean
#' @family agg_funcs
#' @export
#' @examples \dontrun{mean(df$c)}
setMethod("mean",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "mean", x@jc)
column(jc)
})
#' min
#'
#' Aggregate function: returns the minimum value of the expression in a group.
#'
#' @rdname min
#' @name min
#' @family agg_funcs
#' @export
#' @examples \dontrun{min(df$c)}
setMethod("min",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "min", x@jc)
column(jc)
})
#' minute
#'
#' Extracts the minutes as an integer from a given date/timestamp/string.
#'
#' @rdname minute
#' @name minute
#' @family datetime_funcs
#' @export
#' @examples \dontrun{minute(df$c)}
setMethod("minute",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "minute", x@jc)
column(jc)
})
#' month
#'
#' Extracts the month as an integer from a given date/timestamp/string.
#'
#' @rdname month
#' @name month
#' @family datetime_funcs
#' @export
#' @examples \dontrun{month(df$c)}
setMethod("month",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "month", x@jc)
column(jc)
})
#' negate
#'
#' Unary minus, i.e. negate the expression.
#'
#' @rdname negate
#' @name negate
#' @family normal_funcs
#' @export
#' @examples \dontrun{negate(df$c)}
setMethod("negate",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "negate", x@jc)
column(jc)
})
#' quarter
#'
#' Extracts the quarter as an integer from a given date/timestamp/string.
#'
#' @rdname quarter
#' @name quarter
#' @family datetime_funcs
#' @export
#' @examples \dontrun{quarter(df$c)}
setMethod("quarter",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "quarter", x@jc)
column(jc)
})
#' reverse
#'
#' Reverses the string column and returns it as a new string column.
#'
#' @rdname reverse
#' @name reverse
#' @family string_funcs
#' @export
#' @examples \dontrun{reverse(df$c)}
setMethod("reverse",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "reverse", x@jc)
column(jc)
})
#' rint
#'
#' Returns the double value that is closest in value to the argument and
#' is equal to a mathematical integer.
#'
#' @rdname rint
#' @name rint
#' @family math_funcs
#' @export
#' @examples \dontrun{rint(df$c)}
setMethod("rint",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "rint", x@jc)
column(jc)
})
#' round
#'
#' Returns the value of the column `e` rounded to 0 decimal places.
#'
#' @rdname round
#' @name round
#' @family math_funcs
#' @export
#' @examples \dontrun{round(df$c)}
setMethod("round",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "round", x@jc)
column(jc)
})
#' rtrim
#'
#' Trim the spaces from right end for the specified string value.
#'
#' @rdname rtrim
#' @name rtrim
#' @family string_funcs
#' @export
#' @examples \dontrun{rtrim(df$c)}
setMethod("rtrim",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "rtrim", x@jc)
column(jc)
})
#' second
#'
#' Extracts the seconds as an integer from a given date/timestamp/string.
#'
#' @rdname second
#' @name second
#' @family datetime_funcs
#' @export
#' @examples \dontrun{second(df$c)}
setMethod("second",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "second", x@jc)
column(jc)
})
#' sha1
#'
#' Calculates the SHA-1 digest of a binary column and returns the value
#' as a 40 character hex string.
#'
#' @rdname sha1
#' @name sha1
#' @family misc_funcs
#' @export
#' @examples \dontrun{sha1(df$c)}
setMethod("sha1",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "sha1", x@jc)
column(jc)
})
#' signum
#'
#' Computes the signum of the given value.
#'
#' @rdname signum
#' @name signum
#' @family math_funcs
#' @export
#' @examples \dontrun{signum(df$c)}
setMethod("signum",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "signum", x@jc)
column(jc)
})
#' sin
#'
#' Computes the sine of the given value.
#'
#' @rdname sin
#' @name sin
#' @family math_funcs
#' @export
#' @examples \dontrun{sin(df$c)}
setMethod("sin",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "sin", x@jc)
column(jc)
})
#' sinh
#'
#' Computes the hyperbolic sine of the given value.
#'
#' @rdname sinh
#' @name sinh
#' @family math_funcs
#' @export
#' @examples \dontrun{sinh(df$c)}
setMethod("sinh",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "sinh", x@jc)
column(jc)
})
#' size
#'
#' Returns length of array or map.
#'
#' @rdname size
#' @name size
#' @family collection_funcs
#' @export
#' @examples \dontrun{size(df$c)}
setMethod("size",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "size", x@jc)
column(jc)
})
#' soundex
#'
#' Return the soundex code for the specified expression.
#'
#' @rdname soundex
#' @name soundex
#' @family string_funcs
#' @export
#' @examples \dontrun{soundex(df$c)}
setMethod("soundex",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "soundex", x@jc)
column(jc)
})
#' sqrt
#'
#' Computes the square root of the specified float value.
#'
#' @rdname sqrt
#' @name sqrt
#' @family math_funcs
#' @export
#' @examples \dontrun{sqrt(df$c)}
setMethod("sqrt",
signature(x = "Column"),
function(x) {
jc <- callJStatic("org.apache.spark.sql.functions", "sqrt", x@jc)
column(jc)
})
#' sum
#'
#' Aggregate function: returns the sum of all values in the expression.
#'
#' @rdname sum
#' @name sum
#' @family agg_funcs
#' @export