Comments (5)
Ok, so the issue seems to be caused by this:
public string GetOrderBy()
{
return SourceTableInfo.PrimaryIndex.GetOrderBy(excludePartitionColumn:true);
}
This means the ORDER BY generated in the SELECT statement excludes the partitioning key, but the ORDER BY added to the BulkCopy itself includes the partitioning key. When I change excludePartitionColumn to false, it works fine.
from smartbulkcopy.
Good catch, thanks! Not sure I understand what are the conditions that make this issue happen. You have the table on source and the destination created with the same partitioning function and scheme. Both have an Clustered Index.
Adding the Partition column to the order by is needed to make sure sorting does not happen on the destination.
Are you able to create a repro so that I can take a look at it?
Thanks!
from smartbulkcopy.
This script should highlight the issue: By excluding the partition column, the sort order of the data will be different on select and in bulk copy object.
CREATE PARTITION FUNCTION pfTest AS RANGE LEFT FOR VALUES (N'2018-12-31T00:00:00.000', N'2019-12-31T00:00:00.000')
GO
CREATE PARTITION SCHEME [psTest] AS PARTITION [pfTest] TO ([PRIMARY], [PRIMARY], [PRIMARY])
GO
CREATE TABLE PartitionTest (
PartitionDate date not null,
TransactionId int not null,
CategoryId int not null
CONSTRAINT [PK_PartitionTest] PRIMARY KEY CLUSTERED
(
PartitionDate ASC,
TransactionId ASC,
CategoryId ASC
) ON psTest
)
GO
INSERT INTO PartitionTest (PartitionDate, TransactionId, CategoryId)
VALUES
('2018-01-01', 2, 1),
('2018-01-02', 1, 1)
from smartbulkcopy.
Thanks, will take a look ASAP
from smartbulkcopy.
Thanks, I was able to repro the problem and fixed it. Added also unit tests and CI/CD pipeline to make sure not to introduce regression bugs.
Fixed here: b85f6b8
from smartbulkcopy.
Related Issues (20)
- Add staging support
- Add support to Edge and Node tables
- Take into account compression when analyzing source data size
- Detect and warn if secondary indexes are present HOT 1
- Check for FOREIGN KEYS upfront HOT 1
- Temporal Tables retention period always set to INFINITE
- Issues with SQL Server Data Types (Spatial / Hierarchy) HOT 1
- Add an option to copy identity seed HOT 1
- step by step guide
- Nuget Package HOT 1
- Supporting VM Identity or Azure Authentication for Always Encrypted Database scenario HOT 3
- Copying Large Tables Generates Blocking HOT 5
- SmartBulkCopy was fast only initially but slowed down for last heavy tables HOT 2
- .Net 3.1 Core is out of support.
- Cleanup code for retry logic HOT 1
- Add an option to enable/disable bulk load hints HOT 1
- Improve TABLOCK usage HOT 1
- Create logical partition by size HOT 1
- Use Clustered Index for logical partitioning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smartbulkcopy.