我写了一个查询来在 Impala 中创建一个视图。该视图包含一个字段 record_date,它是格式为 yyyy-MM-dd hh:mm:ss 的字符串数据类型。在尝试执行使用 date_sub('2014-01-30 00:00:00',1) 提取先前日期记录的查询时,我收到如下错误:
错误:与 impalad 通信时出错:TSocket 读取 0 个字节。
如果我尝试对创建的表而不是视图执行相同的查询,我将正确获得输出。
任何帮助表示赞赏。
谢谢
这是一个错误,请升级到 Impala 的最新版本,因为它似乎已经从 1.2.3 修复,这已经很老了。
此问题不会在 Impala 2.2 上重现:
[localhost:21000] > create table test_ts_string ( x string );
[localhost:21000] > create view test_ts_string_view as select * from test_ts_string;
... insert data ..
[localhost:21000] > select x, date_sub(x, 1) from test_ts_string;
Query: select x, date_sub(x, 1) from test_ts_string
+---------------------+---------------------+
| x | date_sub(x, 1) |
+---------------------+---------------------+
| 2009-01-01 00:00:00 | 2008-12-31 00:00:00 |
| 2009-01-01 00:01:00 | 2008-12-31 00:01:00 |
| 2009-04-01 00:00:00 | 2009-03-31 00:00:00 |
| 2009-04-01 00:01:00 | 2009-03-31 00:01:00 |
| 2009-03-01 00:00:00 | 2009-02-28 00:00:00 |
| 2009-03-01 00:01:00 | 2009-02-28 00:01:00 |
| 2009-02-01 00:00:00 | 2009-01-31 00:00:00 |
| 2009-02-01 00:01:00 | 2009-01-31 00:01:00 |
+---------------------+---------------------+
Fetched 8 row(s) in 0.22s
[localhost:21000] > select x, date_sub(x, 1) from test_ts_string_view;
+---------------------+---------------------+
| x | _c1 |
+---------------------+---------------------+
| 2009-01-01 00:00:00 | 2008-12-31 00:00:00 |
| 2009-01-01 00:01:00 | 2008-12-31 00:01:00 |
| 2009-04-01 00:00:00 | 2009-03-31 00:00:00 |
| 2009-04-01 00:01:00 | 2009-03-31 00:01:00 |
| 2009-03-01 00:00:00 | 2009-02-28 00:00:00 |
| 2009-03-01 00:01:00 | 2009-02-28 00:01:00 |
| 2009-02-01 00:00:00 | 2009-01-31 00:00:00 |
| 2009-02-01 00:01:00 | 2009-01-31 00:01:00 |
+---------------------+---------------------+
Fetched 8 row(s) in 4.92s