Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 根据数据类型和列名在impala表中插入记录_Linux_Shell_Hadoop_Hive_Impala - Fatal编程技术网

Linux 根据数据类型和列名在impala表中插入记录

Linux 根据数据类型和列名在impala表中插入记录,linux,shell,hadoop,hive,impala,Linux,Shell,Hadoop,Hive,Impala,我有一些黑斑羚表,格式是这样的 +--------------------------+-----------+---------+ | name | type | comment | +--------------------------+-----------+---------+ | col_key | bigint | | | col_cd |

我有一些黑斑羚表,格式是这样的

+--------------------------+-----------+---------+
| name                     | type      | comment |
+--------------------------+-----------+---------+
| col_key                   | bigint    |         |
| col_cd                    | smallint  |         |
| col_desc                  | string    |         |
| col_type_cd               | string    |         |
| col_scheme_cd             | string    |         |
| name                      | string    |         |
| source_cd                 | string    |         |
| source_cd1                | bigint    |         |
| load_dt                   | timestamp |         |
| effective_start_dt        | timestamp |         |
| effective_end_dt          | timestamp |         |
+--------------------------+-----------+---------+
我必须像这样插入值

如果数据类型为

bigint then insert      0
smallint then insert    0
decimal then  insert    0.0
float then insert       0.0
string then insert      unknown
timestamp then insert   1970-01-01 00:00:00
如果列名为

effective_start_dt then insert 1970-01-01 00:00:00
effective_end_dt then insert   3499-12-31 00:00:00
我已经实现了一个解决方案,在这个解决方案中,我能够识别数据类型并基于 在此基础上,我插入了记录,但在我的第二个条件下,它不起作用,我根据列名插入记录,并插入
1970-01-01 00:00:00
vale以
effective\u end\u dt

在这方面寻求帮助。
其他表的列位置可能会有所不同,因此我尝试一些通用的解决方案。我正试图通过shell脚本实现此解决方案。

您需要将字符串转换为时间戳

cast("1979-01-01 00:00:00" as timestamp)