Not sure that it will help, but I would do the following

1. Need to create a case class which matches your json schema.
2. Change the following line:
Dataset<Row> rows_salaries = spark.read().json("/Users/sreeharsha/Downloads/rows_salaries.json");
Dataset<MyCaseClass> rows_salaries = spark.read().json("/Users/sreeharsha/Downloads/rows_salaries.json").as[MyCaseClass];
3. Make your code compiling successfully 


On 29 August 2016 at 12:27, Sree Eedupuganti <sree@inndata.in> wrote:
Here is the snippet of code :

//The entry point into all functionality in Spark is the SparkSession class. To create a basic SparkSession, just use SparkSession.builder():

SparkSession spark = SparkSession.builder().appName("Java Spark SQL Example").master("local").getOrCreate();

//With a SparkSession, applications can create DataFrames from an existing RDD, from a Hive table, or from Spark data sources.

Dataset<Row> rows_salaries = spark.read().json("/Users/sreeharsha/Downloads/rows_salaries.json");

// Register the DataFrame as a SQL temporary view


// SQL statements can be run by using the sql methods provided by spark

List<Row> df = spark.sql("select * from salaries").collectAsList();

for(Row r:df){




Actaul Output : 

WrappedArray(WrappedArray(1, B9B42DE1-E810-4489-9735-B365A47A4012, 1, 1467358044, 697390, 1467358044, 697390, null, Aaron,Patricia G, Facilities/Office Services II, A03031, OED-Employment Dev (031), 1979-10-24T00:00:00, 56705.00, 54135.44))

Expecting Output: 

Need elements from the WrappedArray

Below you can find the attachment of .json file

To unsubscribe e-mail: user-unsubscribe@spark.apache.org

//with Best Regards
--Denis Bolshakov
e-mail: bolshakov.denis@gmail.com