You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Buntu Dev <bu...@gmail.com> on 2016/03/01 00:36:38 UTC
Cannot convert column 2 from string to map error
When attempting to insert null value into a map<string,string> column type,
I run into this error:
Cannot convert column 2 from string to map<string,string>
Here is my Avro schema and the table definition:
~~~~~~~~~~~~~~~~
"fields": [
{"name": "src", "type": ["null", "string"], "default": null},
{"name": "uid", "type": ["null", "string"], "default": null},
{"name": "attrs", "type": {"type": "map", "values": ["null",
"string"]}, "default": null},
...
]
> desc tmp_table;
+--------------------------+-----------------------+-----------------------+--+
| col_name | data_type | comment |
+--------------------------+-----------------------+-----------------------+--+
| src | bigint | from deserializer |
| uid | int | from deserializer |
| attrs | map<string,string> | from deserializer |
....
...
~~~~~~~~~~~~~~~~
If I run this INSERT INTO, I get the error message mentioned:
insert into tmp_table values ( 'src1', 'uid1', null);
Is there some way I can fix this issue?
Thanks!
Re: Cannot convert column 2 from string to map error
Posted by Swagatika Tripathy <sw...@gmail.com>.
Hi Buntu,
Since the attribute attrs is of type MAP,So, you need to do it something
like:
insert into tmp_table values ( 'src1', 'uid1',map("NULL","NULL").
Let me know if it works.
On Tue, Mar 1, 2016 at 5:06 AM, Buntu Dev <bu...@gmail.com> wrote:
> When attempting to insert null value into a map<string,string> column
> type, I run into this error:
>
> Cannot convert column 2 from string to map<string,string>
>
>
> Here is my Avro schema and the table definition:
>
> ~~~~~~~~~~~~~~~~
> "fields": [
> {"name": "src", "type": ["null", "string"], "default": null},
> {"name": "uid", "type": ["null", "string"], "default": null},
> {"name": "attrs", "type": {"type": "map", "values": ["null",
> "string"]}, "default": null},
> ...
> ]
>
>
> > desc tmp_table;
>
> +--------------------------+-----------------------+-----------------------+--+
> | col_name | data_type | comment
> |
>
> +--------------------------+-----------------------+-----------------------+--+
> | src | bigint | from deserializer |
> | uid | int | from deserializer |
> | attrs | map<string,string> | from deserializer |
> ....
> ...
> ~~~~~~~~~~~~~~~~
>
> If I run this INSERT INTO, I get the error message mentioned:
>
> insert into tmp_table values ( 'src1', 'uid1', null);
>
> Is there some way I can fix this issue?
>
>
>
> Thanks!
>
>
>
>
>