Sql 配置单元中的子查询问题

Sql 配置单元中的子查询问题,sql,bash,hive,Sql,Bash,Hive,我正在尝试在bash的配置单元中运行子查询。但问题是编译器说它无法识别查询中的子查询。有什么想法吗 #!/bin/bash echo "Hello world" ##################################################################### #This line will connect to the database and execute the query in Hive ############################

我正在尝试在bash的配置单元中运行子查询。但问题是编译器说它无法识别查询中的子查询。有什么想法吗

#!/bin/bash
echo "Hello world"

#####################################################################
#This line will connect to the database and execute the query in Hive
####################################################################

var1=$(beeline --showHeader=false --outputformat=tsv2 -u "jdbc:hive2:XXXXXXXXX" <<EOF
select $2 from $3.$1 where length($2)=(select max(length($2)) from $3.$1) limit 1;
EOF
)


#####################################################################
#This will output the result of the query
####################################################################

echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo "We are currently analyzing Table:$1 and Column:$2"
echo "The value wth a maximum length for $1 is $var1"
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

我担心您的查询在配置单元中无法工作,因为您正在执行子查询。您必须重写查询

请尝试下一个代码以获取具有最大长度的$2:

从选择maxlength$2作为长度2中选择$2,从$3中选择$2。$1按$2分组按长度2说明限制1


此外,您还可以使用-e选项执行查询,正如@mazaneicha所提到的。

错误消息在哪里?另外,您可能最好使用直线查询参数…-e,而不是尝试通过stdin提供查询文本。