Skip to content

Commit fd7cea3

Browse files
authored
Merge pull request #186 from datastax/issue/CDM-91
CDM-91: Fix NPE issue with counter tables with null fields
2 parents cf91e3b + 4eb7199 commit fd7cea3

File tree

8 files changed

+18
-11
lines changed

8 files changed

+18
-11
lines changed

SIT/environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fi
6868
###
6969
# These variables are hard-coded for now
7070
SUBNET=$(echo ${CIDR} | cut -d. -f1-3)
71-
CASS_VERSION=3.11.14
71+
CASS_VERSION=3
7272
CDM_VERSION=latest
7373

7474
#==============================================================================================================================
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Read Record Count: 5
1+
Read Record Count: 6
22
Mismatch Record Count: 2
33
Corrected Mismatch Record Count: 2
44
Missing Record Count: 1
55
Corrected Missing Record Count: 0
6-
Valid Record Count: 2
6+
Valid Record Count: 3
77
Skipped Record Count: 0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Read Record Count: 5
1+
Read Record Count: 6
22
Mismatch Record Count: 0
33
Corrected Mismatch Record Count: 0
44
Missing Record Count: 1
55
Corrected Missing Record Count: 1
6-
Valid Record Count: 4
6+
Valid Record Count: 5
77
Skipped Record Count: 0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Read Record Count: 5
1+
Read Record Count: 6
22
Skipped Record Count: 0
3-
Write Record Count: 5
3+
Write Record Count: 6
44
Error Record Count: 0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Read Record Count: 5
1+
Read Record Count: 6
22
Mismatch Record Count: 0
33
Corrected Mismatch Record Count: 0
44
Missing Record Count: 0
55
Corrected Missing Record Count: 0
6-
Valid Record Count: 5
6+
Valid Record Count: 6
77
Skipped Record Count: 0

SIT/smoke/04_counters/expected.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
record3 | 2000 | 4000
55
record5 | 500 | 501
66
record2 | 11 | 20
7+
record6 | 500 | null
78
record1 | 1 | 2
89
record4 | 10000 | 20001
910

10-
(5 rows)
11+
(6 rows)

SIT/smoke/04_counters/setup.cql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ UPDATE origin.smoke_counters set col1=col1+10, col2=col2+20 where key='record2';
66
UPDATE origin.smoke_counters set col1=col1+1000, col2=col2+2000 where key='record3';
77
UPDATE origin.smoke_counters set col1=col1+10000, col2=col2+20000 where key='record4';
88
UPDATE origin.smoke_counters set col1=col1+500, col2=col2+500 where key='record5';
9+
UPDATE origin.smoke_counters set col1=col1+500 where key='record6';
910

1011
DROP TABLE IF EXISTS target.smoke_counters;
1112
CREATE TABLE target.smoke_counters(key text,col1 counter,col2 counter, PRIMARY KEY (key));

src/main/java/com/datastax/cdm/cql/statement/TargetUpdateStatement.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ protected BoundStatement bind(Row originRow, Row targetRow, Integer ttl, Long wr
4848

4949
try {
5050
if(usingCounter && counterIndexes.contains(targetIndex)) {
51-
bindValue = ((Long) cqlTable.getOtherCqlTable().getData(originIndex, originRow) - (null==targetRow ? 0 : (Long) cqlTable.getData(targetIndex, targetRow)));
51+
bindValue = cqlTable.getOtherCqlTable().getData(originIndex, originRow);
52+
if (null == bindValue) {
53+
currentBindIndex++;
54+
continue;
55+
}
56+
bindValue = ((Long) bindValue - (null==targetRow ? 0 : (Long) cqlTable.getData(targetIndex, targetRow)));
5257
}
5358
else if (targetIndex== explodeMapKeyIndex) {
5459
bindValue = explodeMapKey;

0 commit comments

Comments
 (0)