Skip to content

Commit

Permalink
Fix for Issue#343 (#353)
Browse files Browse the repository at this point in the history
* Fix for Issue#343

* Reinstate changes and applied modified check to allow empty qualifier

* Update read-rows-acceptance-test.json

* Update read-rows-acceptance-test.json

* Update chunktransformer.js

* Update chunktransformer.js
  • Loading branch information
muraliQlogic authored and sduskis committed Nov 8, 2018
1 parent a8f156d commit e47d80a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/chunktransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class ChunkTransformer extends Transform {
errorMessage = 'A commit happened but the same key followed';
} else if (!chunk.familyName) {
errorMessage = 'A family must be set';
} else if (!chunk.qualifier) {
} else if (chunk.qualifier === null || chunk.qualifier === undefined) {
errorMessage = 'A column qualifier must be set';
}
if (errorMessage) {
Expand Down Expand Up @@ -247,7 +247,10 @@ class ChunkTransformer extends Transform {
return;
}
}
if (chunk.familyName && !chunk.qualifier) {
if (
chunk.familyName &&
(chunk.qualifier === null || chunk.qualifier === undefined)
) {
this.destroy(
new TransformError({
message: 'A qualifier must be specified',
Expand Down
2 changes: 1 addition & 1 deletion system-test/read-rows-acceptance-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -872,4 +872,4 @@
"ts": 0
}]
}]
}
}
47 changes: 47 additions & 0 deletions test/chunktransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,53 @@ describe('Bigtable/ChunkTransformer', function() {
'state mismatch'
);
});
it('chunk with familyName and empty qualifier should produce row', function() {
chunkTransformer.qualifiers = [];
chunkTransformer.family = {
qualifier: chunkTransformer.qualifiers,
};
chunkTransformer.row = {
key: 'key',
data: {
family: chunkTransformer.family,
},
};
const chunk = {
commitRow: true,
familyName: {value: 'family2'},
qualifier: '',
value: 'value',
timestampMicros: 0,
labels: [],
valueSize: 0,
};
chunkTransformer.processRowInProgress(chunk);
assert(commitSpy.called, 'did not call commit');
assert(resetSpy.called, 'did not call reset');
assert.strictEqual(rows.length, 1, 'wrong call to push');
const expectedRow = {
key: 'key',
data: {
family: {
qualifier: [
{
value: 'value',
timestamp: 0,
labels: [],
},
],
},
family2: {},
},
};
const row = rows[0];
assert.deepStrictEqual(row, expectedRow, 'row mismatch');
assert.strictEqual(
chunkTransformer.state,
RowStateEnum.NEW_ROW,
'state mismatch'
);
});
it('chunk with new family and commitRow should produce row', function() {
chunkTransformer.qualifiers = [];
chunkTransformer.family = {
Expand Down

0 comments on commit e47d80a

Please sign in to comment.