Skip to content

Commit 9e5c04b

Browse files
Merge remote-tracking branch 'asf/master' into am-log-link
2 parents b3f9b9d + 8730fbb commit 9e5c04b

File tree

298 files changed

+12143
-4387
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

298 files changed

+12143
-4387
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ The following components are provided under a BSD-style license. See project lin
861861

862862
(BSD 3 Clause) core (com.github.fommil.netlib:core:1.1.2 - https://github.com/fommil/netlib-java/core)
863863
(BSD 3 Clause) JPMML-Model (org.jpmml:pmml-model:1.1.15 - https://github.com/jpmml/jpmml-model)
864-
(BSD 3-clause style license) jblas (org.jblas:jblas:1.2.3 - http://jblas.org/)
864+
(BSD 3-clause style license) jblas (org.jblas:jblas:1.2.4 - http://jblas.org/)
865865
(BSD License) AntLR Parser Generator (antlr:antlr:2.7.7 - http://www.antlr.org/)
866866
(BSD License) Javolution (javolution:javolution:5.5.1 - http://javolution.org)
867867
(BSD licence) ANTLR ST4 4.0.4 (org.antlr:ST4:4.0.4 - http://www.stringtemplate.org)

R/pkg/NAMESPACE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,56 @@ exportMethods("arrange",
5959
exportClasses("Column")
6060

6161
exportMethods("abs",
62+
"acos",
6263
"alias",
6364
"approxCountDistinct",
6465
"asc",
66+
"asin",
67+
"atan",
68+
"atan2",
6569
"avg",
6670
"cast",
71+
"cbrt",
72+
"ceiling",
6773
"contains",
74+
"cos",
75+
"cosh",
6876
"countDistinct",
6977
"desc",
7078
"endsWith",
79+
"exp",
80+
"expm1",
81+
"floor",
7182
"getField",
7283
"getItem",
84+
"hypot",
7385
"isNotNull",
7486
"isNull",
7587
"last",
7688
"like",
89+
"log",
90+
"log10",
91+
"log1p",
7792
"lower",
7893
"max",
7994
"mean",
8095
"min",
8196
"n",
8297
"n_distinct",
98+
"rint",
8399
"rlike",
100+
"sign",
101+
"sin",
102+
"sinh",
84103
"sqrt",
85104
"startsWith",
86105
"substr",
87106
"sum",
88107
"sumDistinct",
108+
"tan",
109+
"tanh",
110+
"toDegrees",
111+
"toRadians",
89112
"upper")
90113

91114
exportClasses("GroupedData")

R/pkg/R/column.R

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ operators <- list(
5555
"+" = "plus", "-" = "minus", "*" = "multiply", "/" = "divide", "%%" = "mod",
5656
"==" = "equalTo", ">" = "gt", "<" = "lt", "!=" = "notEqual", "<=" = "leq", ">=" = "geq",
5757
# we can not override `&&` and `||`, so use `&` and `|` instead
58-
"&" = "and", "|" = "or" #, "!" = "unary_$bang"
58+
"&" = "and", "|" = "or", #, "!" = "unary_$bang"
59+
"^" = "pow"
5960
)
6061
column_functions1 <- c("asc", "desc", "isNull", "isNotNull")
6162
column_functions2 <- c("like", "rlike", "startsWith", "endsWith", "getField", "getItem", "contains")
6263
functions <- c("min", "max", "sum", "avg", "mean", "count", "abs", "sqrt",
63-
"first", "last", "lower", "upper", "sumDistinct")
64+
"first", "last", "lower", "upper", "sumDistinct",
65+
"acos", "asin", "atan", "cbrt", "ceiling", "cos", "cosh", "exp",
66+
"expm1", "floor", "log", "log10", "log1p", "rint", "sign",
67+
"sin", "sinh", "tan", "tanh", "toDegrees", "toRadians")
68+
binary_mathfunctions<- c("atan2", "hypot")
6469

6570
createOperator <- function(op) {
6671
setMethod(op,
@@ -76,7 +81,11 @@ createOperator <- function(op) {
7681
if (class(e2) == "Column") {
7782
e2 <- e2@jc
7883
}
79-
callJMethod(e1@jc, operators[[op]], e2)
84+
if (op == "^") {
85+
jc <- callJStatic("org.apache.spark.sql.functions", operators[[op]], e1@jc, e2)
86+
} else {
87+
callJMethod(e1@jc, operators[[op]], e2)
88+
}
8089
}
8190
column(jc)
8291
})
@@ -106,11 +115,29 @@ createStaticFunction <- function(name) {
106115
setMethod(name,
107116
signature(x = "Column"),
108117
function(x) {
118+
if (name == "ceiling") {
119+
name <- "ceil"
120+
}
121+
if (name == "sign") {
122+
name <- "signum"
123+
}
109124
jc <- callJStatic("org.apache.spark.sql.functions", name, x@jc)
110125
column(jc)
111126
})
112127
}
113128

129+
createBinaryMathfunctions <- function(name) {
130+
setMethod(name,
131+
signature(y = "Column"),
132+
function(y, x) {
133+
if (class(x) == "Column") {
134+
x <- x@jc
135+
}
136+
jc <- callJStatic("org.apache.spark.sql.functions", name, y@jc, x)
137+
column(jc)
138+
})
139+
}
140+
114141
createMethods <- function() {
115142
for (op in names(operators)) {
116143
createOperator(op)
@@ -124,6 +151,9 @@ createMethods <- function() {
124151
for (x in functions) {
125152
createStaticFunction(x)
126153
}
154+
for (name in binary_mathfunctions) {
155+
createBinaryMathfunctions(name)
156+
}
127157
}
128158

129159
createMethods()

R/pkg/R/generics.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ setGeneric("avg", function(x, ...) { standardGeneric("avg") })
552552
#' @export
553553
setGeneric("cast", function(x, dataType) { standardGeneric("cast") })
554554

555+
#' @rdname column
556+
#' @export
557+
setGeneric("cbrt", function(x) { standardGeneric("cbrt") })
558+
555559
#' @rdname column
556560
#' @export
557561
setGeneric("contains", function(x, ...) { standardGeneric("contains") })
@@ -575,6 +579,10 @@ setGeneric("getField", function(x, ...) { standardGeneric("getField") })
575579
#' @export
576580
setGeneric("getItem", function(x, ...) { standardGeneric("getItem") })
577581

582+
#' @rdname column
583+
#' @export
584+
setGeneric("hypot", function(y, x) { standardGeneric("hypot") })
585+
578586
#' @rdname column
579587
#' @export
580588
setGeneric("isNull", function(x) { standardGeneric("isNull") })
@@ -603,6 +611,10 @@ setGeneric("n", function(x) { standardGeneric("n") })
603611
#' @export
604612
setGeneric("n_distinct", function(x, ...) { standardGeneric("n_distinct") })
605613

614+
#' @rdname column
615+
#' @export
616+
setGeneric("rint", function(x, ...) { standardGeneric("rint") })
617+
606618
#' @rdname column
607619
#' @export
608620
setGeneric("rlike", function(x, ...) { standardGeneric("rlike") })
@@ -615,6 +627,14 @@ setGeneric("startsWith", function(x, ...) { standardGeneric("startsWith") })
615627
#' @export
616628
setGeneric("sumDistinct", function(x) { standardGeneric("sumDistinct") })
617629

630+
#' @rdname column
631+
#' @export
632+
setGeneric("toDegrees", function(x) { standardGeneric("toDegrees") })
633+
634+
#' @rdname column
635+
#' @export
636+
setGeneric("toRadians", function(x) { standardGeneric("toRadians") })
637+
618638
#' @rdname column
619639
#' @export
620640
setGeneric("upper", function(x) { standardGeneric("upper") })

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ test_that("column operators", {
530530
c2 <- (- c + 1 - 2) * 3 / 4.0
531531
c3 <- (c + c2 - c2) * c2 %% c2
532532
c4 <- (c > c2) & (c2 <= c3) | (c == c2) & (c2 != c3)
533+
c5 <- c2 ^ c3 ^ c4
533534
})
534535

535536
test_that("column functions", {
@@ -538,6 +539,29 @@ test_that("column functions", {
538539
c3 <- lower(c) + upper(c) + first(c) + last(c)
539540
c4 <- approxCountDistinct(c) + countDistinct(c) + cast(c, "string")
540541
c5 <- n(c) + n_distinct(c)
542+
c5 <- acos(c) + asin(c) + atan(c) + cbrt(c)
543+
c6 <- ceiling(c) + cos(c) + cosh(c) + exp(c) + expm1(c)
544+
c7 <- floor(c) + log(c) + log10(c) + log1p(c) + rint(c)
545+
c8 <- sign(c) + sin(c) + sinh(c) + tan(c) + tanh(c)
546+
c9 <- toDegrees(c) + toRadians(c)
547+
})
548+
549+
test_that("column binary mathfunctions", {
550+
lines <- c("{\"a\":1, \"b\":5}",
551+
"{\"a\":2, \"b\":6}",
552+
"{\"a\":3, \"b\":7}",
553+
"{\"a\":4, \"b\":8}")
554+
jsonPathWithDup <- tempfile(pattern="sparkr-test", fileext=".tmp")
555+
writeLines(lines, jsonPathWithDup)
556+
df <- jsonFile(sqlCtx, jsonPathWithDup)
557+
expect_equal(collect(select(df, atan2(df$a, df$b)))[1, "ATAN2(a, b)"], atan2(1, 5))
558+
expect_equal(collect(select(df, atan2(df$a, df$b)))[2, "ATAN2(a, b)"], atan2(2, 6))
559+
expect_equal(collect(select(df, atan2(df$a, df$b)))[3, "ATAN2(a, b)"], atan2(3, 7))
560+
expect_equal(collect(select(df, atan2(df$a, df$b)))[4, "ATAN2(a, b)"], atan2(4, 8))
561+
expect_equal(collect(select(df, hypot(df$a, df$b)))[1, "HYPOT(a, b)"], sqrt(1^2 + 5^2))
562+
expect_equal(collect(select(df, hypot(df$a, df$b)))[2, "HYPOT(a, b)"], sqrt(2^2 + 6^2))
563+
expect_equal(collect(select(df, hypot(df$a, df$b)))[3, "HYPOT(a, b)"], sqrt(3^2 + 7^2))
564+
expect_equal(collect(select(df, hypot(df$a, df$b)))[4, "HYPOT(a, b)"], sqrt(4^2 + 8^2))
541565
})
542566

543567
test_that("string operators", {
@@ -733,12 +757,12 @@ test_that("parquetFile works with multiple input paths", {
733757
test_that("describe() on a DataFrame", {
734758
df <- jsonFile(sqlCtx, jsonPath)
735759
stats <- describe(df, "age")
736-
expect_true(collect(stats)[1, "summary"] == "count")
737-
expect_true(collect(stats)[2, "age"] == 24.5)
738-
expect_true(collect(stats)[3, "age"] == 5.5)
760+
expect_equal(collect(stats)[1, "summary"], "count")
761+
expect_equal(collect(stats)[2, "age"], "24.5")
762+
expect_equal(collect(stats)[3, "age"], "5.5")
739763
stats <- describe(df)
740-
expect_true(collect(stats)[4, "name"] == "Andy")
741-
expect_true(collect(stats)[5, "age"] == 30.0)
764+
expect_equal(collect(stats)[4, "name"], "Andy")
765+
expect_equal(collect(stats)[5, "age"], "30")
742766
})
743767

744768
unlink(parquetPath)

core/src/main/resources/org/apache/spark/ui/static/dagre-d3.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/main/resources/org/apache/spark/ui/static/spark-dag-viz.css

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,21 @@
1515
* limitations under the License.
1616
*/
1717

18-
#dag-viz-graph svg path {
19-
stroke: #444;
20-
stroke-width: 1.5px;
21-
}
22-
23-
#dag-viz-graph svg g.cluster rect {
24-
stroke-width: 1px;
25-
}
26-
27-
#dag-viz-graph svg g.node circle {
28-
fill: #444;
18+
#dag-viz-graph a, #dag-viz-graph a:hover {
19+
text-decoration: none;
2920
}
3021

31-
#dag-viz-graph svg g.node rect {
32-
fill: #C3EBFF;
33-
stroke: #3EC0FF;
34-
stroke-width: 1px;
22+
#dag-viz-graph .label {
23+
font-weight: normal;
24+
text-shadow: none;
3525
}
3626

37-
#dag-viz-graph svg g.node.cached circle {
38-
fill: #444;
27+
#dag-viz-graph svg path {
28+
stroke: #444;
29+
stroke-width: 1.5px;
3930
}
4031

41-
#dag-viz-graph svg g.node.cached rect {
42-
fill: #B3F5C5;
43-
stroke: #56F578;
32+
#dag-viz-graph svg g.cluster rect {
4433
stroke-width: 1px;
4534
}
4635

@@ -61,12 +50,23 @@
6150
stroke-width: 1px;
6251
}
6352

64-
#dag-viz-graph svg.job g.cluster[class*="stage"] rect {
53+
#dag-viz-graph svg.job g.cluster.skipped rect {
54+
fill: #D6D6D6;
55+
stroke: #B7B7B7;
56+
stroke-width: 1px;
57+
}
58+
59+
#dag-viz-graph svg.job g.cluster.stage rect {
6560
fill: #FFFFFF;
6661
stroke: #FF99AC;
6762
stroke-width: 1px;
6863
}
6964

65+
#dag-viz-graph svg.job g.cluster.stage.skipped rect {
66+
stroke: #ADADAD;
67+
stroke-width: 1px;
68+
}
69+
7070
#dag-viz-graph svg.job g#cross-stage-edges path {
7171
fill: none;
7272
}
@@ -75,6 +75,20 @@
7575
fill: #333;
7676
}
7777

78+
#dag-viz-graph svg.job g.cluster.skipped text {
79+
fill: #666;
80+
}
81+
82+
#dag-viz-graph svg.job g.node circle {
83+
fill: #444;
84+
}
85+
86+
#dag-viz-graph svg.job g.node.cached circle {
87+
fill: #A3F545;
88+
stroke: #52C366;
89+
stroke-width: 2px;
90+
}
91+
7892
/* Stage page specific styles */
7993

8094
#dag-viz-graph svg.stage g.cluster rect {
@@ -83,7 +97,7 @@
8397
stroke-width: 1px;
8498
}
8599

86-
#dag-viz-graph svg.stage g.cluster[class*="stage"] rect {
100+
#dag-viz-graph svg.stage g.cluster.stage rect {
87101
fill: #FFFFFF;
88102
stroke: #FFA6B6;
89103
stroke-width: 1px;
@@ -97,11 +111,14 @@
97111
fill: #333;
98112
}
99113

100-
#dag-viz-graph a, #dag-viz-graph a:hover {
101-
text-decoration: none;
114+
#dag-viz-graph svg.stage g.node rect {
115+
fill: #C3EBFF;
116+
stroke: #3EC0FF;
117+
stroke-width: 1px;
102118
}
103119

104-
#dag-viz-graph .label {
105-
font-weight: normal;
106-
text-shadow: none;
120+
#dag-viz-graph svg.stage g.node.cached rect {
121+
fill: #B3F5C5;
122+
stroke: #52C366;
123+
stroke-width: 2px;
107124
}

0 commit comments

Comments
 (0)