Created 08-14-2017 12:35 PM
I need to create a table with just a field, which is a map of string: string. I have created the table without problems, but when I try to insert the values (they are defined, not in another table) I am not able to achieve it. The code is below.
create table comunidades ( codigo MAP<STRING, STRING> ); INSERT INTO TABLE comunidades SELECT 1, {"AND": '01'};
Created 08-16-2017 09:22 AM
I tried recreating your situation and it worked. see attached.To use the map function the source tables should already exist. I used a text file ruiz.txt with values
$ cat ruiz.txt "AND": '01' "TOO": '02' "MORE": '03'
Hope that helps please accept the reponse if it resolved your problem!
Created 08-14-2017 01:46 PM
Are you trying to insert from one table to another and facing this issue?
If that is the case then when you are inserting from one table to another then you may need to convert the columns into MAP as you have used MAP in the second table.
Created 08-14-2017 06:16 PM
You should use map() complex type constructor in your insert statement.
insert into table testMap SELECT map('AND','01');
You can find more details about complex type constructors from here:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
Created 08-16-2017 07:19 AM
I've just tried your command and it returns an error. I'm using the Hortonworks Sandbox, and I don't understand why it throws that error.
org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED: ParseException line 1:52 Failed to recognize predicate '<EOF>'. Failed rule: 'regularBody' in statement
Created 08-16-2017 09:22 AM
I tried recreating your situation and it worked. see attached.To use the map function the source tables should already exist. I used a text file ruiz.txt with values
$ cat ruiz.txt "AND": '01' "TOO": '02' "MORE": '03'
Hope that helps please accept the reponse if it resolved your problem!
Created 08-16-2017 09:51 AM
I have repeated your steps in Ambari and it throws me an error (below). I have checked the community entries and it's something repeated. I don't know if there is a solution yet for this issue.
java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
Created 08-16-2017 10:14 AM
Try this
# cd /tmp/data
# su - hdfs
$ hdfs dfs -copyFromLocal autonomias.txt /apps/hive/warehouse/
$ hdfs dfs -chown -R hive:hive /apps/hive/warehouse/
hive> load data inpath '/apps/hive/warehouse/autonomias.txt' into table comunidades;
Tell me that should work
Created 08-16-2017 10:31 AM
In Ambari I have no terminal client, I upload files through a visual interface and the permissions for the file and folder are all enabled. I though the same, a problem with the permissions, but not. I don't know if the Sandbox is limited in some Hive operations
Created 08-16-2017 11:21 AM
Install putty to interact with your sandbox from your desktop, let download what is the version of sandbox?
Created 08-16-2017 11:32 AM
Yes I know about putty, but it is possible to do also from Ambari. I will try to do it from putty.
The version of the sandbox is 2.6.1 for VirtualBox. It's available here: https://es.hortonworks.com/downloads/#sandbox