-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add support for Microsoft SQL #29
base: main
Are you sure you want to change the base?
Conversation
Can UTF-8 support be opted-in? This post seems to indicate it should be available https://techcommunity.microsoft.com/t5/sql-server-blog/introducing-utf-8-support-for-sql-server/ba-p/734928 |
That's the thing. I did try that by setting |
The code changes look reasonable. In terms of flakiness, perhaps we need to do a |
@lihaoyi Question about the sorting tests with nulls under SELECT opt_cols0.my_int AS my_int, opt_cols0.my_int2 AS my_int2
FROM opt_cols opt_cols0
ORDER BY my_int NULLS LAST the defined accepted result is value = Seq(
OptCols[Sc](Some(1), Some(2)),
OptCols[Sc](Some(3), None),
OptCols[Sc](None, None),
OptCols[Sc](None, Some(4))
) but shouldn't value = Seq(
OptCols[Sc](Some(1), Some(2)),
OptCols[Sc](Some(3), None),
OptCols[Sc](None, Some(4)),
OptCols[Sc](None, None)
) also be acceptable since we only order by |
@kiendang yes that should be acceptable. IIRC the test suite allows a |
Use `SELECT TOP(?) ...` for MS SQL when there's no offset.
Adapted The UTF-8 workaround fixed around 40 tests. There are still around 93 failed tests out of 310. A large number of those are due to MS SQL does not have a boolean type. You can only use boolean expression in the This is legal SELECT * FROM buyer WHERE name IS NOT NULL; These are not CREATE TABLE tb (
x BOOLEAN
);
SELECT name IS NOT NULL FROM buyer;
SELECT * FROM buyer ORDER BY name IS NOT NULL; Instead have to do CREATE TABLE tb (
x BIT
);
SELECT IIF(name IS NOT NULL, 1, 0) FROM buyer;
SELECT * FROM buyer ORDER BY IIF(name IS NOT NULL, 1, 0); |
Sounds good. Generating |
The built-in LogMessageWaitStrategy doesn't work.
It's a bit more involved than just overriding |
Having custom serialization in the SELECT clause only is doable, as we control the entire query serialization pipeline, but how invasive it would be depends on exactly what semantics you need to introduce. Is |
Boolean expressions can only be used as conditions, not values. These are legal WHERE x > 3
CASE WHEN x > 3 These are not SELECT x > 3
ORDER BY x > 3
GROUP BY x > 3
-- this is also illegal because `x > 3` is used as value here
WHERE (x > 3) = (x > 3) Another issue is boolean literals don't exists either, so these currently fail |
And how anout as parameters to functions? Like booleans are allowed as parameters to iif, but how about other sql functions? Maybe one thing to do here is to look into how Slick and Quill handle this. IIRC both of those libraries support mssql server, and their handling may give us some idea of the best way to proceed for scalasql |
Can't find anything related to MSSQL functions taking boolean inputs but my guess is that Quill does render boolean values as https://scastie.scala-lang.org/kiendang/XHfKDq7jRmS0NwFEAC18pQ/25 |
Would following Quill's strategy work? Presumably if it works for Quill well enough for people to depend on it it should work for Scalasql as well |
Seems like SLICK treats all booleans as bits as well https://github.com/slick/slick/blob/c4b081da7996ad74ccc707d139b07c11c2eb6bba/slick/src/main/scala/slick/jdbc/SQLServerProfile.scala#L316 I guess thats what we need to do in ScalaSql. If the library doesnt already provide appropriate hooks to override, we'll have to add them |
Closing due to inactivity. The bounty remains open for anyone reading |
MSSQL does not support EXCLUDE in window functions
@lihaoyi sorry for the lack of updates. This issue does turn out to require more work than I thought due to the many Microsoft SQL quirks. Beside the issue with Boolean, a lot of remaining failed tests would require more non-trivial solutions than the ones I've already covers. I haven't abandoned the PR but do work on it at a slower pace. If it's ok for you to reopen the PR, I'd work on the remaining issues gradually. Of course I understand at the same time the bounty's still open to everyone else. Anyone who's interested feels free to continue from branch which provides a good starting point. |
@kiendang got it |
happy to leave it open if you're still working on it. |
@kiendang I'm happy to pay out the original bounty (500USD) for the work you've already done so far, just so you don't feel the work has been wasted in case someone else picks it up and completes it. Email me your international bank transfer details and I'll perform the wire |
@lihaoyi Thank you! I've been compiling a list of remaining issues. Will clean it up and post here. Would require your perspective for some of them. Plus it'd help others who are interested in continue the work. I'm also happy to receive the original bounty amount. Will email you later but this could take me a couple weeks coz I've just gone through some life changes. I've also just seen the post on Reddit. I don't want to block anyone from continue the work and I wouldn't claim the rest of the bounty if someone does. Would it be a good idea if you update the original issue to point to this PR as a starting point? |
@kiendang take your time, no hurry at all. Yes I'll update the ticket to explicitly point at this WIP for others to build upon |
Close #17.
Not complete yet. Most test failures are due to MS SQL does not use UTF-8 for strings. Need to figure that out.