Skip to content

Commit 961ec34

Browse files
author
Michael Chirico
committed
Merge branch 'master' into r-stop-paste
2 parents f278f95 + 226301a commit 961ec34

File tree

23 files changed

+371
-108
lines changed

23 files changed

+371
-108
lines changed

R/pkg/R/DataFrame.R

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,23 +1225,18 @@ setMethod("collect",
12251225
# empty data.frame with 0 columns and 0 rows
12261226
data.frame()
12271227
} else if (useArrow) {
1228-
requireNamespace1 <- requireNamespace
1229-
if (requireNamespace1("arrow", quietly = TRUE)) {
1230-
read_arrow <- get("read_arrow", envir = asNamespace("arrow"), inherits = FALSE)
1231-
# Arrow drops `as_tibble` since 0.14.0, see ARROW-5190.
1232-
useAsTibble <- exists("as_tibble", envir = asNamespace("arrow"))
1233-
1228+
if (requireNamespace("arrow", quietly = TRUE)) {
12341229
portAuth <- callJMethod(x@sdf, "collectAsArrowToR")
12351230
port <- portAuth[[1]]
12361231
authSecret <- portAuth[[2]]
12371232
conn <- socketConnection(
12381233
port = port, blocking = TRUE, open = "wb", timeout = connectionTimeout)
12391234
output <- tryCatch({
12401235
doServerAuth(conn, authSecret)
1241-
arrowTable <- read_arrow(readRaw(conn))
1242-
if (useAsTibble) {
1243-
as_tibble <- get("as_tibble", envir = asNamespace("arrow"))
1244-
as.data.frame(as_tibble(arrowTable), stringsAsFactors = stringsAsFactors)
1236+
arrowTable <- arrow::read_arrow(readRaw(conn))
1237+
# Arrow drops `as_tibble` since 0.14.0, see ARROW-5190.
1238+
if (exists("as_tibble", envir = asNamespace("arrow"))) {
1239+
as.data.frame(arrow::as_tibble(arrowTable), stringsAsFactors = stringsAsFactors)
12451240
} else {
12461241
as.data.frame(arrowTable, stringsAsFactors = stringsAsFactors)
12471242
}

R/pkg/R/types.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ specialtypeshandle <- function(type) {
8888
checkSchemaInArrow <- function(schema) {
8989
stopifnot(inherits(schema, "structType"))
9090

91-
requireNamespace1 <- requireNamespace
92-
if (!requireNamespace1("arrow", quietly = TRUE)) {
91+
if (!requireNamespace("arrow", quietly = TRUE)) {
9392
stop("'arrow' package should be installed.")
9493
}
9594

dev/appveyor-install-dependencies.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Function InstallR {
5050

5151
Function InstallRtools {
5252
$rtoolsver = $rToolsVer.Split('.')[0..1] -Join ''
53-
$rtoolsurl = $CRAN + "/bin/windows/Rtools/Rtools$rtoolsver.exe"
53+
$rtoolsurl = $CRAN + "/bin/windows/Rtools/rtools$rtoolsver-x86_64.exe"
5454

5555
# Downloading Rtools
5656
Start-FileDownload $rtoolsurl "Rtools-current.exe"
@@ -67,8 +67,8 @@ Function InstallRtools {
6767
Else {
6868
$gccPath = $env:GCC_PATH
6969
}
70-
$env:PATH = $RtoolsDrive + '\Rtools\bin;' + $RtoolsDrive + '\Rtools\MinGW\bin;' + $RtoolsDrive + '\Rtools\' + $gccPath + '\bin;' + $env:PATH
71-
$env:BINPREF=$RtoolsDrive + '/Rtools/mingw_$(WIN)/bin/'
70+
$env:PATH = $RtoolsDrive + '\Rtools40\bin;' + $RtoolsDrive + '\Rtools40\MinGW$(WIN)\bin;' + $RtoolsDrive + '\Rtools40\' + $gccPath + '\bin;' + $env:PATH
71+
$env:BINPREF=$RtoolsDrive + '/Rtools40/mingw$(WIN)/bin/'
7272
}
7373

7474
# create tools directory outside of Spark directory
@@ -116,7 +116,7 @@ Pop-Location
116116

117117
# ========================== R
118118
$rVer = "3.6.2"
119-
$rToolsVer = "3.5.1"
119+
$rToolsVer = "4.0.0"
120120

121121
InstallR
122122
InstallRtools

docs/_plugins/copy_api_dirs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@
157157
curr_dir = pwd
158158
cd("..")
159159

160-
puts "Running 'build/sbt clean package' from " + pwd + "; this may take a few minutes..."
161-
system("build/sbt clean package") || raise("SQL doc generation failed")
160+
puts "Running 'build/sbt clean package -Phive' from " + pwd + "; this may take a few minutes..."
161+
system("build/sbt clean package -Phive") || raise("SQL doc generation failed")
162162

163163
puts "Moving back into docs dir."
164164
cd("docs")

docs/sql-migration-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ license: |
5959

6060
- In Spark 3.0, you can use `ADD FILE` to add file directories as well. Earlier you could add only single files using this command. To restore the behavior of earlier versions, set `spark.sql.legacy.addSingleFileInAddFile` to `true`.
6161

62-
- In Spark 3.0, `SHOW TBLPROPERTIES` throws `AnalysisException` if the table does not exist. In Spark version 2.4 and below, this scenario caused `NoSuchTableException`. Also, `SHOW TBLPROPERTIES` on a temporary view causes `AnalysisException`. In Spark version 2.4 and below, it returned an empty result.
62+
- In Spark 3.0, `SHOW TBLPROPERTIES` throws `AnalysisException` if the table does not exist. In Spark version 2.4 and below, this scenario caused `NoSuchTableException`.
6363

6464
- In Spark 3.0, `SHOW CREATE TABLE` always returns Spark DDL, even when the given table is a Hive SerDe table. For generating Hive DDL, use `SHOW CREATE TABLE AS SERDE` command instead.
6565

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ case class InSet(child: Expression, hset: Set[Any]) extends UnaryExpression with
521521
override def sql: String = {
522522
val valueSQL = child.sql
523523
val listSQL = hset.toSeq
524-
.map(elem => Literal(convertToScala(elem, child.dataType)).sql)
524+
.map(elem => Literal(elem, child.dataType).sql)
525525
.mkString(", ")
526526
s"($valueSQL IN ($listSQL))"
527527
}

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/randomExpressions.scala

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@ trait ExpressionWithRandomSeed {
8383
""",
8484
since = "1.5.0")
8585
// scalastyle:on line.size.limit
86-
case class Rand(child: Expression) extends RDG with ExpressionWithRandomSeed {
86+
case class Rand(child: Expression, hideSeed: Boolean = false)
87+
extends RDG with ExpressionWithRandomSeed {
8788

88-
def this() = this(Literal(Utils.random.nextLong(), LongType))
89+
def this() = this(Literal(Utils.random.nextLong(), LongType), true)
90+
91+
def this(child: Expression) = this(child, false)
8992

9093
override def withNewSeed(seed: Long): Rand = Rand(Literal(seed, LongType))
9194

@@ -101,7 +104,12 @@ case class Rand(child: Expression) extends RDG with ExpressionWithRandomSeed {
101104
isNull = FalseLiteral)
102105
}
103106

104-
override def freshCopy(): Rand = Rand(child)
107+
override def freshCopy(): Rand = Rand(child, hideSeed)
108+
109+
override def flatArguments: Iterator[Any] = Iterator(child)
110+
override def sql: String = {
111+
s"rand(${if (hideSeed) "" else child.sql})"
112+
}
105113
}
106114

107115
object Rand {
@@ -126,9 +134,12 @@ object Rand {
126134
""",
127135
since = "1.5.0")
128136
// scalastyle:on line.size.limit
129-
case class Randn(child: Expression) extends RDG with ExpressionWithRandomSeed {
137+
case class Randn(child: Expression, hideSeed: Boolean = false)
138+
extends RDG with ExpressionWithRandomSeed {
130139

131-
def this() = this(Literal(Utils.random.nextLong(), LongType))
140+
def this() = this(Literal(Utils.random.nextLong(), LongType), true)
141+
142+
def this(child: Expression) = this(child, false)
132143

133144
override def withNewSeed(seed: Long): Randn = Randn(Literal(seed, LongType))
134145

@@ -144,7 +155,12 @@ case class Randn(child: Expression) extends RDG with ExpressionWithRandomSeed {
144155
isNull = FalseLiteral)
145156
}
146157

147-
override def freshCopy(): Randn = Randn(child)
158+
override def freshCopy(): Randn = Randn(child, hideSeed)
159+
160+
override def flatArguments: Iterator[Any] = Iterator(child)
161+
override def sql: String = {
162+
s"randn(${if (hideSeed) "" else child.sql})"
163+
}
148164
}
149165

150166
object Randn {

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3573,7 +3573,7 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging
35733573
override def visitShowTblProperties(
35743574
ctx: ShowTblPropertiesContext): LogicalPlan = withOrigin(ctx) {
35753575
ShowTableProperties(
3576-
UnresolvedTable(visitMultipartIdentifier(ctx.table)),
3576+
UnresolvedTableOrView(visitMultipartIdentifier(ctx.table)),
35773577
Option(ctx.key).map(visitTablePropertyKey))
35783578
}
35793579

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/IntervalUtils.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.apache.spark.sql.catalyst.util
1919

20-
import java.math.BigDecimal
2120
import java.util.concurrent.TimeUnit
2221

2322
import scala.util.control.NonFatal
@@ -55,11 +54,12 @@ object IntervalUtils {
5554
}
5655

5756
def getDays(interval: CalendarInterval): Int = {
58-
interval.days
57+
val daysInMicroseconds = (interval.microseconds / MICROS_PER_DAY).toInt
58+
Math.addExact(interval.days, daysInMicroseconds)
5959
}
6060

6161
def getHours(interval: CalendarInterval): Long = {
62-
interval.microseconds / MICROS_PER_HOUR
62+
(interval.microseconds % MICROS_PER_DAY) / MICROS_PER_HOUR
6363
}
6464

6565
def getMinutes(interval: CalendarInterval): Byte = {

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/IntervalExpressionsSuite.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
6868
// Years and months must not be taken into account
6969
checkEvaluation(ExtractIntervalDays("100 year 10 months 5 days"), 5)
7070
checkEvaluation(ExtractIntervalDays(largeInterval), 31)
71+
checkEvaluation(ExtractIntervalDays("25 hours"), 1)
7172
}
7273

7374
test("hours") {
@@ -81,6 +82,8 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
8182
// Minutes should be taken into account
8283
checkEvaluation(ExtractIntervalHours("10 hours 100 minutes"), 11L)
8384
checkEvaluation(ExtractIntervalHours(largeInterval), 11L)
85+
checkEvaluation(ExtractIntervalHours("25 hours"), 1L)
86+
8487
}
8588

8689
test("minutes") {

0 commit comments

Comments
 (0)