如何将textinputformat.record.delimiter重置为其在hive cli / beeline内的默认值? [英] How to reset textinputformat.record.delimiter to its default value within hive cli / beeline?

查看:401
本文介绍了如何将textinputformat.record.delimiter重置为其在hive cli / beeline内的默认值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

textinputformat.record.delimiter 设置为非默认值,可用于加载多行文本,如以下演示所示。

但是,我无法在不退出cli的情况下将此参数设置回其默认值并重新打开。



以下任何选项都不起作用(以及其他一些试验)

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

重置;

有什么想法?

p>

Demo



  create table mytable(mycol string); 
插入mytable select concat('Hello',unhex('A'),'world');
从mytable中选择concat('>>>',mycol,'<<<')mycol;

NewLine被解释为记录分隔符,导致插入2条记录

  + ------------- + 
| mycol |
+ ------------- +
| >>>你好<<< |
| >>>世界<<< |
+ ------------- +






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

truncate table mytable;
插入mytable select concat('Hello',unhex('A'),'world');
从mytable中选择concat('>>>',mycol,'<<<')mycol;

整个文本被插入为一条记录

  + ---------- + 
| mycol |
+ ---------- +
| >>>您好|
|世界|
| <<< |
+ ---------- +






尝试将分隔符更改回换行符

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

truncate table mytable;
插入mytable select concat('Hello',unhex('A'),'world');
从mytable中选择concat('>>>',mycol,'<<<')mycol;

仍然得到相同的结果

  + ---------- + 
| mycol |
+ ---------- +
| >>>您好|
|世界|
| <<< |
+ ---------- +


解决方案 div>

使用unicode alt + A或\\\作为delimer。

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    |
| <<<      |
+----------+

解决方案

use unicode alt+A or \u0001 as delimer.

这篇关于如何将textinputformat.record.delimiter重置为其在hive cli / beeline内的默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆