Sql 如何连接所有表';列转换为分隔格式,而不单独指定每一列

Sql 如何连接所有表';列转换为分隔格式,而不单独指定每一列,sql,hadoop,hive,apache-spark-sql,hiveql,Sql,Hadoop,Hive,Apache Spark Sql,Hiveql,例如 给定一个只包含基元类型的表,例如- create table t (i int, dt date, str string, ts timestamp, bl boolean) ; insert into t select 1,date '2017-03-14','Hello world',timestamp '2017-03-14 14:37:28.889',true ; select * from t ; +-----+------------+-------------+---

例如

给定一个只包含基元类型的表,例如-

create table t (i int, dt date, str string, ts timestamp, bl boolean)
;

insert into t 
select 1,date '2017-03-14','Hello world',timestamp '2017-03-14 14:37:28.889',true
;

select * from t
;

+-----+------------+-------------+-------------------------+------+
| t.i |    t.dt    |    t.str    |          t.ts           | t.bl |
+-----+------------+-------------+-------------------------+------+
|   1 | 2017-03-14 | Hello world | 2017-03-14 14:37:28.889 | true |
+-----+------------+-------------+-------------------------+------+
。。。和
| |
作为请求的分隔符
(为了简单起见,我们可以假设它不会出现在数据中的任何地方)


请求的结果将是单个分隔字符串

1 | | | | | | | | | | | | | | |世界你好| | 2017-03-14:37:28.889 | | | | |真的


此解决方案仅限于包含“基本”类型(无结构、数组、映射等)的表

1 | | | | | | | | | | | | | | |世界你好| | 2017-03-14:37:28.889 | | | | |真的

附言

concat(*)
有效,但值之间没有分隔符。
concat_ws(…,*)
产生一个异常

select  printf(concat('%s',repeat('|||%s',field(unhex(1),*,unhex(1))-2)),*) 
from    t
;