使用 HQL 文件时从直线获取准确的 return 代码?

Get an accurate return code from beeline when using an HQL file?

我有一个 init 文件和一个 HQL 文件,我要传递给 beeline 来执行:

beeline -i "$INIT_FILE" -f "$BEELINE_HQL_FILE"  

并且我希望 beeline 停止执行脚本,并且 return 如果脚本中有任何行失败,则返回错误代码。但是,如果脚本中存在错误,那么它将继续执行并且 returns 0 作为 return 代码。 我怎样才能配置它来做我想做的事?

来自HS2 Clients Guide

--force=[true/false] Continue running script even after errors (true) or do not continue (false). Default is false.

Usage: beeline --force=true

因此,默认情况下,beeline 会在出现错误时停止执行脚本。如果它在您的环境中表现不同,也许您可​​以尝试使用 $ beeline --force=false ...

更新

当执行 HQL 语句或脚本失败时,Beeline 将 return 非零 return 代码。

$ beeline -u "jdbc:hive2://hiveserver2:10000/default;" -e "describe unknown_table"
Error: Error while compiling statement: FAILED: SemanticException [Error 10001]: Table not found unknown_table (state=42S02,code=10001)

$ echo $?
1
$