ydb-platform / ydb

YDB is an open source Distributed SQL Database that combines high availability and scalability with strong consistency and ACID transactions
https://ydb.tech
Apache License 2.0
3.96k stars 543 forks source link

Support duplicate column names in SDKs #3885

Open rekby opened 6 months ago

rekby commented 6 months ago

For prevent customer unexpected issues after https://github.com/ydb-platform/ydb/issues/3553

If result has duplicate column names and user access to one of them by name - SK must return error. If user access to the column by index, or access to other columns (without name duplications) - sdk must work fine.

alex268 commented 6 months ago

Why we must return error? It brokes some conversations like JDBC standard. From here Column names used as input to getter methods are case insensitive. When a getter method is called with a column name and several columns have the same name, the value of the first matching column will be returned.

Zork33 commented 6 months ago

It's worth to discus. Since currently i.e. NodeJS SDK has no mechanism to fetch columns by index at all. As a solution, we could think about adding an index to the column name if the name is duplicated

rekby commented 5 months ago

Why we must return error? It brokes some conversations like JDBC standard.

This behavour will be at server queries and it is safest way - we always can start to support duplicated names, but it is difficult to change behavior.

may be reaction way need more research.

Main idea was:

  1. Now we don't support duplicated names on server side
  2. We will support duplicated names on server side in results
  3. Safest way - deny use unexpected column
alex268 commented 5 months ago

Our API has always supported the columns with any names, including duplicated. So these is no difference - does server support it or doesn't, the SDKs have to support it already. The only think we have to decide - the behavior of various SDKs must be equal. I checked Java SDK and it returns the last matching column - but it seems very as non conversational behavior. What about others SDK?

rekby commented 5 months ago

I think about it will be better to sync not only SDK, but server too - for have same behaviour of SDK and YQL/SQL.