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

    https://github.com/apache/spark/pull/999#discussion_r13520450
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/json/JsonTable.scala 
---
    @@ -0,0 +1,364 @@
    +/*
    + * 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.json
    +
    +import org.apache.spark.annotation.Experimental
    +import org.apache.spark.rdd.RDD
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.execution.{ExistingRdd, SparkLogicalPlan}
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.catalyst.types._
    +import org.apache.spark.sql.SchemaRDD
    +import org.apache.spark.sql.Logging
    +import org.apache.spark.sql.catalyst.expressions.{Alias, 
AttributeReference, GetField}
    +
    +import com.fasterxml.jackson.databind.ObjectMapper
    +
    +import scala.collection.JavaConversions._
    +import scala.math.BigDecimal
    +import org.apache.spark.sql.catalyst.expressions.GetField
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.execution.SparkLogicalPlan
    +import org.apache.spark.sql.catalyst.expressions.Alias
    +import org.apache.spark.sql.catalyst.expressions.GetField
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.execution.SparkLogicalPlan
    +import org.apache.spark.sql.catalyst.expressions.Alias
    +import org.apache.spark.sql.catalyst.types.StructField
    +import org.apache.spark.sql.catalyst.types.StructType
    +import org.apache.spark.sql.catalyst.types.ArrayType
    +import org.apache.spark.sql.catalyst.expressions.GetField
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.execution.SparkLogicalPlan
    +import org.apache.spark.sql.catalyst.expressions.Alias
    +
    +sealed trait SchemaResolutionMode
    +
    +case object EAGER_SCHEMA_RESOLUTION extends SchemaResolutionMode
    +case class EAGER_SCHEMA_RESOLUTION_WITH_SAMPLING(val fraction: Double) 
extends SchemaResolutionMode
    +case object LAZY_SCHEMA_RESOLUTION extends SchemaResolutionMode
    +
    +/**
    + * :: Experimental ::
    + * Converts a JSON file to a SparkSQL logical query plan.  This 
implementation is only designed to
    + * work on JSON files that have mostly uniform schema.  The conversion 
suffers from the following
    + * limitation:
    + *  - The data is optionally sampled to determine all of the possible 
fields. Any fields that do
    + *    not appear in this sample will not be included in the final output.
    + */
    +@Experimental
    +object JsonTable extends Serializable with Logging {
    +  def inferSchema(
    +      json: RDD[String], sampleSchema: Option[Double] = None): LogicalPlan 
= {
    --- End diff --
    
    Good idea, I like that better than Option.


---
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.
---

Reply via email to