Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions databend_sqlalchemy/databend_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
from .types import DOUBLE

from sqlalchemy.engine import ExecutionContext, default
from sqlalchemy.exc import DBAPIError, NoSuchTableError
from sqlalchemy.exc import DBAPIError, NoSuchTableError, CompileError

from .dml import (
Merge,
Expand Down Expand Up @@ -1316,10 +1316,14 @@ def create_table_constraints(
def visit_create_index(
self, create, include_schema=False, include_table_schema=True, **kw
):
return ""
raise CompileError(
"Databend does not support standard secondary indexes; consider CLUSTER BY or INVERTED INDEX."
)

def visit_drop_index(self, drop, **kw):
return ""
raise CompileError(
"Databend does not support standard secondary indexes."
)

def visit_drop_schema(self, drop, **kw):
# Override - Databend does not support the CASCADE option
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_databend_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,21 @@ def test_datetime_result_processor_timezone_handling():
process_tz = DatabendDateTime(timezone=True).result_processor(None, None)
assert process_tz(aware_utc) == aware_utc
assert process_tz(aware_utc).tzinfo is not None


def test_create_and_drop_index_raises_compile_error():
import pytest
from sqlalchemy import MetaData, Table, Column, Integer, Index
from sqlalchemy.schema import CreateIndex, DropIndex
from sqlalchemy.exc import CompileError

d = databend_sqlalchemy.databend_dialect.DatabendDialect()
m = MetaData()
t = Table("t", m, Column("id", Integer), Column("x", Integer))
ix = Index("ix_t_x", t.c.x)

with pytest.raises(CompileError, match="does not support"):
CreateIndex(ix).compile(dialect=d)

with pytest.raises(CompileError, match="does not support"):
DropIndex(ix).compile(dialect=d)
Loading