我是 Azure databricks 的新手,所以希望我的问题不会太离谱。我正在尝试在 Azure databricks 笔记本中运行 sql 下推查询,但使用“with 语句”,但它不起作用。我尝试了类似的下推查询,但没有成功:
sql = """
with r as (select max(load_id) as load_id, table_name
from LOG.TABLE_AND_FILE_ACQUISITION_MONITORING
group by TABLE_NAME)
(select * from r) t"""
sql = """
(with r as (select max(load_id) as load_id, table_name
from LOG.TABLE_AND_FILE_ACQUISITION_MONITORING
group by TABLE_NAME)
select * from r) t"""
运行此命令后:
df = spark.read.jdbc(url=jdbc_url, table=sql, properties=connection_properties)
display(df)
我收到此错误:关键字“with”附近的语法不正确。 有人可以知道如何使其工作的语法吗? 谢谢!
这应该是正确的语法:
sql = """
with r as (select max(load_id) as load_id, table_name
from LOG.TABLE_AND_FILE_ACQUISITION_MONITORING
group by TABLE_NAME)
select * from r"""