How to reset textinputformat.record.delimiter to its default value within hive cli / beeline?

冷暖自知 提交于 2019-12-22 05:57:17

问题


Setting textinputformat.record.delimiter to a non-default value, is useful for loading multi-row text, as shown in the demo below.
However, I'm failing to set this parameter back to its default value without exiting the cli and reopen it.

None of the following options worked (nor some other trials)

set textinputformat.record.delimiter='\n';
set textinputformat.record.delimiter='\r';
set textinputformat.record.delimiter='\r\n';
set textinputformat.record.delimiter='
';

reset;

Any thought?

Thanks

Demo

create table mytable (mycol string);
insert into mytable select concat('Hello',unhex('A'),'world');    
select concat('>>>',mycol,'<<<') as mycol from mytable;

NewLine is interpreted is record delimiter, causing the insert of 2 records

+-------------+
|    mycol    |
+-------------+
| >>>Hello<<< |
| >>>world<<< |
+-------------+

set textinputformat.record.delimiter='\0';

truncate table mytable;
insert into mytable select concat('Hello',unhex('A'),'world');    
select concat('>>>',mycol,'<<<') as mycol from mytable;

The whole text was inserted as a single record

+----------+
|  mycol   |
+----------+
| >>>Hello |
| world    |
| <<<      |
+----------+

Trying to change the delimiter back to newline

set textinputformat.record.delimiter='\n';

truncate table mytable;
insert into mytable select concat('Hello',unhex('A'),'world');    
select concat('>>>',mycol,'<<<') as mycol from mytable;

Still get the same results

+----------+
|  mycol   |
+----------+
| >>>Hello |
| world    |
| <<<      |
+----------+

回答1:


Have you checked the "textinputformat.record.delimiter" variable state? Was it really changed? You could do it calling set textinputformat.record.delimiter without any value.
If it was changed, but not works, you could definitely create issue in the issue tracker. As a workaround for setting delimiter param back to default value, you could try RESET command. It would reset ALL properties to default values, though this solution could be unacceptable for your case.




回答2:


use unicode alt+A or \u0001 as delimer.



来源:https://stackoverflow.com/questions/42672451/how-to-reset-textinputformat-record-delimiter-to-its-default-value-within-hive-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!