GP通过外部表装载数据时遇到ERROR:extra data after last expected column解决方法
2017-10-17 20:01
561 查看
一般通过hive -e导出文本时,我都习惯把比较容易出错的String类型字段做一次regexp_replace()处理,
因为如果字段里面含有制表符,那是一件很坑很坑的事。
根据错误信息,定位到含有出错字符串的行,备份到一个临时文件,实际上也就发现了一行有错误,没办法,只能查找删除它
附.
sed命令_Linux sed 命令用法详解
因为如果字段里面含有制表符,那是一件很坑很坑的事。
hive -e "select regexp_replace(String_Col1,'\t',''),Date_Col2,Integer_Col3 ... from hivedb.export_table" | sed 's/\t/\x01/g;s/\\/\\\\/g;s/\x00//g' >.../export_table.txtGP中新建外部表,根据之前把\t替换掉的分隔符x01来分隔,屡试不爽,成功率99.99%
drop external table if exists product_ext.export_table_ext; create external table product_ext.export_table_ext( String_Col1 varchar(1000), Date_Col2 date, Integer_Col3 integer, ... ) LOCATION ( 'gpfdist://xxx.xxx.xxx.xxx:port/.../export_table.txt' )FORMAT 'TEXT' (DELIMITER E'\x01'); --irview_vt即使sed 's/\t/\x01/g;s/\\/\\\\/g;s/\x00//g'处理过,分隔符按照\x01处理,今天还是遇到了0.01%的失败,下面是解决方法:
根据错误信息,定位到含有出错字符串的行,备份到一个临时文件,实际上也就发现了一行有错误,没办法,只能查找删除它
more rid_mac_201735to38w.txt | grep 'jQTIJWkiyytg97PCjh5U' > rid_mac_falsedata.txt把包含错误(也就是通过外部表映射到内部表出错)信息的行删除掉
sed -i '/jQTIJWkiyytg97PCjh5U/d' rid_mac_201735to38w.txt此时,就能正常插入了
Query returned successfully: 302060132 rows affected, 26.6 secs execution time.
附.
sed命令_Linux sed 命令用法详解
相关文章推荐
- Extra Data after Last Expected Column:hawq建外表load数据报错
- [Excel Services]连接外部数据库,刷新数据的时候遇到“Data Refresh Failed ”的解决方法
- lr场景异常Continuing after Error -26479: Conversion of form submission data to the target charset failed: U_TRUNCATED_CHAR_FOUND解决方法
- MYSQL5.7配置主从同步数据 Slave_IO_Running=NO,Last_IO_Error:1236 错误解决方法
- ERROR 1406 (22001): Data too long for column 解决方法
- ERROR 1265 (01000): Data truncated for column 解决方法
- 使用Vue.js加sass时遇到 Invalid CSS after ".xxx{": expected "}", was "{" 错误的解决方法
- 自己测试bolt程序时遇到error LNK2019: 无法解析的外部符号解决方法。
- Confluence迁移中遇到的问题(Data too long for column 'STRINGVAL')及解决方法
- ERROR 1406 (22001): Data too long for column 解决方法
- 通过miscdevice获得驱动私有数据结构体时file->private_data为空的解决方法
- ResultSet can not re-read row data for column X的解决方法
- flex中,用ArrayCollection作为DataGrid的dataProvider,想在ArrayCollection末尾插入数据的解决方法
- IIS7.0通过FastCGI方式运行PHP遇到的一些问题及解决方法
- "com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column"错误解决方法
- 编译安装MYSQL,遇到configure: error: No curses/termcap library found的解决方法!
- mySQL中"Data truncated for column xxx" 解决方法
- centos 安装mysql遇到configure: error: No curses/termcap library found 解决方法
- IIS7.0通过FastCGI方式运行PHP遇到的一些问题及解决方法
- IIS7.0通过FastCGI方式运行PHP遇到的一些问题及解决方法