一、presto不支持insert overwrite
Presto中不支持insert overwrite语法,只能先delete,然后insert into。
详见:Presto上使用SQL遇到的一些坑:https://segmentfault.com/a/1190000013120454
presto insert overwrite 替代方案:
1.hive建表
2.presto查询结果放到txt文件
3.load
hive -e"
use app;
CREATE external TABLE IF NOT EXISTS app.tablename(
...
m_pt bigint COMMENT '播放时长'
)
COMMENT '表描述'
PARTITIONED BY(dt STRING, testid STRING, type STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE
LOCATION '/dw/app/tablename';
"
# run sql
$presto --server uhadoop-op3raf-master1:28080 --catalog hive --schema adm --file $TO_SQL | sed 's/"//g' > $RESULT_LINK
# load data
hive -e "load data local inpath '${RESULT_LINK}' overwrite