flink-cdc icon indicating copy to clipboard operation
flink-cdc copied to clipboard

The uniqueidentifier type in SQL Server cannot be compared using ObjectUtils.compare.

Open comien opened this issue 2 years ago • 4 comments

The uniqueidentifier type in SQL Server cannot be compared using ObjectUtils.compare. For example, in SQL Server, the value 'C6D6083A-4D2A-40D0-B20A-000005972E13' is considered less than 'B63D3AA7-8BC8-4C0F-BACD-FFFFFDAA57CD'.

DECLARE @uuid1 uniqueidentifier = 'C6D6083A-4D2A-40D0-B20A-000005972E13';
DECLARE @uuid2 uniqueidentifier = 'B63D3AA7-8BC8-4C0F-BACD-FFFFFDAA57CD';

SELECT CASE 
         WHEN BINARY_CHECKSUM(CAST(@uuid1 AS binary(16))) > BINARY_CHECKSUM(CAST(@uuid2 AS binary(16))) THEN 'uuid1 greater than uuid2'
         WHEN BINARY_CHECKSUM(CAST(@uuid1 AS binary(16))) < BINARY_CHECKSUM(CAST(@uuid2 AS binary(16))) THEN 'uuid1 小于 uuid2'
         ELSE 'uuid1 less than uuid2'
       END AS result;�

Due to the incorrect comparison, the split chunks are terminated prematurely. Therefore, I have chosen to address this issue by using a SQL query specifically for this type.

comien avatar Oct 26 '23 09:10 comien

@comien please refer https://ververica.github.io/flink-cdc-connectors/master/content/about.html#code-style

gtk96 avatar Oct 27 '23 03:10 gtk96

@comien Thanks for your contribution, Could you add test for this case?

leonardBang avatar Nov 24 '23 09:11 leonardBang

@comien Hi, Can you rebase master and add unit test to confirm this fix worked?

GOODBOY008 avatar Dec 04 '23 10:12 GOODBOY008

Hi @comien, could you please rebase this PR with latest master branch before it could be merged?

yuxiqian avatar Apr 26 '24 05:04 yuxiqian

This pull request has been automatically marked as stale because it has not had recent activity for 60 days. It will be closed in 30 days if no further activity occurs.

github-actions[bot] avatar Jul 17 '24 00:07 github-actions[bot]