Hive 在导出 csv 时抛出 ParseException
Hive throwing ParseException while exporting a csv
hive -e 'SELECT *, MIN(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MIN_YEARLY, MAX(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MAX_YEARLY, AVG(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS AVG_YEARLY, STDDEV(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS STD_YEARLY FROM NSEDATA ORDER BY SYMBOL;' | sed 's/[[:space:]]\+/,/g' > ~/output2.csv
运行 这段代码,我正在尝试导出 csv 但出现以下错误:
ParseException line 2:3 cannot recognize input near 'MIN' '(' 'HIGH' in expression specification
尝试添加 table 别名 (d
) 并使用 select d.*
而不是 select *
:
hive -e "SELECT d.*,
MIN(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MIN_YEARLY,
MAX(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MAX_YEARLY,
AVG(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS AVG_YEARLY,
STDDEV(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS STD_YEARLY
FROM NSEDATA d
ORDER BY SYMBOL" | sed 's/[[:space:]]\+/,/g' > ~/output2.csv
hive -e 'SELECT *, MIN(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MIN_YEARLY, MAX(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MAX_YEARLY, AVG(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS AVG_YEARLY, STDDEV(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS STD_YEARLY FROM NSEDATA ORDER BY SYMBOL;' | sed 's/[[:space:]]\+/,/g' > ~/output2.csv
运行 这段代码,我正在尝试导出 csv 但出现以下错误:
ParseException line 2:3 cannot recognize input near 'MIN' '(' 'HIGH' in expression specification
尝试添加 table 别名 (d
) 并使用 select d.*
而不是 select *
:
hive -e "SELECT d.*,
MIN(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MIN_YEARLY,
MAX(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS MAX_YEARLY,
AVG(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS AVG_YEARLY,
STDDEV(HIGH) OVER(PARTITION BY SYMBOL ORDER BY TIMESTAMP) AS STD_YEARLY
FROM NSEDATA d
ORDER BY SYMBOL" | sed 's/[[:space:]]\+/,/g' > ~/output2.csv