Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 455ce8e

Browse files
jvalkealilayaperumalg
authored andcommitted
Fix parser for named destination from processor
- While parser previously correctly named type as source leading named destination, having source and processor leading to named destination wrongly marked processor as sink. Now handling this case by checking presense of sinkChannel. - Fixes #931
1 parent 576a888 commit 455ce8e

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

ui/src/app/shared/services/parser.spec.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,41 @@ describe('parser:', () => {
102102
});
103103

104104
it('long running apps', () => {
105-
parseResult = Parser.parse('aaa, bbb', 'stream');
106-
expect(parseResult.lines.length).toEqual(1);
107-
line = parseResult.lines[0];
108-
nodes = parseResult.lines[0].nodes;
109-
expect(nodes.length).toEqual(2);
110-
node = nodes[0];
111-
expect(node.group).toEqual('UNKNOWN_0');
112-
expect(node.type).toEqual('app');
113-
expect(node.name).toEqual('aaa');
114-
expectRange(node.range, 0, 0, 3, 0);
115-
node = nodes[1];
116-
expect(node.group).toEqual('UNKNOWN_0');
117-
expect(node.type).toEqual('app');
118-
expect(node.name).toEqual('bbb');
119-
expectRange(node.range, 5, 0, 8, 0);
105+
parseResult = Parser.parse('aaa, bbb', 'stream');
106+
expect(parseResult.lines.length).toEqual(1);
107+
line = parseResult.lines[0];
108+
nodes = parseResult.lines[0].nodes;
109+
expect(nodes.length).toEqual(2);
110+
node = nodes[0];
111+
expect(node.group).toEqual('UNKNOWN_0');
112+
expect(node.type).toEqual('app');
113+
expect(node.name).toEqual('aaa');
114+
expectRange(node.range, 0, 0, 3, 0);
115+
node = nodes[1];
116+
expect(node.group).toEqual('UNKNOWN_0');
117+
expect(node.type).toEqual('app');
118+
expect(node.name).toEqual('bbb');
119+
expectRange(node.range, 5, 0, 8, 0);
120+
});
121+
122+
it('from source and processor to named destination', () => {
123+
parseResult = Parser.parse('time | transform > :foo', 'stream');
124+
expect(parseResult.lines.length).toEqual(1);
125+
line = parseResult.lines[0];
126+
nodes = parseResult.lines[0].nodes;
127+
expect(nodes.length).toEqual(2);
128+
node = nodes[0];
129+
expect(node.group).toEqual('UNKNOWN_0');
130+
expect(node.type).toEqual('source');
131+
expect(node.name).toEqual('time');
132+
expectRange(node.range, 0, 0, 4, 0);
133+
expectChannels(node, null, null);
134+
node = nodes[1];
135+
expect(node.group).toEqual('UNKNOWN_0');
136+
expect(node.type).toEqual('processor');
137+
expect(node.name).toEqual('transform');
138+
expectRange(node.range, 7, 0, 16, 0);
139+
expectChannels(node, null, 'foo');
120140
});
121141

122142
it('options', () => {

ui/src/app/shared/services/parser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,10 @@ class InternalParser {
587587
} else {
588588
if (m === 0 && !streamdef.sourceChannel) {
589589
expectedType = 'source';
590-
} else if (m === (streamdef.apps.length - 1)) {
590+
} else if (m === (streamdef.apps.length - 1) && !streamdef.sinkChannel) {
591+
// if last expect it to be sink only
592+
// without sink channel. i.e. source | processor > :dest
593+
// we fall back to processor type
591594
expectedType = 'sink';
592595
}
593596
}

0 commit comments

Comments
 (0)