Dask read_sql_table errors out when using an SQLAlchemy expression

前端 未结 3 902
没有蜡笔的小新
没有蜡笔的小新 2021-01-23 12:55

I\'m trying to use an SQLAlchemy expression with dask\'s read_sql_table in order to bring down a dataset that is created by joining and filtering a few different tables. The do

3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-23 13:23

    As Chris said in a different answer, Dask wraps your query in something of a form SELECT columns FROM (yourquery), which is an invalid syntax for PostgreSQL, because it expects an alias for that parenthesised expression. Without reimplementing the whole read_sql_table method, the expression can be aliased simply by adding .alias('somename') to your select, i.e.

    select([t]).limit(5).alias('foo')
    

    That expression, when wrapped by Dask, generates correct syntax for Postgres

    SELECT columns FROM (yourquery) AS foo
    

提交回复
热议问题