Skip to content

Commit

Permalink
Merge pull request #1 from pinohans/patch-2
Browse files Browse the repository at this point in the history
Update test_sqlalchemy_presto.py add unittest
  • Loading branch information
pinohans authored Jan 23, 2025
2 parents e146aa5 + 3a33f4e commit 780ce61
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion python/pyhive/tests/test_sqlalchemy_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@

import sqlalchemy

from pyhive.sqlalchemy_presto import PrestoDialect
from pyhive.tests.sqlalchemy_test_case import SqlAlchemyTestCase
from pyhive.tests.sqlalchemy_test_case import with_engine_connection
from sqlalchemy import types
from sqlalchemy import select
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import Column
from sqlalchemy.schema import MetaData
from sqlalchemy.schema import Table
from sqlalchemy.sql import text
from sqlalchemy.sql import try_cast
from sqlalchemy.types import String
from sqlalchemy.types import Double
from decimal import Decimal

import contextlib
Expand Down Expand Up @@ -102,4 +106,12 @@ def test_hash_table(self, engine, connection):
self.assertFalse(insp.has_table("THIS_TABLE_DOSE_not_exist"))
else:
self.assertFalse(Table('THIS_TABLE_DOSE_NOT_EXIST', MetaData(bind=engine)).exists())
self.assertFalse(Table('THIS_TABLE_DOSE_not_exits', MetaData(bind=engine)).exists())
self.assertFalse(Table('THIS_TABLE_DOSE_not_exits', MetaData(bind=engine)).exists())

def test_try_cast(self):
fake_table = Table('TestModel', MetaData(), Column('MaybeDouble', String))
query = str(select(try_cast(fake_table.c.MaybeDouble, Double)).compile(dialect=PrestoDialect(), compile_kwargs={"literal_binds": True}))
self.assertIn(
'try_cast("TestModel"."MaybeDouble" as DOUBLE)',
query
)

0 comments on commit 780ce61

Please sign in to comment.