hive 表的一些默认值

见 Hadoop.The.Definitive.Guide.2nd.Edition P388

Thus, the statement:
CREATE TABLE ...;
is identical to the more explicit:
CREATE TABLE ...
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
COLLECTION ITEMS TERMINATED BY '\002'
MAP KEYS TERMINATED BY '\003'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE;

Notice that the octal form of the delimiter characters can be used—001 for Control-A, for instance.


STORED AS TEXTFILE 这个目前可以通过配置文件配置,配置项是hive.default.fileformat。
HiveConf
// Default file format for CREATE TABLE statement
// Options: TextFile, SequenceFile
HIVEDEFAULTFILEFORMAT("hive.default.fileformat", "TextFile"),

其他诸如: FIELD_DELIM、COLLECTION_DELIM、MAPKEY_DELIM、SERIALIZATION_NULL_FORMAT目前无法通过配置文件进行配置:

以LazySimpleSerDe的为例来看:

public class LazySimpleSerDe implements SerDe {

public static final byte[] DefaultSeparators = {(byte) 1, (byte) 2, (byte) 3};

public static SerDeParameters initSerdeParams(Configuration job,
Properties tbl, String serdeName) throws SerDeException {
SerDeParameters serdeParams = new SerDeParameters();
// Read the separators: We use 8 levels of separators by default, but we
// should change this when we allow users to specify more than 10 levels
// of separators through DDL.
serdeParams.separators = new byte[8];
serdeParams.separators[0] = getByte(tbl.getProperty(Constants.FIELD_DELIM,
tbl.getProperty(Constants.SERIALIZATION_FORMAT)), DefaultSeparators[0]);
serdeParams.separators[1] = getByte(tbl
.getProperty(Constants.COLLECTION_DELIM), DefaultSeparators[1]);
serdeParams.separators[2] = getByte(
tbl.getProperty(Constants.MAPKEY_DELIM), DefaultSeparators[2]);
for (int i = 3; i < serdeParams.separators.length; i++) {
serdeParams.separators[i] = (byte) (i + 1);
}

serdeParams.nullString = tbl.getProperty(
Constants.SERIALIZATION_NULL_FORMAT, "\\N");
serdeParams.nullSequence = new Text(serdeParams.nullString);

}

}

Constants: public static final String SERIALIZATION_NULL_FORMAT = "serialization.null.format";
serialization.null.format默认为/N
^A为中间的分隔符也就是001
1^A/N
2^A/N
3^A3
4^A4
5^A5

serdeParams.nullString = tbl.getProperty(
Constants.SERIALIZATION_NULL_FORMAT, "\\N");
早前的版本有个问题见:http://www.linezing.com/blog/?p=500,最新的版本已经修复了该问题。

ALTER TABLE ctas_null_format1 SET SERDEPROPERTIES ('serialization.null.format'='\\N');
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值