Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: sqlite connection bindings not back compatible/ defective #10811

Closed
1 task done
blythed opened this issue Feb 8, 2025 · 3 comments · Fixed by #10812
Closed
1 task done

bug: sqlite connection bindings not back compatible/ defective #10811

blythed opened this issue Feb 8, 2025 · 3 comments · Fixed by #10812
Labels
bug Incorrect behavior inside of ibis

Comments

@blythed
Copy link

blythed commented Feb 8, 2025

What happened?

Version: 10.0.0

import ibis
ibis.connect('sqlite://')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[7], line 1
----> 1 con = ibis.connect("sqlite://tmp_db")

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/__init__.py:1502, in connect(resource, **kwargs)
   1500     backend = getattr(ibis, scheme)
   1501 except AttributeError:
-> 1502     raise ValueError(f"Don't know how to connect to {resource!r}") from None
   1504 return backend._from_url(parsed, **kwargs)

ValueError: Don't know how to connect to 'sqlite://'
import ibis
ibis.sqlite.connect()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[9], line 1
----> 1 ibis.sqlite.connect()

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/__init__.py:142, in __getattr__(name)
    140     return null()  # noqa: F405
    141 else:
--> 142     return load_backend(name)

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/__init__.py:82, in load_backend(name)
     80 (entry_point,) = entry_points
     81 try:
---> 82     module = entry_point.load()
     83 except ImportError as exc:
     84     raise ImportError(
     85         f"Failed to import the {name} backend due to missing dependencies.\n\n"
     86         f"You can pip or conda install the {name} backend as follows:\n\n"
     87         f'  python -m pip install -U "ibis-framework[{name}]"  # pip install\n'
     88         f"  conda install -c conda-forge ibis-{name}           # or conda install"
     89     ) from exc

File ~/.pyenv/versions/3.10.13/lib/python3.10/importlib/metadata/__init__.py:171, in EntryPoint.load(self)
    166 """Load the entry point from its definition. If only a module
    167 is indicated by the value, return that module. Otherwise,
    168 return the named object.
    169 """
    170 match = self.pattern.match(self.value)
--> 171 module = import_module(match.group('module'))
    172 attrs = filter(None, (match.group('attr') or '').split('.'))
    173 return functools.reduce(getattr, attrs, module)

File ~/.pyenv/versions/3.10.13/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1050, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1027, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1006, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:688, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:883, in exec_module(self, module)

File <frozen importlib._bootstrap>:241, in _call_with_frames_removed(f, *args, **kwds)

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sqlite/__init__.py:12
      9 import sqlglot.expressions as sge
     11 import ibis
---> 12 import ibis.backends.sql.compilers as sc
     13 import ibis.common.exceptions as com
     14 import ibis.expr.datatypes as dt

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sql/compilers/__init__.py:25
      1 from __future__ import annotations
      3 __all__ = [
      4     "AthenaCompiler",
      5     "BigQueryCompiler",
   (...)
     22     "TrinoCompiler",
     23 ]
---> 25 from ibis.backends.sql.compilers.athena import AthenaCompiler
     26 from ibis.backends.sql.compilers.bigquery import BigQueryCompiler
     27 from ibis.backends.sql.compilers.clickhouse import ClickHouseCompiler

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sql/compilers/athena.py:8
      5 from sqlglot.dialects import Athena
      7 import ibis.expr.operations as ops
----> 8 from ibis.backends.sql.compilers.trino import TrinoCompiler
      9 from ibis.backends.sql.datatypes import AthenaType
     11 _NAME_REGEX = re.compile(r'[^!"$()*,./;?@[\\\]^`{}~\n]+')

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sql/compilers/trino.py:23
     14 from ibis.backends.sql.compilers.base import (
     15     FALSE,
     16     NULL,
   (...)
     20     SQLGlotCompiler,
     21 )
     22 from ibis.backends.sql.datatypes import TrinoType
---> 23 from ibis.backends.sql.dialects import Trino
     24 from ibis.backends.sql.rewrites import (
     25     FirstValue,
     26     LastValue,
   (...)
     31     split_select_distinct_with_order_by,
     32 )
     33 from ibis.util import gen_name

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sql/dialects.py:27
     23 from sqlglot.dialects.dialect import rename_func
     24 from sqlglot.helper import find_new_name, seq_get
---> 27 class ClickHouse(_ClickHouse):
     28     class Generator(_ClickHouse.Generator):
     29         _ClickHouse.Generator.TRANSFORMS |= {
     30             sge.ArraySize: rename_func("length"),
     31             sge.ArraySort: rename_func("arraySort"),
   (...)
     34             sge.Median: rename_func("median"),
     35         }

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sql/dialects.py:28, in ClickHouse()
     27 class ClickHouse(_ClickHouse):
---> 28     class Generator(_ClickHouse.Generator):
     29         _ClickHouse.Generator.TRANSFORMS |= {
     30             sge.ArraySize: rename_func("length"),
     31             sge.ArraySort: rename_func("arraySort"),
   (...)
     34             sge.Median: rename_func("median"),
     35         }
     37         def except_op(self, expression: sge.Except) -> str:

File ~/.pyenv/versions/3.10.13/envs/superduper-3.10/lib/python3.10/site-packages/ibis/backends/sql/dialects.py:34, in ClickHouse.Generator()
     28 class Generator(_ClickHouse.Generator):
     29     _ClickHouse.Generator.TRANSFORMS |= {
     30         sge.ArraySize: rename_func("length"),
     31         sge.ArraySort: rename_func("arraySort"),
     32         sge.LogicalAnd: rename_func("min"),
     33         sge.LogicalOr: rename_func("max"),
---> 34         sge.Median: rename_func("median"),
     35     }
     37     def except_op(self, expression: sge.Except) -> str:
     38         return f"EXCEPT{' DISTINCT' if expression.args.get('distinct') else ' ALL'}"

AttributeError: module 'sqlglot.expressions' has no attribute 'Median'

What version of ibis are you using?

10.0.0

What backend(s) are you using, if any?

SQLite

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct
@blythed blythed added the bug Incorrect behavior inside of ibis label Feb 8, 2025
@blythed
Copy link
Author

blythed commented Feb 8, 2025

Followed this guide: https://ibis-project.org/backends/sqlite

@cpcloud
Copy link
Member

cpcloud commented Feb 8, 2025

I think you need to upgrade your version of sqlglot for now. I will look into either bumping the lower bound of sqlglot, or making our use of sge.Median backward compatible.

@cpcloud
Copy link
Member

cpcloud commented Feb 8, 2025

@blythed There should be a pre-release out tomorrow if you'd like to give that a try.

I will likely cut a 10.x release late next week as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants