Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue#343 #353

Merged
merged 8 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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