Support Questions
Find answers, ask questions, and share your expertise

Facing issue while loading HDFS file into Hive

Facing issue while loading HDFS file into Hive

New Contributor

Hi All,

 

I am trying to write data into hive using R Studio, for which first I am storing data into HDFS and from there I want to insert data into Hive.

 

R to HDFS: I am using below code to generate HDFS(i.e. txt) file which is working fine.

library(jsonlite)

modelfile <- hdfs.file("/Result.txt", "w")

data1 <- toJSON(hdfsfile)

data2 <- charToRaw(data1)

hdfs.write(data2,modelfile)

hdfs.close(modelfile)

 

Out Put data format: 

["TER0626974_achieved","TER0630327_achieved","TER0630520_achieved","TER0537124_achieved","TER0404705_achieved"]

 

Issue: Now the issue is writing and reading this data from Hive.

We are able to insert this result into hive. But when try to read, getting below error.

> archive_data <- dbGetQuery(hivecon, "SELECT * from Table")
Error in .jcall(rp, "I", "fetch", stride, block) :
  org.apache.hive.service.cli.HiveSQLException: java.io.IOException: org.apache.hadoop.hive.serde2.SerDeException: java.io.IOException: Start token not found where expected
 
can this be the issueJSON should start with { and not with array ([)?
 
Appreciate your support in resolving this issue.
Thanks in Advance,