better usage of __isStreamHeader flag

This commit is contained in:
Jan Prochazka
2022-02-17 13:23:56 +01:00
parent 29fa8445e2
commit 2946d8a1de
8 changed files with 22 additions and 36 deletions

View File

@@ -12,14 +12,14 @@ class ParseStream extends stream.Transform {
_transform(chunk, encoding, done) {
const obj = JSON.parse(chunk);
if (!this.wasHeader) {
if (
!obj.__isStreamHeader &&
// TODO remove isArray test
!Array.isArray(obj.columns)
) {
this.push({ columns: Object.keys(obj).map(columnName => ({ columnName })) });
if (!obj.__isStreamHeader) {
this.push({
__isStreamHeader: true,
__isDynamicStructure: true,
// columns: Object.keys(obj).map(columnName => ({ columnName })),
});
}
this.wasHeader = true;
}
if (!this.limitRows || this.rowsWritten < this.limitRows) {