Skip to content

GLOB operator is not supported for duckdb and sqlite #1066

@cldellow

Description

@cldellow

Hi, sqlglot is amazing! Thank you for this library.

I noticed that this fails:

import sqlglot

print(sqlglot.transpile("SELECT 'foo' GLOB '?'", read="duckdb", write="sqlite")[0])

I expected it to print SELECT 'foo' GLOB '?', but it gave an exception:

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    print(sqlglot.transpile("SELECT 'foo' GLOB '?'", read="duckdb", write="sqlite")[0])
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/sqlglot/__init__.py", line 124, in transpile
    for expression in parse(sql, read, error_level=error_level)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/sqlglot/__init__.py", line 60, in parse
    return dialect.parse(sql, **opts)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/sqlglot/dialects/dialect.py", line 151, in parse
    return self.parser(**opts).parse(self.tokenizer.tokenize(sql), sql)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/sqlglot/parser.py", line 684, in parse
    return self._parse(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/sqlglot/parser.py", line 749, in _parse
    self.raise_error("Invalid expression / Unexpected token")
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/sqlglot/parser.py", line 792, in raise_error
    raise error
sqlglot.errors.ParseError: Invalid expression / Unexpected token. Line 1, Col: 21.
  SELECT 'foo' GLOB '?'

Searching the code base, I think this operator isn't supported for any dialect yet. I'm not sure which flavours of SQL support it - duckdb (docs) and sqlite (docs) do.

I imagine this might be an easy fix, but I don't know where to start

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions