I would like to insert some data my table "test" in Hive through a pySpark script (python for Spark).
I created first of all a table "animals" in the HUE's graphic interface for Hive thank to the query :
CREATE TABLE animals( id int, animal String)
Thus I got a new table. I wrote this script in order to add a new line (1, dog) to it :
from pyspark.conf import SparkConf
from pyspark import SparkContext
from pyspark.sql import SQLContext, HiveContext
sc = SparkContext()
hc = HiveContext(sc)
dataToInsert = hc.sql("select 1 as id, 'dog' as animal")
dataToInsert.write.mode("append").insertInto("animals")
After having executed it (several times with "sudo pyspark myscript.py" in the terminal), it seems it doesn't add anything.
Do you know how to fix that or another way to insert data into a Hive/Impala table through a python script for Spark please ?
Thanks in advance !