Skip to content

fix(datatype): convert from sqlglot VARCHAR(MAX) correctly #11202

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NickCrews
Copy link
Contributor

@NickCrews NickCrews commented May 9, 2025

Fixes #11191

I'd like to add a test for this. I think checking for roundtripping ibis.string -> sqglot.DataType -> ibis.string across all backends sounds like the best approach.

@github-actions github-actions bot added the sql Backends that generate SQL label May 9, 2025
@NickCrews
Copy link
Contributor Author

Ah, it looks like there is already test_roundtripable_types() in ibis/backends/sql/tests/test_datatypes.py, but it only uses the superclass SqlGlotType type mapper, not the backend-specific type mappers. Adjusting this now.

@NickCrews NickCrews force-pushed the fix-convert-string-max branch from 4c8283b to 32c1adc Compare May 12, 2025 16:31
@NickCrews
Copy link
Contributor Author

eh, the roundtrip test doesn't actually catch the bug, since ibis.String goes to VARCHAR(max), but the bug only appears when using NVARCHAR(max). So at this point I didn't actually add a test, it didn't seem worth it. Maybe could add test only to the mssql backend tests?

Another implementation we could do here is to hoist the MSSQL implementation, with the safety check for "MAX" length, up to the superclass SqlglotType. Then there will less code, but the needs of the different backends will get mixed with each other. This implementation is more explicit and granular and extensible.

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql Backends that generate SQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: NVARCHAR(MAX) column fails on mssql connector
2 participants