Skip to content

Commit 4c3a9f6

Browse files
guyco33hashhar
authored andcommitted
Add test for queries reaching completed state
1 parent e260273 commit 4c3a9f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/integration/test_sqlalchemy_integration.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License
12+
import os
1213
import pytest
1314
import sqlalchemy as sqla
1415
from sqlalchemy.sql import and_, or_, not_
@@ -177,6 +178,23 @@ def test_conjunctions(trino_connection):
177178
assert len(rows) == 1
178179

179180

181+
@pytest.mark.parametrize('trino_connection', ['system'], indirect=True)
182+
def test_scalar_query_completed_state(trino_connection):
183+
_, conn = trino_connection
184+
metadata = sqla.MetaData()
185+
queries = sqla.Table('queries', metadata, schema='runtime', autoload_with=conn)
186+
s = sqla.select(queries.c.state).where(queries.c.query == "SELECT version()")
187+
result = conn.execute(s)
188+
rows = result.fetchall()
189+
assert len(rows) > 0
190+
for row in rows:
191+
if os.environ.get("TRINO_VERSION") == '351':
192+
assert row['state'] == 'FAILED'
193+
else:
194+
# TODO: Query state should be FINISHED instead (will be fixed in https://github.com/trinodb/trino-python-client/pull/220)
195+
assert row['state'] == 'FAILED'
196+
197+
180198
@pytest.mark.parametrize('trino_connection', ['tpch'], indirect=True)
181199
def test_textual_sql(trino_connection):
182200
_, conn = trino_connection

0 commit comments

Comments
 (0)