Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15102#discussion_r80564169
  
    --- Diff: 
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaSourceProvider.scala
 ---
    @@ -0,0 +1,263 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.kafka010
    +
    +import java.{util => ju}
    +import java.util.UUID
    +
    +import scala.collection.JavaConverters._
    +
    +import org.apache.kafka.clients.consumer.ConsumerConfig
    +import org.apache.kafka.common.serialization.ByteArrayDeserializer
    +
    +import org.apache.spark.internal.Logging
    +import org.apache.spark.sql.SQLContext
    +import org.apache.spark.sql.execution.streaming.Source
    +import org.apache.spark.sql.kafka010.KafkaSource._
    +import org.apache.spark.sql.sources.{DataSourceRegister, 
StreamSourceProvider}
    +import org.apache.spark.sql.types.StructType
    +
    +/**
    + * The provider class for the [[KafkaSource]]. This provider is designed 
such that it throws
    + * IllegalArgumentException when the Kafka Dataset is created, so that it 
can catch
    + * missing options even before the query is started.
    + */
    +private[kafka010] class KafkaSourceProvider extends StreamSourceProvider
    +    with DataSourceRegister with Logging {
    +  import KafkaSourceProvider._
    +
    +  /**
    +   * Returns the name and schema of the source. In addition, it also 
verifies whether the options
    +   * are correct and sufficient to create the [[KafkaSource]] when the 
query is started.
    +   */
    +  override def sourceSchema(
    +      sqlContext: SQLContext,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): (String, StructType) = {
    +    validateOptions(parameters)
    +    ("kafka", KafkaSource.kafkaSchema)
    +  }
    +
    +  override def createSource(
    +      sqlContext: SQLContext,
    +      metadataPath: String,
    +      schema: Option[StructType],
    +      providerName: String,
    +      parameters: Map[String, String]): Source = {
    +      validateOptions(parameters)
    +    val caseInsensitiveParams = parameters.map { case (k, v) => 
(k.toLowerCase, v) }
    +    val specifiedKafkaParams =
    +      parameters
    +        .keySet
    +        .filter(_.toLowerCase.startsWith("kafka."))
    +        .map { k => k.drop(6).toString -> parameters(k) }
    +        .toMap
    +
    +    val deserClassName = classOf[ByteArrayDeserializer].getName
    +    val uniqueGroupId = 
s"spark-kafka-source-${UUID.randomUUID}-${metadataPath.hashCode}"
    --- End diff --
    
    Also, do these get cleaned up?  or are we leaking state into ZK?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to