connector-x
                                
                                 connector-x copied to clipboard
                                
                                    connector-x copied to clipboard
                            
                            
                            
                        Support for duplicate columns in MS SQL
Hi again,
Would it be possible to allow downloading tables with multiple columns with the same name? pd.read_sql can do this
I get: RuntimeError: Token error: 'The column 'x' was specified multiple times for 'CXTMPTAB_COUNT'.' on server y executing on line 1 (code: 8156, state: 1, class: 16)
Hi @bloukanov, it seems like you want two columns with the same name which I'm not sure why there is a need for this. Can you specify your use case? Also, can workarounds like using alias to rename the column solve the problem?
Hi @wangxiaoying,
My use case is I have a SQL join upstream (before the download to Python), and I do not want to specify column names in it, so it is:
select a.*, b.* 
from a left join b on a.x = b.x and a.y = b.y
This way I will not have to touch this join even after adding or removing columns upstream, from tables a or b. But this causes x and y to be duplicated in the resulting dataset. For now I can work around, but I suppose this would be an issue with any "select all" join?
@bloukanov I see. It might be a little bit tricky to support this in our case. Unlike pandas which directly issue the query, we need to count the query result and partition the query in advance. And in order to make sure the generated queries are valid in all cases, nested query is the safest choice, and this error is caused by the duplicated name in the subquery. We will take a look at whether there is other workarounds that we can do in our side, but it won't be in very high priority since right now it can work with specifying a different name in the SQL query. Thanks for the report anyway.
@wangxiaoying got it, makes sense! thanks