[MDEV-12440] CTE not found in a complex SQL code Created: 2017-04-04 Updated: 2017-10-31 Resolved: 2017-04-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - CTE |
| Affects Version/s: | 10.2.4 |
| Fix Version/s: | 10.2.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | CARME Antoine | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
debian sid package on x64 |
||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Dear all, I am currently working on a tool to translate machine learning models (built with scikit-learn python library) into a SQL code that can produce the model predictions when executed. The tool works by translating the model into a "sequence" of CTEs. It supports the main relational databases available on the market (sqlite, postgresql, MSSql, Oracle). Some demo is available here (https://github.com/antoinecarme/sklearn2sql-demo/) with sample SQL codes. MySQL used to not support CTEs. I see that MariaDB is adding support for CTEs and I will be glad to use it and help with examples. This is very good news!!! I am giving it a try. I use the debian sid (x64) 10.2.4 version and already read some the bug reports filed recently about CTEs. I use a set of automatic tests that run on all supported databases. I will only report when MariaDB is the only failing case. So far, a lot of the tested models generate SQL that executes OK on MariaDB which is great!! However, I still have some issues with some complex models (>10 CTEs), I can provide a list. For example, the AdaBoostClassifier models produce some SQL code that works on postgresql/oracle/MSSQL/SQlite but not on MariaDB. I get a message "Table \'db.AdaBoost_AVG_Scores\' doesn\'t exist" AdaBoost_AVG_Scores is a CTE defined in the query. It seems to be a lookup issue for CTEs. the SQL code is available here : the SQL code is based on a table INPUT_DATA that can be defined this way : create table `INPUT_DATA` AS Your help is welcome. Sorry for the long message. I tried to give a full bug report with the most details. Thanks in advance Antoine |
| Comments |
| Comment by Igor Babaev [ 2017-04-06 ] | ||||||||||||||||||||||
|
The following simple test case demonstrates this problem:
As in the reported query the same CTE in used twice in another CTE and the server returns:
Here's another query where the same CTE is used twice: In the main query and in a CTE.
| ||||||||||||||||||||||
| Comment by Igor Babaev [ 2017-04-07 ] | ||||||||||||||||||||||
|
The fix for this bug was pushed into the 10.2 tree. | ||||||||||||||||||||||
| Comment by Igor Babaev [ 2017-04-07 ] | ||||||||||||||||||||||
|
Hi Antoine, I executed your query after having applied my fix. It returned some result set, but I could not verify the result, because I did know what to expect. | ||||||||||||||||||||||
| Comment by CARME Antoine [ 2017-04-07 ] | ||||||||||||||||||||||
|
YEEEES! That's excellent. Thanks a lot Igor Babaev. Can't wait or testing the 10.2.6 release !!!! | ||||||||||||||||||||||
| Comment by CARME Antoine [ 2017-04-07 ] | ||||||||||||||||||||||
|
Igor, I can do some tests and give you my feedback (in particular, I compare all supported databases result sets, should be the same). | ||||||||||||||||||||||
| Comment by CARME Antoine [ 2017-06-04 ] | ||||||||||||||||||||||
|
Igor, ?? instead of this ?? Good job, guys. You made a happy MariaDB user. Cheers |