microsoft / mssql-jdbc

The Microsoft JDBC Driver for SQL Server is a Type 4 JDBC driver that provides database connectivity with SQL Server through the standard JDBC application program interfaces (APIs).
MIT License
1.06k stars 426 forks source link

[FEATURE REQUEST]Add order Hints for Bulk Copy operations #1481

Open luxu1-ms opened 3 years ago

luxu1-ms commented 3 years ago

Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it

Can you add support for order hints for bulk copy operations? I am going to add order hints for spark-mssql-connector but there is no implementation of order hints for SQLServerBulkCopy.class, SQLServerBulkCopyOptions.class

Describe the preferred solution

Describe alternatives you've considered

Additional context

Reference Documentations/Specifications

BULK INSERT allow to specify if data already has a specific order so that Azure SQL / SQL Server can avoid sorting it again if inserting data into a clustered index.

ORDER ( { column [ ASC | DESC ] } [ ,... n ] ) Specifies how the data in the data file is sorted. Bulk import performance is improved if the data being imported is sorted according to the clustered index on the table, if any. If the data file is sorted in a different order, that is other than the order of a clustered index key or if there is no clustered index on the table, the ORDER clause is ignored. The column names supplied must be valid column names in the destination table. By default, the bulk insert operation assumes the data file is unordered. For optimized bulk import, SQL Server also validates that the imported data is sorted.

https://docs.microsoft.com/en-us/sql/connect/ado-net/sql/bulk-copy-order-hints?view=sql-server-ver15

Reference Implementation

ulvii commented 3 years ago

Hi @luxu1-ms , Thank you for the suggestion. The team will take a look into this.

luxu1-ms commented 3 years ago

Hi, any update on this issue

lilgreenbird commented 3 years ago

hi @luxu1-ms This issue is in our backlog. This will be triaged when we plan for the next semester.

Thanks.

shivsood commented 1 year ago

Any updates on this?

lilgreenbird commented 1 year ago

hi @shivsood

This issue is still in our backlog. It didn't make the cut as we have to prioritize bug fixes and other features that are in higher demand. Please feel free to fill out our survey for features you would like to see in the driver we do look at the results when we do semester planning.

siggemannen commented 1 year ago

Would patches for this be accepted? it looks to be literally a couple of rows of changes since it's all in the query being send to sql server + new orderoption parameter to bulk copy options

Jeffery-Wasty commented 1 year ago

Yes, we accept external PRs. Feel free to submit something, and we'll take a look.