Hive 查询无法识别表达式规范中 'select' 'max' '(' 附近的输入

Hive Query cannot recognize input near 'select' 'max' '(' in expression specification

我在配置单元中有一个 table 具有以下结构

hive> describe stock_summary;                                                                                                                 
OK                                                                                                                                            
year                    int                                                                                                                   
month                   int                                                                                                                   
symbol                  string                                                                                                                
company_name            string                                                                                                                
sector                  string                                                                                                                
sub_industry            string                                                                                                                
state                   string                                                                                                                
avg_open                double                                                                                                                
avg_close               double                                                                                                                
avg_low                 double                                                                                                                
avg_high                double                                                                                                                
avg_volume              double     

我想获取最新的日期(年月)。

在尝试执行查询时 select max(s1.month) from stock_summary s1 where s1.year = (select max(s2.year) from stock_summary s2) t; 我收到以下错误

NoViableAltException(226@[400:1: precedenceEqualExpression : ( (left= precedenceBitwiseOrExpression -> $left) ( ( KW_NOT precedenceEqualNegata
bleOperator notExpr= precedenceBitwiseOrExpression ) -> ^( KW_NOT ^( precedenceEqualNegatableOperator $precedenceEqualExpression $notExpr) ) |
 ( precedenceEqualOperator equalExpr= precedenceBitwiseOrExpression ) -> ^( precedenceEqualOperator $precedenceEqualExpression $equalExpr) | (
 KW_NOT KW_IN LPAREN KW_SELECT )=> ( KW_NOT KW_IN subQueryExpression ) -> ^( KW_NOT ^( TOK_SUBQUERY_EXPR ^( TOK_SUBQUERY_OP KW_IN ) subQueryEx
pression $precedenceEqualExpression) ) | ( KW_NOT KW_IN expressions ) -> ^( KW_NOT ^( TOK_FUNCTION KW_IN $precedenceEqualExpression expression
s ) ) | ( KW_IN LPAREN KW_SELECT )=> ( KW_IN subQueryExpression ) -> ^( TOK_SUBQUERY_EXPR ^( TOK_SUBQUERY_OP KW_IN ) subQueryExpression $prece
denceEqualExpression) | ( KW_IN expressions ) -> ^( TOK_FUNCTION KW_IN $precedenceEqualExpression expressions ) | ( KW_NOT KW_BETWEEN (min= pr
ecedenceBitwiseOrExpression ) KW_AND (max= precedenceBitwiseOrExpression ) ) -> ^( TOK_FUNCTION Identifier["between"] KW_TRUE $left $min $max)
 | ( KW_BETWEEN (min= precedenceBitwiseOrExpression ) KW_AND (max= precedenceBitwiseOrExpression ) ) -> ^( TOK_FUNCTION Identifier["between"] 
KW_FALSE $left $min $max) )* | ( KW_EXISTS LPAREN KW_SELECT )=> ( KW_EXISTS subQueryExpression ) -> ^( TOK_SUBQUERY_EXPR ^( TOK_SUBQUERY_OP KW
_EXISTS ) subQueryExpression ) );])                                                                                                           
        at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)                                                                                    
        at org.antlr.runtime.DFA.predict(DFA.java:116)                                                                                        
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceEqualExpression(HiveParser_IdentifiersParser.java:8668)     
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceNotExpression(HiveParser_IdentifiersParser.java:9690)       
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceAndExpression(HiveParser_IdentifiersParser.java:9809)       
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceOrExpression(HiveParser_IdentifiersParser.java:9968)        
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.expression(HiveParser_IdentifiersParser.java:6584)                    
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.atomExpression(HiveParser_IdentifiersParser.java:6808)                
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceFieldExpression(HiveParser_IdentifiersParser.java:6879)     
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceUnaryPrefixExpression(HiveParser_IdentifiersParser.java:7264
)                                                                                                                                             
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceUnarySuffixExpression(HiveParser_IdentifiersParser.java:7324
)                                                                                                                                             
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceBitwiseXorExpression(HiveParser_IdentifiersParser.java:7508)
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceStarExpression(HiveParser_IdentifiersParser.java:7668)      
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedencePlusExpression(HiveParser_IdentifiersParser.java:7828)      
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceAmpersandExpression(HiveParser_IdentifiersParser.java:7988) 
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceBitwiseOrExpression(HiveParser_IdentifiersParser.java:8147) 
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceEqualExpression(HiveParser_IdentifiersParser.java:8803)     
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceNotExpression(HiveParser_IdentifiersParser.java:9690)       
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceAndExpression(HiveParser_IdentifiersParser.java:9809)       
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.precedenceOrExpression(HiveParser_IdentifiersParser.java:9968)        
        at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.expression(HiveParser_IdentifiersParser.java:6584)                    
        at org.apache.hadoop.hive.ql.parse.HiveParser.expression(HiveParser.java:44936)                                                       
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.searchCondition(HiveParser_FromClauseParser.java:6530)                 
        at org.apache.hadoop.hive.ql.parse.HiveParser_FromClauseParser.whereClause(HiveParser_FromClauseParser.java:6438)                     
        at org.apache.hadoop.hive.ql.parse.HiveParser.whereClause(HiveParser.java:44905)                                                      
        at org.apache.hadoop.hive.ql.parse.HiveParser.singleSelectStatement(HiveParser.java:42062)                                            
        at org.apache.hadoop.hive.ql.parse.HiveParser.selectStatement(HiveParser.java:41720)                                                  
        at org.apache.hadoop.hive.ql.parse.HiveParser.regularBody(HiveParser.java:41657)                                                      
        at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpressionBody(HiveParser.java:40710)                                     
        at org.apache.hadoop.hive.ql.parse.HiveParser.queryStatementExpression(HiveParser.java:40586)                                         
        at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1529)                                                     
        at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1065)                                                         
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:201)                                                            
        at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)                                                            
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:522)                                                                          
        at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1356)                                                                 
        at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1473)                                                                     
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1285)                                                                             
        at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1275)                                                                             
        at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:226)                                                           
        at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:175)                                                                
        at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:389)                                                               
        at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:781)                                                             
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:699)                                                                       
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:634)                                                                      
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)                                                                        
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)                                                      
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                              
        at java.lang.reflect.Method.invoke(Method.java:498)                                                                                   
        at org.apache.hadoop.util.RunJar.run(RunJar.java:221)                                                                                 
        at org.apache.hadoop.util.RunJar.main(RunJar.java:136)                                                                                
FAILED: ParseException line 1:60 cannot recognize input near 'select' 'max' '(' in expression specification                                   
hive>                                                                                                           

` 我正在使用配置单元 1.1.0。

谁能告诉我为什么会失败?

select 
    t.* 
from 
    stock_summary t 
order by 
    year desc, month desc 
limit 1