Repository: dask/dask

Issue:
`sqlalchemy` 2.0 compatibility
`sqlalchemy` 2.0 was recently released and is causing tests to fail. We should temporarily pin `sqlalchemy<2` in CI as a temporary workaround. 

EDIT: https://github.com/dask/dask/pull/9897 adds the `<2` pin to CI 


Discussion:
https://github.com/coiled/coiled-runtime/pull/675 pins it in coiled-runtime too

Resolving patch:
diff --git a/dask/dataframe/io/sql.py b/dask/dataframe/io/sql.py
--- a/dask/dataframe/io/sql.py
+++ b/dask/dataframe/io/sql.py
@@ -141,7 +141,7 @@ def read_sql_query(
         if limits is None:
             # calculate max and min for given index
             q = sa.sql.select(
-                [sa.sql.func.max(index), sa.sql.func.min(index)]
+                sa.sql.func.max(index), sa.sql.func.min(index)
             ).select_from(sql.subquery())
             minmax = pd.read_sql(q, engine)
             maxi, mini = minmax.iloc[0]
@@ -151,7 +151,7 @@ def read_sql_query(
             dtype = pd.Series(limits).dtype
 
         if npartitions is None:
-            q = sa.sql.select([sa.sql.func.count(index)]).select_from(sql.subquery())
+            q = sa.sql.select(sa.sql.func.count(index)).select_from(sql.subquery())
             count = pd.read_sql(q, engine)["count_1"][0]
             npartitions = (
                 int(round(count * bytes_per_row / parse_bytes(bytes_per_chunk))) or 1
@@ -309,9 +309,7 @@ def read_sql_table(
     engine = sa.create_engine(con, **engine_kwargs)
     m = sa.MetaData()
     if isinstance(table_name, str):
-        table_name = sa.Table(
-            table_name, m, autoload=True, autoload_with=engine, schema=schema
-        )
+        table_name = sa.Table(table_name, m, autoload_with=engine, schema=schema)
     else:
         raise TypeError(
             "`table_name` must be of type str, not " + str(type(table_name))
@@ -339,7 +337,7 @@ def read_sql_table(
     if index.name not in [c.name for c in columns]:
         columns.append(index)
 
-    query = sql.select(columns).select_from(table_name)
+    query = sql.select(*columns).select_from(table_name)
 
     return read_sql_query(
         sql=query,


Test patch:
diff --git a/dask/dataframe/io/tests/test_sql.py b/dask/dataframe/io/tests/test_sql.py
--- a/dask/dataframe/io/tests/test_sql.py
+++ b/dask/dataframe/io/tests/test_sql.py
@@ -386,7 +386,7 @@ def test_query(db):
     import sqlalchemy as sa
     from sqlalchemy import sql
 
-    s1 = sql.select([sql.column("number"), sql.column("name")]).select_from(
+    s1 = sql.select(sql.column("number"), sql.column("name")).select_from(
         sql.table("test")
     )
     out = read_sql_query(s1, db, npartitions=2, index_col="number")
@@ -394,10 +394,8 @@ def test_query(db):
 
     s2 = (
         sql.select(
-            [
-                sa.cast(sql.column("number"), sa.types.BigInteger).label("number"),
-                sql.column("name"),
-            ]
+            sa.cast(sql.column("number"), sa.types.BigInteger).label("number"),
+            sql.column("name"),
         )
         .where(sql.column("number") >= 5)
         .select_from(sql.table("test"))
@@ -412,7 +410,7 @@ def test_query_index_from_query(db):
 
     number = sql.column("number")
     name = sql.column("name")
-    s1 = sql.select([number, name, sql.func.length(name).label("lenname")]).select_from(
+    s1 = sql.select(number, name, sql.func.length(name).label("lenname")).select_from(
         sql.table("test")
     )
     out = read_sql_query(s1, db, npartitions=2, index_col="lenname")
@@ -434,7 +432,7 @@ def test_query_with_meta(db):
     meta = pd.DataFrame(data, index=index)
 
     s1 = sql.select(
-        [sql.column("number"), sql.column("name"), sql.column("age")]
+        sql.column("number"), sql.column("name"), sql.column("age")
     ).select_from(sql.table("test"))
     out = read_sql_query(s1, db, npartitions=2, index_col="number", meta=meta)
     # Don't check dtype for windows https://github.com/dask/dask/issues/8620
@@ -450,7 +448,7 @@ def test_no_character_index_without_divisions(db):
 def test_read_sql(db):
     from sqlalchemy import sql
 
-    s = sql.select([sql.column("number"), sql.column("name")]).select_from(
+    s = sql.select(sql.column("number"), sql.column("name")).select_from(
         sql.table("test")
     )
     out = read_sql(s, db, npartitions=2, index_col="number")