# Writting to Index using pure SQL

**URL:** <https://discuss.elastic.co/t/writting-to-index-using-pure-sql/70533>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [January 4, 2017, 10:14am UTC](https://discuss.elastic.co/t/writting-to-index-using-pure-sql/70533 "2017-01-04T10:14:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivier-ds](https://avatars.discourse-cdn.com/v4/letter/o/7ab992/32.png) [@olivier-ds](https://discuss.elastic.co/u/olivier-ds)\
**Post date:** [January 4, 2017, 10:14am UTC](https://discuss.elastic.co/t/writting-to-index-using-pure-sql/70533/1 "2017-01-04T10:14:39Z")

</div>

Hi all,

I would to push data from Hive to table to ES Index. I have managed to do it with Hive using an external table \_csv\_demo\_export\_\_es (create external table csv\_demo\_export\_es STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' ...)

Using Hive (beeline CLI) I am able to write into selected index through this external table (INSERT OVERWRITE TABLE csv\_demo\_export\_es SELECT ...)

Now I would like to perform the same with Spark-SQL i.e. using pure SQL. with Spark-SQL CLI I am able to see the external table I have created with Hive and pointing to an ES Index. I can also read from the index using this table I have defined in Hive. But I cannot insert data into it as I could do with Hive

spark-sql (default)\> INSERT OVERWRITE TABLE csv\_demo\_export\_es SELECT event\_id, host, collection\_time FROM csv\_demo\_data WHERE year=2016;  
17/01/04 10:35:47 ERROR SparkSQLDriver: Failed in [INSERT OVERWRITE TABLE csv\_demo\_export\_es SELECT event\_id, host, collection\_time FROM csv\_demo\_data WHERE year=2016]  
java.lang.RuntimeException: java.lang.RuntimeException: class org.elasticsearch.hadoop.mr.EsOutputFormat$EsOutputCommitter not org.apache.hadoop.mapred.OutputCommitter

I have also tried using a Spark SQL temporary table pointing to the same ES index (CREATE TEMPORARY TABLE myIndex USING org.elasticsearch.spark.sql )

I am able to perform read operations (select \* friom myIndex) but not insert operations

Documentation tells about how to read indexes using pure SQL ([https://www.elastic.co/guide/en/elasticsearch/hadoop/5.0/spark.html#spark-sql-read-ds](https://www.elastic.co/guide/en/elasticsearch/hadoop/5.0/spark.html#spark-sql-read-ds)) but not how to write into index using pure SQL (with Spark SQL... no pb with Hive)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 1, 2017, 10:14am UTC](https://discuss.elastic.co/t/writting-to-index-using-pure-sql/70533/2 "2017-02-01T10:14:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
