-
Notifications
You must be signed in to change notification settings - Fork 5
Fix: CLOB, NCHAR, NVARCHAR, DATETIME and DATE compile to DDL CrateDB cannot parse #305
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
Merged
bgunebakan
merged 9 commits into
main
from
bilal/304-types-clob-nchar-nvarchar-datetime-and-date-compile-to-ddl-cratedb-cannot-parse
Sep 23, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
690b60c
Types: Fix CLOB, NCHAR, NVARCHAR, DATETIME, and DATE mappings to Crat…
bgunebakan 284d6cc
Add type coverage tests for CrateDB compatible SQLAlchemy types
bgunebakan cbc3e9b
Add tests for core SQLAlchemy types compatibility with CrateDB
bgunebakan 88dc0d5
Remove redundant datetime and date mappings
bgunebakan ac0a283
Update DATE handling and add tests for DATE casting behavior
bgunebakan 86e9842
Merge branch 'main' into bilal/304-types-clob-nchar-nvarchar-datetime…
bgunebakan 2f355ae
Merge branch 'main' into bilal/304-types-clob-nchar-nvarchar-datetime…
bgunebakan 7a2bc79
Refactor type factories to specify precision for Numeric and Decimal …
bgunebakan 4ae1d03
Update changelog
bgunebakan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # -*- coding: utf-8; -*- | ||
| # | ||
| # Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
| # license agreements. See the NOTICE file distributed with this work for | ||
| # additional information regarding copyright ownership. Crate licenses | ||
| # this file to you under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. You may | ||
| # obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
| # | ||
| # However, if you have executed another commercial license agreement | ||
| # with Crate these terms will supersede the license and you may use the | ||
| # software solely pursuant to the terms of the relevant commercial agreement. | ||
|
|
||
| import pytest | ||
| import sqlalchemy as sa | ||
|
|
||
| CORE_TYPE_FACTORIES = { | ||
| "BigInteger": lambda: sa.BigInteger, | ||
| "Boolean": lambda: sa.Boolean, | ||
| "Date": lambda: sa.Date, | ||
| "DateTime": lambda: sa.DateTime, | ||
| "Double": lambda: sa.Double, | ||
| "Enum": lambda: sa.Enum("a", "b", name="enum_a_b"), | ||
| "Float": lambda: sa.Float, | ||
| "Integer": lambda: sa.Integer, | ||
| "Interval": lambda: sa.Interval, | ||
| "JSON": lambda: sa.JSON, | ||
| "LargeBinary": lambda: sa.LargeBinary, | ||
| "Numeric": lambda: sa.Numeric(10, 2), | ||
| "PickleType": lambda: sa.PickleType, | ||
| "SmallInteger": lambda: sa.SmallInteger, | ||
| "String": lambda: sa.String(50), | ||
| "Text": lambda: sa.Text, | ||
| "Time": lambda: sa.Time, | ||
| "Unicode": lambda: sa.Unicode(50), | ||
| "UnicodeText": lambda: sa.UnicodeText, | ||
| "Uuid": lambda: sa.Uuid, | ||
| "ARRAY": lambda: sa.ARRAY(sa.Integer), | ||
| "BIGINT": lambda: sa.BIGINT, | ||
| "BINARY": lambda: sa.BINARY, | ||
| "BLOB": lambda: sa.BLOB, | ||
| "BOOLEAN": lambda: sa.BOOLEAN, | ||
| "CHAR": lambda: sa.CHAR(5), | ||
| "CLOB": lambda: sa.CLOB, | ||
| "DATE": lambda: sa.DATE, | ||
|
bgunebakan marked this conversation as resolved.
|
||
| "DATETIME": lambda: sa.DATETIME, | ||
| "DECIMAL": lambda: sa.DECIMAL(10, 2), | ||
| "DOUBLE": lambda: sa.DOUBLE, | ||
| "DOUBLE_PRECISION": lambda: sa.DOUBLE_PRECISION, | ||
| "FLOAT": lambda: sa.FLOAT, | ||
| "INTEGER": lambda: sa.INTEGER, | ||
| "NCHAR": lambda: sa.NCHAR(5), | ||
| "NUMERIC": lambda: sa.NUMERIC(10, 2), | ||
| "NVARCHAR": lambda: sa.NVARCHAR(50), | ||
| "REAL": lambda: sa.REAL, | ||
| "SMALLINT": lambda: sa.SMALLINT, | ||
| "TEXT": lambda: sa.TEXT, | ||
| "TIME": lambda: sa.TIME, | ||
| "TIMESTAMP": lambda: sa.TIMESTAMP, | ||
| "UUID": lambda: sa.UUID, | ||
|
bgunebakan marked this conversation as resolved.
|
||
| "VARBINARY": lambda: sa.VARBINARY(50), | ||
| "VARCHAR": lambda: sa.VARCHAR(50), | ||
| } | ||
|
|
||
| CORE_TYPES = {name: factory() for name, factory in CORE_TYPE_FACTORIES.items() if hasattr(sa, name)} | ||
|
|
||
|
|
||
| KNOWN_UNSUPPORTED = { | ||
| "BINARY": "CrateDB has no binary data type", | ||
| "BLOB": "CrateDB has no binary data type", | ||
| "LargeBinary": "CrateDB has no binary data type", | ||
| "PickleType": "Builds on `sa.LargeBinary`", | ||
| "VARBINARY": "CrateDB has no binary data type", | ||
| } | ||
|
|
||
|
|
||
| def _cases(): | ||
| for name in sorted(CORE_TYPES): | ||
| marks = [] | ||
| if name in KNOWN_UNSUPPORTED: | ||
| marks.append(pytest.mark.xfail(strict=True, reason=KNOWN_UNSUPPORTED[name])) | ||
| yield pytest.param(name, marks=marks) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("name", list(_cases())) | ||
| def test_core_type_is_creatable(cratedb_service, name): | ||
| """CrateDB accepts the DDL the dialect generates for this type.""" | ||
| engine = cratedb_service.database.engine | ||
| table = sa.Table( | ||
| "type_compilation", | ||
| sa.MetaData(), | ||
| sa.Column("id", sa.Integer, primary_key=True), | ||
| sa.Column("d", CORE_TYPES[name]), | ||
| ) | ||
| table.drop(engine, checkfirst=True) | ||
| table.create(engine) | ||
| table.drop(engine) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.