Skip to content

Commit d7c59b2

Browse files
committed
[SC-5465] Throw errors for unsupported options in Kafka 0.8 source
## What changes were proposed in this pull request? A follow up PR for apache#161 to disallow unsupported options. ## How was this patch tested? `test("unsupported options")` Author: Shixiong Zhu <[email protected]> Closes apache#169 from zsxwing/kafka08-errors.
1 parent f9c9cd8 commit d7c59b2

File tree

12 files changed

+68
-8
lines changed

12 files changed

+68
-8
lines changed

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/JsonUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/KafkaCluster.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/KafkaSource.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/KafkaSourceOffset.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/KafkaSourceProvider.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache
@@ -150,6 +150,13 @@ private[kafka08] class KafkaSourceProvider extends StreamSourceProvider
150150
s"Option 'kafka.bootstrap.servers' must be specified for " +
151151
s"configuring Kafka consumer")
152152
}
153+
154+
for (unsupportedOption <- UNSUPPORTED_OPTIONS) {
155+
if (caseInsensitiveParams.contains(unsupportedOption.toLowerCase)) {
156+
throw new IllegalArgumentException(
157+
s"'$unsupportedOption' is not supported in Kafka 0.8 source")
158+
}
159+
}
153160
}
154161

155162
override def shortName: String = "kafka08"
@@ -158,4 +165,5 @@ private[kafka08] class KafkaSourceProvider extends StreamSourceProvider
158165
private[kafka08] object KafkaSourceProvider {
159166
private val STRATEGY_OPTION_KEYS = Set("subscribe", "assign")
160167
private val STARTING_OFFSETS_OPTION_KEY = "startingoffsets"
168+
private val UNSUPPORTED_OPTIONS = Set("subscribePattern", "failOnDataLoss")
161169
}

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/KafkaSourceRDD.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/StartingOffsets.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/main/scala/org/apache/spark/sql/kafka08/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
/*
18-
* Copyright © 2016 Databricks, Inc.
18+
* Copyright (C) 2016 Databricks, Inc.
1919
*
2020
* Portions of this software incorporate or are derived from software contained within Apache Spark,
2121
* and this modified software differs from the Apache Spark software provided under the Apache

external/kafka-0-8-sql/src/test/scala/org/apache/spark/sql/kafka08/JsonUtilsSuite.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
/*
18+
* Copyright (C) 2016 Databricks, Inc.
19+
*
20+
* Portions of this software incorporate or are derived from software contained within Apache Spark,
21+
* and this modified software differs from the Apache Spark software provided under the Apache
22+
* License, Version 2.0, a copy of which you may obtain at
23+
* http://www.apache.org/licenses/LICENSE-2.0
24+
*/
1725

1826
package org.apache.spark.sql.kafka08
1927

external/kafka-0-8-sql/src/test/scala/org/apache/spark/sql/kafka08/KafkaSourceOffsetSuite.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
/*
18+
* Copyright (C) 2016 Databricks, Inc.
19+
*
20+
* Portions of this software incorporate or are derived from software contained within Apache Spark,
21+
* and this modified software differs from the Apache Spark software provided under the Apache
22+
* License, Version 2.0, a copy of which you may obtain at
23+
* http://www.apache.org/licenses/LICENSE-2.0
24+
*/
1725

1826
package org.apache.spark.sql.kafka08
1927

0 commit comments

Comments
 (0)