我尝试使用以下代码在表\u 1中查找上月数据,然后将其与表\u 2左键联接:
import pandas as pd
query = 'select * from table_1 where table_1.ts > "2016-07-12 00:00:00" as recent_table left join table_2 on table_1.t2__fk=table_2.id'
cursor = impala_con.cursor()
cursor.execute('USE my_db')
cursor.execute(query)
df_result = as_pandas(cursor)
df_result
但错误如下:
HiveServer2Error: AnalysisException: Syntax error in line 1:
...s > "2016-07-10 00:00:00" as recent_table left join table_2...
^
Encountered: AS
Expected: AND, BETWEEN, DIV, GROUP, HAVING, ILIKE, IN, IREGEXP, IS, LIKE, LIMIT, NOT, OFFSET, OR, ORDER, REGEXP, RLIKE, UNION
CAUSED BY: Exception: Syntax error
有人知道我错过了什么吗?怎样才能达到这个目标呢。谢谢!
1条答案
按热度按时间axr492tv1#
这是因为您的查询语法错误。不能对下面指出的条件语句使用别名。别名仅用于表名和列名。
正确的查询是