@@ -26,7 +26,7 @@ column <- function(jc) {
26
26
# TODO: change Dsl to functions once update spark-sql
27
27
# A helper function to create a column from name
28
28
col <- function (x ) {
29
- column(callJStatic(" org.apache.spark.sql.Dsl " , " col" , x ))
29
+ column(callJStatic(" org.apache.spark.sql.functions " , " col" , x ))
30
30
}
31
31
32
32
# TODO(davies): like, rlike, startwith, substr, getField, getItem
@@ -38,7 +38,7 @@ operators <- list(
38
38
)
39
39
40
40
functions <- c(" min" , " max" , " sum" , " avg" , " mean" , " count" , " abs" , " sqrt" ,
41
- " first" , " last" , " asc " , " desc " , " lower" , " upper" , " sumDistinct" ,
41
+ " first" , " last" , " lower" , " upper" , " sumDistinct" ,
42
42
" isNull" , " isNotNull" )
43
43
44
44
createOperator <- function (op ) {
@@ -65,7 +65,7 @@ createFunction <- function(name) {
65
65
setMethod(name ,
66
66
signature(x = " Column" ),
67
67
function (x ) {
68
- jc <- callJStatic(" org.apache.spark.sql.Dsl " , name , x @ jc )
68
+ jc <- callJStatic(" org.apache.spark.sql.functions " , name , x @ jc )
69
69
column(jc )
70
70
})
71
71
}
@@ -77,8 +77,6 @@ createMethods <- function() {
77
77
78
78
setGeneric ("avg ", function(x) { standardGeneric("avg") })
79
79
setGeneric ("last ", function(x) { standardGeneric("last") })
80
- setGeneric ("asc ", function(x) { standardGeneric("asc") })
81
- setGeneric ("desc ", function(x) { standardGeneric("desc") })
82
80
setGeneric ("lower ", function(x) { standardGeneric("lower") })
83
81
setGeneric ("upper ", function(x) { standardGeneric("upper") })
84
82
setGeneric ("isNull ", function(x) { standardGeneric("isNull") })
@@ -92,6 +90,24 @@ createMethods <- function() {
92
90
93
91
createMethods()
94
92
93
+ setGeneric ("asc ", function(x) { standardGeneric("asc") })
94
+
95
+ setMethod ("asc ",
96
+ signature(x = " Column" ),
97
+ function (x ) {
98
+ jc <- callJMethod(x @ jc , " asc" )
99
+ column(jc )
100
+ })
101
+
102
+ setGeneric ("desc ", function(x) { standardGeneric("desc") })
103
+
104
+ setMethod ("desc ",
105
+ signature(x = " Column" ),
106
+ function (x ) {
107
+ jc <- callJMethod(x @ jc , " desc" )
108
+ column(jc )
109
+ })
110
+
95
111
setMethod ("alias ",
96
112
signature(object = " Column" ),
97
113
function (object , data ) {
@@ -117,7 +133,7 @@ setGeneric("approxCountDistinct", function(x, ...) { standardGeneric("approxCoun
117
133
setMethod ("approxCountDistinct ",
118
134
signature(x = " Column" ),
119
135
function (x , rsd = 0.95 ) {
120
- jc <- callJStatic(" org.apache.spark.sql.Dsl " , " approxCountDistinct" , x @ jc , rsd )
136
+ jc <- callJStatic(" org.apache.spark.sql.functions " , " approxCountDistinct" , x @ jc , rsd )
121
137
column(jc )
122
138
})
123
139
@@ -129,7 +145,7 @@ setMethod("countDistinct",
129
145
jcol <- lapply(list (... ), function (x ) {
130
146
x @ jc
131
147
})
132
- jc <- callJStatic(" org.apache.spark.sql.Dsl " , " countDistinct" , x @ jc , listToSeq(jcol ))
148
+ jc <- callJStatic(" org.apache.spark.sql.functions " , " countDistinct" , x @ jc , listToSeq(jcol ))
133
149
column(jc )
134
150
})
135
151
0 commit comments