title: Spark from_json No Exception
body: <p>I am working with Spark 2.1 (scala 2.11).</p>
  
  <p>I want to load json formatted strings with a defined schema , from a dataframe into another dataframe .
  I have tried out some solutions but the least expensive turns out to be the standard column function from_json . 
  I tried out an example(<a href="https://jaceklaskowski.gitbooks.io/mastering-spark-sql/spark-sql-functions-collection.html#from_json" rel="nofollow noreferrer">https://jaceklaskowski.gitbooks.io/mastering-spark-sql/spark-sql-functions-collection.html#from_json</a>) with this function which is giving me unexpected results .</p>
  
  <pre><code>val df = spark.read.text("testFile.txt")
  
  df.show(false)
  
  +----------------+
  |value           |
  +----------------+
  |{"a": 1, "b": 2}|
  |{bad-record     |
  +----------------+
  
  
  df.select(from_json(col("value"),
        StructType(List(
                    StructField("a",IntegerType),
                    StructField("b",IntegerType)
                  ))
      )).show(false)
  
  
  +-------------------+
  |jsontostruct(value)|
  +-------------------+
  |[1,2]              |
  |null               |
  +-------------------+
  </code></pre>
  
  <p>This behavior is similar to  mode:PERMISSIVE which is not the default .
  By default , it is set to FAILFAST mode meaning it should throw an exception whenever the input data &amp;  enforced schema are not matching.</p>
  
  <p>I tried the load the testFile.txt with DataFrameReader(JSON DataSource and FAILFAST mode ) and successfully caught an exception.</p>
  
  <pre><code>spark.read.option("mode","FAILFAST").json("test.txt").show(false)
  
  ---
  Caused by: org.apache.spark.sql.catalyst.json.SparkSQLJsonProcessingException: Malformed line in FAILFAST mode: {bad-record
  ---
  </code></pre>
  
  <p>Though  the Parsing Mode is same in both cases , why are respective outputs so different ?</p>