Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 53
FIX: Request SQL_CHAR as SQL_C_WCHAR in arrow fetch path#575
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
Subrata (subrata-ms)
merged 12 commits into
microsoft:main
from
ffelixg:arrow_char_to_wcharJun 23, 2026
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
29a9cec
Arrow fetch: request SQL_CHAR as SQL_C_WCHAR
ffelixg 4ce73ca
Make utf8 collation test optional; Add mandatory cp1252 test to make …
ffelixg c4ce528
Merge remote-tracking branch 'origin/main' into arrow_char_to_wchar
ffelixg c574aca
Merge branch 'main' into arrow_char_to_wchar
subrata-ms 9a3992e
Merge branch 'main' into arrow_char_to_wchar
gargsaumya 2d5fc16
Comments, test char+text ontop of varchar, test name fix
ffelixg b4d8627
Merge remote-tracking branch 'origin/main' into arrow_char_to_wchar
ffelixg 0afa584
Merge branch 'main' into arrow_char_to_wchar
subrata-ms 8a83c34
Merge remote-tracking branch 'origin/main' into arrow_char_to_wchar_c…
ffelixg a6678bd
Allow fetching narrow utf-8 if configured
ffelixg f94dbcf
Merge branch 'main' into arrow_char_to_wchar
subrata-ms 5548c96
Merge branch 'main' into arrow_char_to_wchar
gargsaumya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -313,6 +313,83 @@ def test_arrow_long_string(cursor: mssql_python.Cursor): | ||
| assert batch.column(0).to_pylist() == [long_string] | ||
| @pytest.mark.parametrize("sql_type", ["char(32)", "varchar(32)"]) | ||
| @pytest.mark.parametrize("narrow", [True, False]) | ||
| def test_arrow_char_utf8_collation_unicode( | ||
| cursor: mssql_python.Cursor, sql_type: str, narrow: bool | ||
| ): | ||
| table = "#t_arrow_char_decode" | ||
| collation = "Latin1_General_100_CI_AS_SC_UTF8" | ||
| expected = [ | ||
| "Grüße", | ||
| "你好😀", | ||
| "こんにちは", | ||
| "Привет", | ||
| "Hello 世界", | ||
| "😀😃😄😁", | ||
| "", | ||
| None, | ||
| ] | ||
| if narrow: | ||
| cursor.connection.setdecoding(mssql_python.SQL_CHAR, ctype=mssql_python.SQL_CHAR) | ||
| try: | ||
| cursor.execute( | ||
| f"create table {table} (id int primary key, v {sql_type} collate {collation})" | ||
| ) | ||
| except Exception as exc: | ||
| pytest.skip(f"UTF-8 collation '{collation}' not supported: {exc}") | ||
| try: | ||
| for index, value in enumerate(expected, start=1): | ||
| cursor.execute(f"insert into {table} (id, v) values (?, ?)", index, value) | ||
| tbl = cursor.execute(f"select v from {table} order by id").arrow() | ||
| assert tbl.column(0).type.equals(pa.large_string()) | ||
| for expected_val, actual_val in zip(expected, tbl.column(0).to_pylist(), strict=True): | ||
| if actual_val is not None: | ||
| actual_val = actual_val.strip() | ||
| assert expected_val == actual_val | ||
| finally: | ||
| cursor.connection.setdecoding(mssql_python.SQL_CHAR) | ||
| cursor.execute(f"drop table if exists {table}") | ||
| @pytest.mark.parametrize("sql_type", ["char(32)", "varchar(32)", "text"]) | ||
| @pytest.mark.parametrize("narrow", [True, False]) | ||
| def test_arrow_char_cp1252_collation_unicode( | ||
| cursor: mssql_python.Cursor, sql_type: str, narrow: bool | ||
| ): | ||
| table = "#t_arrow_char_decode" | ||
| collation = "SQL_Latin1_General_CP1_CI_AS" | ||
| expected = [ | ||
| "Grüße", | ||
| "café René!", | ||
| "naïve café", | ||
| "Español", | ||
| "Müller-Öztürk", | ||
| "Françoise", | ||
| "", | ||
| None, | ||
| ] | ||
| if narrow: | ||
| cursor.connection.setdecoding(mssql_python.SQL_CHAR, ctype=mssql_python.SQL_CHAR) | ||
| cursor.execute(f"create table {table} (id int primary key, v {sql_type} collate {collation})") | ||
| try: | ||
| for index, value in enumerate(expected, start=1): | ||
| cursor.execute(f"insert into {table} (id, v) values (?, ?)", index, value) | ||
| tbl = cursor.execute(f"select v from {table} order by id").arrow() | ||
| assert tbl.column(0).type.equals(pa.large_string()) | ||
| for expected_val, actual_val in zip(expected, tbl.column(0).to_pylist(), strict=True): | ||
| if actual_val is not None: | ||
| actual_val = actual_val.strip() | ||
| assert expected_val == actual_val | ||
| finally: | ||
| cursor.connection.setdecoding(mssql_python.SQL_CHAR) | ||
| cursor.execute(f"drop table if exists {table}") | ||
ffelixg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def test_rownumber_arrow_batch_interleaved_fetchmany(cursor: mssql_python.Cursor): | ||
| """Verify that arrow_batch and fetchmany can be interleaved | ||
| on the same result set with correct rownumber tracking and values.""" | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.