Skip to content

Commit c6ab640

Browse files
Merge pull request #37 from apache/master
Update upstream
2 parents 501bbe7 + 5d75b14 commit c6ab640

16 files changed

Lines changed: 111 additions & 9 deletions

File tree

bin/spark-class

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ build_command() {
7272
printf "%d\0" $?
7373
}
7474

75+
# Turn off posix mode since it does not allow process substitution
76+
set +o posix
7577
CMD=()
7678
while IFS= read -d '' -r ARG; do
7779
CMD+=("$ARG")

bin/spark-class2.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ if not "x%SPARK_PREPEND_CLASSES%"=="x" (
5151
rem Figure out where java is.
5252
set RUNNER=java
5353
if not "x%JAVA_HOME%"=="x" (
54-
set RUNNER="%JAVA_HOME%\bin\java"
54+
set RUNNER=%JAVA_HOME%\bin\java
5555
) else (
5656
where /q "%RUNNER%"
5757
if ERRORLEVEL 1 (

external/docker-integration-tests/src/test/scala/org/apache/spark/sql/jdbc/OracleIntegrationSuite.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSQLCo
7070
""".stripMargin.replaceAll("\n", " ")).executeUpdate()
7171
conn.commit()
7272

73+
conn.prepareStatement("CREATE TABLE ts_with_timezone (id NUMBER(10), t TIMESTAMP WITH TIME ZONE)")
74+
.executeUpdate()
75+
conn.prepareStatement("INSERT INTO ts_with_timezone VALUES (1, to_timestamp_tz('1999-12-01 11:00:00 UTC','YYYY-MM-DD HH:MI:SS TZR'))")
76+
.executeUpdate()
77+
conn.commit()
78+
7379
sql(
7480
s"""
7581
|CREATE TEMPORARY VIEW datetime
@@ -185,4 +191,11 @@ class OracleIntegrationSuite extends DockerJDBCIntegrationSuite with SharedSQLCo
185191
sql("INSERT INTO TABLE datetime1 SELECT * FROM datetime where id = 1")
186192
checkRow(sql("SELECT * FROM datetime1 where id = 1").head())
187193
}
194+
195+
test("SPARK-20557: column type TIMEZONE with TIME STAMP should be recognized") {
196+
val dfRead = sqlContext.read.jdbc(jdbcUrl, "ts_with_timezone", new Properties)
197+
val rows = dfRead.collect()
198+
val types = rows(0).toSeq.map(x => x.getClass.toString)
199+
assert(types(1).equals("class java.sql.Timestamp"))
200+
}
188201
}

external/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaTestUtils.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class KafkaTestUtils(withBrokerProps: Map[String, Object] = Map.empty) extends L
292292
props.put("log.flush.interval.messages", "1")
293293
props.put("replica.socket.timeout.ms", "1500")
294294
props.put("delete.topic.enable", "true")
295+
props.put("offsets.topic.num.partitions", "1")
295296
props.putAll(withBrokerProps.asJava)
296297
props
297298
}

mllib/src/main/scala/org/apache/spark/ml/feature/Bucketizer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ final class Bucketizer @Since("1.4.0") (@Since("1.4.0") override val uid: String
116116
Bucketizer.binarySearchForBuckets($(splits), feature, keepInvalid)
117117
}
118118

119-
val newCol = bucketizer(filteredDataset($(inputCol)))
119+
val newCol = bucketizer(filteredDataset($(inputCol)).cast(DoubleType))
120120
val newField = prepOutputField(filteredDataset.schema)
121121
filteredDataset.withColumn($(outputCol), newCol, newField.metadata)
122122
}
@@ -130,7 +130,7 @@ final class Bucketizer @Since("1.4.0") (@Since("1.4.0") override val uid: String
130130

131131
@Since("1.4.0")
132132
override def transformSchema(schema: StructType): StructType = {
133-
SchemaUtils.checkColumnType(schema, $(inputCol), DoubleType)
133+
SchemaUtils.checkNumericType(schema, $(inputCol))
134134
SchemaUtils.appendColumn(schema, prepOutputField(schema))
135135
}
136136

mllib/src/test/scala/org/apache/spark/ml/feature/BucketizerSuite.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import org.apache.spark.ml.util.{DefaultReadWriteTest, MLTestingUtils}
2626
import org.apache.spark.ml.util.TestingUtils._
2727
import org.apache.spark.mllib.util.MLlibTestSparkContext
2828
import org.apache.spark.sql.{DataFrame, Row}
29+
import org.apache.spark.sql.functions._
30+
import org.apache.spark.sql.types._
2931

3032
class BucketizerSuite extends SparkFunSuite with MLlibTestSparkContext with DefaultReadWriteTest {
3133

@@ -162,6 +164,29 @@ class BucketizerSuite extends SparkFunSuite with MLlibTestSparkContext with Defa
162164
.setSplits(Array(0.1, 0.8, 0.9))
163165
testDefaultReadWrite(t)
164166
}
167+
168+
test("Bucket numeric features") {
169+
val splits = Array(-3.0, 0.0, 3.0)
170+
val data = Array(-2.0, -1.0, 0.0, 1.0, 2.0)
171+
val expectedBuckets = Array(0.0, 0.0, 1.0, 1.0, 1.0)
172+
val dataFrame: DataFrame = data.zip(expectedBuckets).toSeq.toDF("feature", "expected")
173+
174+
val bucketizer: Bucketizer = new Bucketizer()
175+
.setInputCol("feature")
176+
.setOutputCol("result")
177+
.setSplits(splits)
178+
179+
val types = Seq(ShortType, IntegerType, LongType, FloatType, DoubleType,
180+
ByteType, DecimalType(10, 0))
181+
for (mType <- types) {
182+
val df = dataFrame.withColumn("feature", col("feature").cast(mType))
183+
bucketizer.transform(df).select("result", "expected").collect().foreach {
184+
case Row(x: Double, y: Double) =>
185+
assert(x === y, "The result is not correct after bucketing in type " +
186+
mType.toString + ". " + s"Expected $y but found $x.")
187+
}
188+
}
189+
}
165190
}
166191

167192
private object BucketizerSuite extends SparkFunSuite {

project/MimaExcludes.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ object MimaExcludes {
3636

3737
// Exclude rules for 2.3.x
3838
lazy val v23excludes = v22excludes ++ Seq(
39+
// [SPARK-20495][SQL] Add StorageLevel to cacheTable API
40+
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.sql.catalog.Catalog.cacheTable")
3941
)
4042

4143
// Exclude rules for 2.2.x

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleExecutor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ abstract class RuleExecutor[TreeType <: TreeNode[_]] extends Logging {
122122
logDebug(
123123
s"""
124124
|=== Result of Batch ${batch.name} ===
125-
|${sideBySide(plan.treeString, curPlan.treeString).mkString("\n")}
125+
|${sideBySide(batchStartPlan.treeString, curPlan.treeString).mkString("\n")}
126126
""".stripMargin)
127127
} else {
128128
logTrace(s"Batch ${batch.name} has no effect.")

sql/core/src/main/scala/org/apache/spark/sql/catalog/Catalog.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import scala.collection.JavaConverters._
2222
import org.apache.spark.annotation.{Experimental, InterfaceStability}
2323
import org.apache.spark.sql.{AnalysisException, DataFrame, Dataset}
2424
import org.apache.spark.sql.types.StructType
25-
25+
import org.apache.spark.storage.StorageLevel
2626

2727
/**
2828
* Catalog interface for Spark. To access this, use `SparkSession.catalog`.
@@ -476,6 +476,18 @@ abstract class Catalog {
476476
*/
477477
def cacheTable(tableName: String): Unit
478478

479+
/**
480+
* Caches the specified table with the given storage level.
481+
*
482+
* @param tableName is either a qualified or unqualified name that designates a table/view.
483+
* If no database identifier is provided, it refers to a temporary view or
484+
* a table/view in the current database.
485+
* @param storageLevel storage level to cache table.
486+
* @since 2.3.0
487+
*/
488+
def cacheTable(tableName: String, storageLevel: StorageLevel): Unit
489+
490+
479491
/**
480492
* Removes the specified table from the in-memory cache.
481493
*

sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/ObjectAggregationIterator.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.apache.spark.sql.catalyst.expressions._
2424
import org.apache.spark.sql.catalyst.expressions.aggregate._
2525
import org.apache.spark.sql.catalyst.expressions.codegen.{BaseOrdering, GenerateOrdering}
2626
import org.apache.spark.sql.execution.UnsafeKVExternalSorter
27+
import org.apache.spark.sql.execution.metric.SQLMetric
2728
import org.apache.spark.sql.internal.SQLConf
2829
import org.apache.spark.sql.types.StructType
2930
import org.apache.spark.unsafe.KVIterator
@@ -39,7 +40,8 @@ class ObjectAggregationIterator(
3940
newMutableProjection: (Seq[Expression], Seq[Attribute]) => MutableProjection,
4041
originalInputAttributes: Seq[Attribute],
4142
inputRows: Iterator[InternalRow],
42-
fallbackCountThreshold: Int)
43+
fallbackCountThreshold: Int,
44+
numOutputRows: SQLMetric)
4345
extends AggregationIterator(
4446
groupingExpressions,
4547
originalInputAttributes,
@@ -83,7 +85,9 @@ class ObjectAggregationIterator(
8385

8486
override final def next(): UnsafeRow = {
8587
val entry = aggBufferIterator.next()
86-
generateOutput(entry.groupingKey, entry.aggregationBuffer)
88+
val res = generateOutput(entry.groupingKey, entry.aggregationBuffer)
89+
numOutputRows += 1
90+
res
8791
}
8892

8993
/**

0 commit comments

Comments
 (0)