spark sql create nested schema

2014-11-04 Thread tridib
I am trying to create a schema which will look like:

root
 |-- ParentInfo: struct (nullable = true)
 ||-- ID: string (nullable = true)
 ||-- State: string (nullable = true)
 ||-- Zip: string (nullable = true)
 |-- ChildInfo: struct (nullable = true)
 ||-- ID: string (nullable = true)
 ||-- State: string (nullable = true)
 ||-- Hobby: string (nullable = true)
 ||-- Zip: string (nullable = true)

How do I create a StructField of StructType? I think that's what the root
is.

Thanks  Regards 
Tridib



--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/spark-sql-create-nested-schema-tp18090.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

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



Re: spark sql create nested schema

2014-11-04 Thread Yin Huai
Hello Tridib,

For you case, you can use StructType(StructField(ParentInfo, parentInfo,
true) :: StructField(ChildInfo, childInfo, true) :: Nil) to create the
StructType representing the schema (parentInfo and childInfo are two
existing StructTypes). You can take a look at our docs (
http://spark.apache.org/docs/1.1.0/sql-programming-guide.html#programmatically-specifying-the-schema
 and
http://spark.apache.org/docs/1.1.0/api/scala/index.html#org.apache.spark.sql.package
).

Thanks,

Yin

On Tue, Nov 4, 2014 at 3:19 PM, tridib tridib.sama...@live.com wrote:

 I am trying to create a schema which will look like:

 root
  |-- ParentInfo: struct (nullable = true)
  ||-- ID: string (nullable = true)
  ||-- State: string (nullable = true)
  ||-- Zip: string (nullable = true)
  |-- ChildInfo: struct (nullable = true)
  ||-- ID: string (nullable = true)
  ||-- State: string (nullable = true)
  ||-- Hobby: string (nullable = true)
  ||-- Zip: string (nullable = true)

 How do I create a StructField of StructType? I think that's what the root
 is.

 Thanks  Regards
 Tridib



 --
 View this message in context:
 http://apache-spark-user-list.1001560.n3.nabble.com/spark-sql-create-nested-schema-tp18090.html
 Sent from the Apache Spark User List mailing list archive at Nabble.com.

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