将多行 Athena 查询的结果存储在变量中
Store result of a multi-line Athena query in a variable
我正在使用 https://github.com/finklabs/jupyter-athena-sql 从 Jupyter Lab 查询 Athena。我需要将多行查询的结果存储在一个变量中。我可以按如下方式对单行查询执行此操作:
pd = %athena select 1
pd
但是,我似乎无法弄清楚如何访问多行查询的结果,例如:
%%athena
select col1, count(*)
from my_table
group by col1
In the implementation of the Athena extension 我可以看到它正在返回一个数据帧,我想知道 Jupyter Lab 中是否有一个它绑定到的标准变量?
谢谢!
我最终查找并调用了注册为在 jupyter-athena-sql 扩展中执行 Athena 查询的魔法函数,如下所示:
athena = get_ipython().find_cell_magic('athena')
df = athena("""select col1, count(*)
from my_table
group by col1""")
我正在使用 https://github.com/finklabs/jupyter-athena-sql 从 Jupyter Lab 查询 Athena。我需要将多行查询的结果存储在一个变量中。我可以按如下方式对单行查询执行此操作:
pd = %athena select 1
pd
但是,我似乎无法弄清楚如何访问多行查询的结果,例如:
%%athena
select col1, count(*)
from my_table
group by col1
In the implementation of the Athena extension 我可以看到它正在返回一个数据帧,我想知道 Jupyter Lab 中是否有一个它绑定到的标准变量?
谢谢!
我最终查找并调用了注册为在 jupyter-athena-sql 扩展中执行 Athena 查询的魔法函数,如下所示:
athena = get_ipython().find_cell_magic('athena')
df = athena("""select col1, count(*)
from my_table
group by col1""")