我正在尝试使用我设置的 dask 集群运行和并行化这个 sqlalchemy 查询,因为我没有足够的内存从本地计算机执行它。
我的代码如下 - 我不确定这是否是实现此目的的最佳方法:
from dask.distributed import Client
import dask.dataframe as dd
from dask.delayed import delayed
client = Client(<IP Address>)
recent_dates = ['2020-04-24', '2020-04-23', 2020-04-22']
query = """SELECT * FROM table WHERE date = '%s'"""
queries = [query.format(d) for d in recent_dates]
from sqlalchemy.engine import create_engine
conn = create_engine(f'presto://{user}:{password}@{host}:{port}/{catalog}/{schema}',
connect_args={'protocol': 'https',
'requests_kwargs': {'verify': key}})
con = engine.connect()
df = dd.from_delayed([delayed(pd.read_sql_query)(q, conn) for q in queries])
我收到以下错误:
TypeError: can't pickle _thread.RLock objects