From 8c8f74dfcd29b9ea0109ac7cb72d8e7c9c983ce6 Mon Sep 17 00:00:00 2001 From: gimantha Date: Mon, 23 Sep 2024 19:44:12 +0530 Subject: [PATCH] Fix code review suggestions --- langlib/lang.query/src/main/ballerina/types.bal | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/langlib/lang.query/src/main/ballerina/types.bal b/langlib/lang.query/src/main/ballerina/types.bal index d8264b9722f6..ce3c63473a4b 100644 --- a/langlib/lang.query/src/main/ballerina/types.bal +++ b/langlib/lang.query/src/main/ballerina/types.bal @@ -652,17 +652,21 @@ class _GroupByFunction { public function process() returns _Frame|error? { lock { if (self.groupedStream is ()) { - _StreamFunction pf = <_StreamFunction>self.prevFunc; + _StreamFunction pf = check self.prevFunc.ensureType(); _Frame? f = check pf.process(); while f is _Frame { anydata & readonly groupingKey = (check self.getKey(f)).cloneReadOnly(); - self.tbl.hasKey(key) ? self.tbl.get(key).frames.push(f) : self.tbl.add({groupingKey: key, frames: [f]}); + if self.tbl.hasKey(groupingKey) { + self.tbl.get(groupingKey).frames.push(f); + } else { + self.tbl.add({groupingKey, frames: [f]}); + } f = check pf.process(); } self.groupedStream = self.convertToStream(self.tbl); } - stream<_Frame> s = >self.groupedStream; + stream<_Frame> s = check self.groupedStream.ensureType(); record {|_Frame value;|}|error? next = s.next(); return next is record {|_Frame value;|} ? next.value : next; }