snowflake-sqlalchemy icon indicating copy to clipboard operation
snowflake-sqlalchemy copied to clipboard

SNOW-591541: AssertionError when using future=True

Open jordantshaw opened this issue 2 years ago • 0 comments

I am having an issue when setting the "future" parameter to "True" when creating the engine. Any ideas?

  1. What version of Python are you using?

    Python 3.9.12

  2. What operating system and processor architecture are you using?

    macOS-10.16-x86_64-i386-64bit

  3. What are the component versions in the environment (pip freeze)?

aiohttp @ file:///opt/concourse/worker/volumes/live/ba252660-e2b9-4a6d-6906-9be4ed7deda4/volume/aiohttp_1646806382603/work
aiosignal @ file:///tmp/build/80754af9/aiosignal_1637843061372/work
appdirs==1.4.4
asn1crypto @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_df35a2a4-e7a8-49c6-ace6-edff7129cef9u6px56sz/croots/recipe/asn1crypto_1652362655696/work
async-timeout @ file:///tmp/build/80754af9/async-timeout_1637851218186/work
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
Authlib @ file:///tmp/build/80754af9/authlib_1623136273663/work
azure-common @ file:///tmp/build/80754af9/azure-common_1633356537236/work
azure-core @ file:///opt/conda/conda-bld/azure-core_1624572659128/work
azure-storage-blob @ file:///tmp/build/80754af9/azure-storage-blob_1633359807179/work
bcrypt @ file:///opt/concourse/worker/volumes/live/7540a0c1-471d-4a61-5243-0bfec3601197/volume/bcrypt_1607022666156/work
blinker==1.4
bokeh @ file:///opt/concourse/worker/volumes/live/daea12c5-5a78-4471-406c-958ab70942ea/volume/bokeh_1638362839809/work
boto3 @ file:///opt/conda/conda-bld/boto3_1649078879353/work
botocore @ file:///opt/conda/conda-bld/botocore_1649076662316/work
Bottleneck @ file:///opt/concourse/worker/volumes/live/220f0b56-5355-4122-6705-41fcd18e285c/volume/bottleneck_1648028927947/work
brotlipy==0.7.0
cached-property @ file:///tmp/build/80754af9/cached-property_1600785575025/work
certifi==2021.10.8
cffi @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/croot-2p6q7e2r/cffi_1642701115063/work
charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work
click @ file:///opt/concourse/worker/volumes/live/17ca243b-fc66-462b-4bc1-f11ad524e336/volume/click_1646056621177/work
cloudpickle @ file:///tmp/build/80754af9/cloudpickle_1632508026186/work
coverage @ file:///opt/concourse/worker/volumes/live/e29d4cc8-d994-4292-6cc0-7b7ee6a5fd49/volume/coverage_1645539132539/work
cryptography @ file:///opt/concourse/worker/volumes/live/3143e751-d0f4-457e-7dc5-b7eaa48a56a8/volume/cryptography_1633520383659/work
Cython @ file:///opt/concourse/worker/volumes/live/bb723241-1e07-4a4e-6f4c-519cc9dd2786/volume/cython_1647850373871/work
cytoolz==0.11.0
dask @ file:///opt/conda/conda-bld/dask-core_1647268715755/work
distributed @ file:///opt/conda/conda-bld/distributed_1647271944416/work
entrypoints @ file:///opt/concourse/worker/volumes/live/78b2c4ae-da17-4aa7-7fdc-138f840abf07/volume/entrypoints_1649926486598/work
et-xmlfile==1.1.0
frozenlist @ file:///opt/concourse/worker/volumes/live/b4c48fd3-7df7-4aa9-70fc-74aba3122503/volume/frozenlist_1637767148873/work
fsspec @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_525f1e44-6d75-452d-9a70-93c42355faa3jwokas7u/croots/recipe/fsspec_1652802115470/work
greenlet @ file:///opt/concourse/worker/volumes/live/b27b4e9e-4697-4d57-403b-f82d36a391ca/volume/greenlet_1628888146890/work
HeapDict @ file:///Users/ktietz/demo/mc3/conda-bld/heapdict_1630598515714/work
idna @ file:///tmp/build/80754af9/idna_1637925883363/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
intake @ file:///opt/conda/conda-bld/intake_1647436631684/work
isodate @ file:///Users/ktietz/demo/mc3/conda-bld/isodate_1630584690429/work
JayDeBeApi @ file:///tmp/build/80754af9/jaydebeapi_1601401763009/work
Jinja2 @ file:///opt/conda/conda-bld/jinja2_1647436528585/work
jmespath @ file:///Users/ktietz/demo/mc3/conda-bld/jmespath_1630583964805/work
JPype1 @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/croot-t9a8b439/jpype1_1643968578667/work
locket @ file:///opt/concourse/worker/volumes/live/93dd8d31-1785-4a47-5e27-b3dcf1402e70/volume/locket_1647006093697/work
lxml @ file:///opt/concourse/worker/volumes/live/8e73df53-5332-4884-7b1c-0b765f6e416b/volume/lxml_1646642659239/work
MarkupSafe @ file:///opt/concourse/worker/volumes/live/1bcf0940-5bf8-4171-61e3-2133f5885e8b/volume/markupsafe_1621528148241/work
mkl-fft==1.3.1
mkl-random @ file:///opt/concourse/worker/volumes/live/0cda23d8-7460-44b2-7e5d-3c76a8a0ca7e/volume/mkl_random_1626186083266/work
mkl-service==2.4.0
msgpack @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_8471ad7f-dce1-4146-86d4-c2864258a94duzpja450/croots/recipe/msgpack-python_1652362671722/work
msrest @ file:///tmp/build/80754af9/msrest_1633357089145/work
multidict @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/croot-af6k74k7/multidict_1640703861097/work
numexpr @ file:///opt/concourse/worker/volumes/live/87ac54fe-281a-440d-4d94-26ac99bdabdc/volume/numexpr_1640704258458/work
numpy @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_e3f85f54-0572-4c0e-b190-4bc4766fc3fenewxarhq/croots/recipe/numpy_and_numpy_base_1652801682879/work
oauthlib @ file:///opt/conda/conda-bld/oauthlib_1644332107998/work
openpyxl @ file:///tmp/build/80754af9/openpyxl_1632777717936/work
oscrypto @ file:///tmp/build/80754af9/oscrypto_1633350059025/work
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pandas==1.3.5
pandas-flavor==0.2.0
paramiko @ file:///opt/conda/conda-bld/paramiko_1640109032755/work
partd @ file:///opt/conda/conda-bld/partd_1647245470509/work
Pillow==9.0.1
platformdirs @ file:///tmp/build/80754af9/platformdirs_1638968569495/work
pluggy @ file:///opt/concourse/worker/volumes/live/42ef51ae-f79c-40e0-6d26-eb6fe9d8ba6e/volume/pluggy_1648042596777/work
psutil @ file:///opt/concourse/worker/volumes/live/da41f1b1-060b-47fa-4c17-557e069ead1d/volume/psutil_1612298011002/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyarrow==4.0.1
pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work
pycryptodomex @ file:///opt/concourse/worker/volumes/live/c6c91a2f-3c3c-412e-7c83-8fa5f2689ca7/volume/pycryptodomex_1613764683653/work
pydantic @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_8c98be6a-d0b5-43d1-b487-874a2b344c9f1gqf2z78/croots/recipe/pydantic_1651218729478/work
PyJWT @ file:///opt/concourse/worker/volumes/live/bd094316-1935-4bf0-5028-b889d4e7967c/volume/pyjwt_1619682501859/work
pymongo==3.12.0
PyNaCl @ file:///opt/concourse/worker/volumes/live/84fbe300-25e9-45d9-79c1-dc409645d406/volume/pynacl_1607611470184/work
pyodbc @ file:///opt/concourse/worker/volumes/live/455bdcd5-79c1-4298-5eb4-de3023e99769/volume/pyodbc_1647425904610/work
pyOpenSSL @ file:///tmp/build/80754af9/pyopenssl_1608057966937/work
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
PySocks @ file:///opt/concourse/worker/volumes/live/112288ac-9cb0-4e73-768b-13baf4ca6419/volume/pysocks_1605305820043/work
pytest==7.1.1
pytest-cov @ file:///tmp/build/80754af9/pytest-cov_1637159997573/work
python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work
python-snappy @ file:///opt/concourse/worker/volumes/live/8c331f10-f7c9-4f6b-5744-375e3450cc0a/volume/python-snappy_1610133354807/work
pytz==2021.3
PyYAML==6.0
requests @ file:///opt/conda/conda-bld/requests_1641824580448/work
requests-file @ file:///Users/ktietz/demo/mc3/conda-bld/requests-file_1629455781986/work
requests-oauthlib==1.3.0
requests-toolbelt @ file:///Users/ktietz/demo/mc3/conda-bld/requests-toolbelt_1629456163440/work
s3transfer @ file:///tmp/build/80754af9/s3transfer_1626435152308/work
selenium @ file:///opt/concourse/worker/volumes/live/9dcbb584-e669-4c23-547e-fda41ecd267d/volume/selenium_1614267791101/work
simple-salesforce @ file:///tmp/build/80754af9/simple-salesforce_1623836350210/work
six @ file:///tmp/build/80754af9/six_1644875935023/work
snowflake-connector-python @ file:///opt/concourse/worker/volumes/live/42dbe200-011c-4931-6b3e-20ff582ea892/volume/snowflake-connector-python_1633362850446/work
snowflake-sqlalchemy @ file:///home/conda/feedstock_root/build_artifacts/snowflake-sqlalchemy_1639732109357/work
sortedcontainers @ file:///tmp/build/80754af9/sortedcontainers_1623949099177/work
SQLAlchemy @ file:///opt/concourse/worker/volumes/live/bfe20d71-b806-4187-4783-cd5d96eb1af2/volume/sqlalchemy_1647599831148/work
tblib @ file:///Users/ktietz/demo/mc3/conda-bld/tblib_1629402031467/work
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tomli @ file:///tmp/build/80754af9/tomli_1637314251069/work
toolz @ file:///tmp/build/80754af9/toolz_1636545406491/work
tornado @ file:///opt/concourse/worker/volumes/live/2c1a63a2-006b-48ee-56b9-0cfe8b4927f9/volume/tornado_1606942321278/work
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
urllib3 @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_92f3a881-8cf4-469b-8319-736ffa3c6d61ordl4zjw/croots/recipe/urllib3_1650639998913/work
xarray @ file:///opt/conda/conda-bld/xarray_1639166117697/work
xlwt==1.3.0
xmltodict @ file:///Users/ktietz/demo/mc3/conda-bld/xmltodict_1629301980723/work
yarl @ file:///opt/concourse/worker/volumes/live/8e0192c5-7b7d-47fe-5cfd-fadef81d5ebb/volume/yarl_1606940005549/work
zeep @ file:///home/conda/feedstock_root/build_artifacts/zeep_1630310978540/work
zict==2.0.0
  1. What did you do?
    from snowflake.sqlalchemy import URL
    import sqlalchemy

    url = URL(
        account=config.get('ACCOUNT'),
        user=config.get('USER'),
        password=config.get('PASS'),
        database=config.get('DATABASE'),
        warehouse=config.get('WAREHOUSE'),
        role=config.get('ROLE'),
    )

    engine = sqlalchemy.create_engine(
        url=url,
        future=True
    )

    engine.connect()
  1. What did you expect to see?

    Create snowflake database connection

  2. Can you set logging to DEBUG and collect the logs?

Traceback (most recent call last):
  File "/Users/jshaw/TAB-DATA/pyetl/pyetl/task.py", line 125, in _run_dependent_calculations
    task_module.task(context)
  File "/Users/jshaw/TAB-DATA/pyetl/pyetl/task.py", line 95, in wrapper
    return func(context=_context)
  File "/Users/jshaw/TAB-DATA/pyetl/tasks/test_task.py", line 36, in task
    with conn['dw'].transaction(echo=True) as conn:
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/Users/jshaw/TAB-DATA/pyetl/pyetl/connection/db.py", line 205, in transaction
    connection = self.connection(**kwargs)
  File "/Users/jshaw/TAB-DATA/pyetl/pyetl/connection/db.py", line 185, in connection
    connection = client_connections.get(self.connector)(**kwargs)
  File "/Users/jshaw/TAB-DATA/pyetl/pyetl/connection/db.py", line 146, in _sqlalchemy_connection
    return self._engine.connect()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/future/engine.py", line 406, in connect
    return super(Engine, self).connect()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3210, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3289, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 3256, in _wrap_pool_connect
    return fn()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 146, in _do_get
    self._dec_overflow()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
    compat.raise_(
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/impl.py", line 143, in _do_get
    return self._create_connection()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/pool/base.py", line 677, in __connect
    pool.dispatch.connect.for_modify(
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/event/attr.py", line 329, in _exec_w_sync_on_first_run
    self(*args, **kw)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/event/attr.py", line 343, in __call__
    fn(*args, **kw)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 1691, in go
    return once_fn(*arg, **kw)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 686, in first_connect
    dialect.initialize(c)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 413, in initialize
    self.default_schema_name = self._get_default_schema_name(
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/snowflake/sqlalchemy/snowdialect.py", line 256, in _get_default_schema_name
    _, current_schema = self._current_database_schema(connection)
  File "<string>", line 2, in _current_database_schema
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/reflection.py", line 47, in cache
    return fn(self, con, *args, **kw)
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/snowflake/sqlalchemy/snowdialect.py", line 250, in _current_database_schema
    return (
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 219, in __exit__
    self.close()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/future/engine.py", line 246, in close
    super(Connection, self).close()
  File "/Users/jshaw/miniconda3/envs/pyetl/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1136, in close
    assert not self._is_future
AssertionError

jordantshaw avatar May 17 '22 19:05 jordantshaw