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
6 changes: 4 additions & 2 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 @@ -1273,7 +1273,9 @@ def visit_JSON(self, type_, **kw):
return "JSON" # or VARIANT

def visit_TIME(self, type_, **kw):
return "DATETIME"
raise CompileError(
"Databend does not support the TIME data type; consider using TIMESTAMP or VARCHAR."
)

def visit_INTERVAL(self, type, **kw):
return "INTERVAL"
Expand Down
4 changes: 2 additions & 2 deletions databend_sqlalchemy/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ def time(self):
"""target dialect supports representation of Python
datetime.time() objects."""

return exclusions.open()
return exclusions.closed()

@property
def time_microseconds(self):
"""target dialect supports representation of Python
datetime.time() with microsecond objects."""

return exclusions.open()
return exclusions.closed()

@property
def time_timezone(self):
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_databend_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,17 @@ 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_visit_time_raises_compile_error():
import pytest
from sqlalchemy import Column, MetaData, Table, Time
from sqlalchemy.exc import CompileError
from sqlalchemy.schema import CreateTable

dialect = databend_sqlalchemy.databend_dialect.DatabendDialect()
metadata = MetaData()
table = Table("probe", metadata, Column("clock", Time()))

with pytest.raises(CompileError, match="does not support the TIME data type"):
CreateTable(table).compile(dialect=dialect)
Loading