<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: spark + scala schema creattion error in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226540#M188400</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/11048/falbani.html" nodeid="11048"&gt;@Felix Albani&lt;/A&gt;&lt;/P&gt;&lt;P&gt;yes your suggestion works fine, i think i have to extend my object as app to make it work. Tanx Bro.&lt;/P&gt;</description>
    <pubDate>Sat, 25 Aug 2018 13:40:37 GMT</pubDate>
    <dc:creator>manikandanjeyab</dc:creator>
    <dc:date>2018-08-25T13:40:37Z</dc:date>
    <item>
      <title>spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226533#M188393</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;im trying to convert case class to StryctType schema in spark, im getting error attached in image,&lt;/P&gt;&lt;P&gt;please find my case class and conversion technique&lt;/P&gt;&lt;P&gt;case class Airlines(Airline_id: Integer, Name: String, Alias: String, IATA: String, ICAO: String, Callsign: String, Country: String, Active: String)&lt;/P&gt;&lt;P&gt;val AirlineSchema = ScalaReflection.schemaFor[Airlines].dataType.asInstanceOf[StructType]&lt;/P&gt;&lt;P&gt;Reference URL:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/36746055/generate-a-spark-structtype-schema-from-a-case-class" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/36746055/generate-a-spark-structtype-schema-from-a-case-class&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="85725-case-class-to-schema-issue.jpg" style="width: 1297px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15352i0DB3B5192B1176EC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="85725-case-class-to-schema-issue.jpg" alt="85725-case-class-to-schema-issue.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 01:26:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226533#M188393</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2019-08-18T01:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226534#M188394</link>
      <description>&lt;P&gt;
	 &lt;A rel="user" href="https://community.cloudera.com/users/16912/manikandanjeyabal029.html" nodeid="16912" data-hasqtip="0"&gt;@Manikandan Jeyabal&lt;/A&gt;
&lt;/P&gt;
&lt;P&gt;
	Perhaps you can try this out:
&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;PRE&gt;
import org.apache.spark.sql.Encoders
case class Airlines(Airline_id: Integer, Name: String, Alias: String, IATA: String, ICAO: String, Callsign: String, Country: String, Active: String)
Encoders.product[Airlines].schema
&lt;/PRE&gt;
&lt;P&gt;
	Also there are some examples of use of case class in the following example:
&lt;/P&gt;
&lt;P&gt;
	&lt;A href="https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/sql/SparkSQLExample.scala" target="_blank"&gt;https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/sql/SparkSQLExample.scala&lt;/A&gt;
&lt;/P&gt;
&lt;P&gt;
	Let me know if this helps!
&lt;/P&gt;
&lt;P&gt;
	*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.
&lt;/P&gt;</description>
      <pubDate>Fri, 24 Aug 2018 19:32:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226534#M188394</guid>
      <dc:creator>falbani</dc:creator>
      <dc:date>2018-08-24T19:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226535#M188395</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/11048/falbani.html" nodeid="11048" target="_blank"&gt;@Felix Albani&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Tanx for your response, actully I've tried all the possible options,&lt;/P&gt;&lt;P&gt;please find the attached image for reference. is there any other way i can solve my issue ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="87385-case-class-to-schema-issue-1.jpg" style="width: 944px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15351iBF0363C8DC51A202/image-size/medium?v=v2&amp;amp;px=400" role="button" title="87385-case-class-to-schema-issue-1.jpg" alt="87385-case-class-to-schema-issue-1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;MJ&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 01:26:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226535#M188395</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2019-08-18T01:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226536#M188396</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/16912/manikandanjeyabal029.html" nodeid="16912" target="_blank"&gt;@Manikandan Jeyabal&lt;/A&gt; &lt;/P&gt;&lt;P&gt;The problem perhaps could be at the project level then. Could you check your pom file and make sure you have all necessary spark depenedencies. I tried this in zeppelin ui and is working fine:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="85727-screen-shot-2018-08-24-at-94033-am.png" style="width: 1301px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/15350i4CC5D448AEBA504E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="85727-screen-shot-2018-08-24-at-94033-am.png" alt="85727-screen-shot-2018-08-24-at-94033-am.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also make sure you clean/build and perhaps exit eclipse just in case there is something wrong with eclipse. &lt;/P&gt;&lt;P&gt;Finally here is a link on how to setup depenedecies eclipse:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hortonworks.com/articles/147787/how-to-setup-hortonworks-repository-for-spark-on-e.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://community.hortonworks.com/articles/147787/how-to-setup-hortonworks-repository-for-spark-on-e.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 01:26:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226536#M188396</guid>
      <dc:creator>falbani</dc:creator>
      <dc:date>2019-08-18T01:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226537#M188397</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/11048/falbani.html" nodeid="11048"&gt;@Felix Albani&lt;/A&gt;&lt;/P&gt;&lt;P&gt;just for an clarification this will work only on Hortonworks dependencies ? please find my build.sbt dependencies and let me know whether i needs to add anything&lt;/P&gt;&lt;PRE&gt;val sparkVersion = "2.2.1"val hadoopVersion = "2.7.1"val poiVersion = "3.9"val avroVersion = "1.7.6"&lt;/PRE&gt;&lt;P&gt;libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % sparkVersion,
  "org.apache.spark" %% "spark-sql" % sparkVersion,
  "org.apache.spark" %% "spark-hive" % sparkVersion,
  "org.apache.poi" % "poi-ooxml" % poiVersion,
  "org.apache.poi" % "poi" % poiVersion,
  "org.apache.avro" % "avro" % avroVersion
)&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 00:41:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226537#M188397</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2018-08-25T00:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226538#M188398</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/11048/falbani.html" nodeid="11048"&gt;@Felix Albani&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Still the same issue Exists, please find my attached build.sbt and sample code attached.&lt;/P&gt;&lt;P&gt;import sbt._
import sbt.Keys._
name := "BackupSnippets"
version := "1.0"
scalaVersion := "2.11.8"
val sparkVersion = "2.2.1"
val hadoopVersion = "2.7.1"
val poiVersion = "3.9"
val avroVersion = "1.7.6"
val hortonworksVersion = "2.2.0.2.6.3.79-2"
conflictManager := ConflictManager.latestRevision
/*libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % sparkVersion,
  "org.apache.spark" %% "spark-sql" % sparkVersion,
  "org.apache.spark" %% "spark-hive" % sparkVersion,
  "org.apache.poi" % "poi-ooxml" % poiVersion,
  "org.apache.poi" % "poi" % poiVersion,
  "org.apache.avro" % "avro" % avroVersion
)*/
/*resolvers ++= Seq(
  "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/",
  "Typesafe Ivyrepository" at "https://repo.typesafe.com/typesafe/ivy-releases/",
  "Maven Central" at "https://repo1.maven.org/maven2/",
  "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
  Resolver.sonatypeRepo("releases")
) */
libraryDependencies ++= Seq(
  "org.apache.spark" %% "spark-core" % hortonworksVersion,
  "org.apache.spark" %% "spark-sql" % hortonworksVersion,
  "org.apache.spark" %% "spark-hive" % hortonworksVersion)
resolvers ++= Seq("Hortonworks Releases" at "http://repo.hortonworks.com/content/repositories/releases/",
  "Jetty Releases" at "http://repo.hortonworks.com/content/repositories/jetty-hadoop/")&lt;/P&gt;&lt;P&gt;************************************************************************************&lt;/P&gt;&lt;P&gt;package BigData101.ORC
import ScalaUtils.SchemaUtils
import org.apache.spark.sql.{Encoders, Row, SparkSession}
import org.apache.spark.sql.catalyst.ScalaReflection
import org.apache.spark.sql.types.StructType
object ORCTesting {
  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder()
                              .master("local[*]")
                              .appName("ORC Testing")
                              .enableHiveSupport()
                              .getOrCreate()
    case class Airlines(Airline_id: Integer, Name: String, Alias: String, IATA: String, ICAO: String, Callsign: String,
                        Country: String, Active: String)
    //val AirlineSchema = ScalaReflection.schemaFor[Airlines].dataType.asInstanceOf[StructType]
    Encoders.product[Airlines].schema
    sys.exit(1)
  }
}&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 00:51:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226538#M188398</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2018-08-25T00:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226539#M188399</link>
      <description>&lt;P&gt;
	&lt;A rel="user" href="https://community.cloudera.com/users/16912/manikandanjeyabal029.html" nodeid="16912"&gt;@Manikandan Jeyabal&lt;/A&gt;
&lt;/P&gt;
&lt;P&gt;
	I think there may be a project level problem on yours. Therefore I'm sharing a very simple dummy project that is compiling fine in my environment (this is only shared as an example and is not meant to be used in real production):
&lt;/P&gt;
&lt;P&gt;
	&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/85729-sparktest.zip"&gt;sparktest.zip&lt;/A&gt;
&lt;/P&gt;
&lt;P&gt;
	Hopefully with this project you will be able to figure out what is wrong when comparing with yours. Note: You can use command line sbt compile and sbt package to get the jar
&lt;/P&gt;
&lt;P&gt;
	This is the output I get when I run it:
&lt;/P&gt;&lt;P&gt;
&lt;/P&gt;&lt;PRE&gt;
 SPARK_MAJOR_VERSION=2 spark-submit /root/projects/sparktest/target/scala-2.11/hello_2.11-0.1.0-SNAPSHOT.jar Hello
SPARK_MAJOR_VERSION is set to 2, using Spark2
hello
root
 |-- Airline_id: integer (nullable = true)
 |-- Name: string (nullable = true)
 |-- Alias: string (nullable = true)
 |-- IATA: string (nullable = true)
 |-- ICAO: string (nullable = true)
 |-- Callsign: string (nullable = true)
 |-- Country: string (nullable = true)
 |-- Active: string (nullable = true)
&lt;BR /&gt;
&lt;/PRE&gt;
&lt;P&gt;
	HTH
&lt;/P&gt;
&lt;P&gt;
	*** If you found this answer addressed your question, please take a moment to login and click the "accept" link on the answer.
&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 01:21:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226539#M188399</guid>
      <dc:creator>falbani</dc:creator>
      <dc:date>2018-08-25T01:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: spark + scala schema creattion error</title>
      <link>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226540#M188400</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/11048/falbani.html" nodeid="11048"&gt;@Felix Albani&lt;/A&gt;&lt;/P&gt;&lt;P&gt;yes your suggestion works fine, i think i have to extend my object as app to make it work. Tanx Bro.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Aug 2018 13:40:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/spark-scala-schema-creattion-error/m-p/226540#M188400</guid>
      <dc:creator>manikandanjeyab</dc:creator>
      <dc:date>2018-08-25T13:40:37Z</dc:date>
    </item>
  </channel>
</rss>

