title: Writing SQL vs using Dataframe APIs in Spark SQL
body: <p>I am a newbie in Spark SQL world. I am currently migrating my application's Ingestion code which includes ingesting data in stage,Raw and Application layer in HDFS and doing CDC(change data capture), this is currently written in Hive queries and is executed via Oozie. This needs to migrate into a Spark application(current version 1.6). The other section of code will migrate later on.</p>
  <p>In spark-SQL, I can create dataframes directly from tables in Hive and simply execute queries as it is (like <code>sqlContext.sql(&quot;my hive hql&quot;)</code> ). The other way would be to use dataframe APIs and rewrite the hql in that way.</p>
  <p>What is the difference in these two approaches?</p>
  <p>Is there any performance gain with using Dataframe APIs?</p>
  <p>Some people suggested, there is an extra layer of SQL that spark core engine has to go through when using &quot;SQL&quot; queries directly which may impact performance to some extent but I didn't find any material substantiating that statement. I know the code would be much more compact with Datafrmae APIs but when I have my hql queries all handy would it really worth to write complete code into Dataframe API?</p>
  <p>Thank You.</p>