iodone commented on code in PR #2678:
URL: https://github.com/apache/incubator-kyuubi/pull/2678#discussion_r875633507


##########
externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/TrinoStatement.scala:
##########
@@ -80,63 +74,34 @@ class TrinoStatement(
     }
   }
 
-  /**
-   * Execute sql and return ResultSet.
-   */
-  def execute(): Iterable[List[Any]] = {
-    val rowQueue = new ArrayBlockingQueue[List[Any]](MAX_QUEUED_ROWS)
-
-    val dataProcessing = Future[Unit] {
-      while (trino.isRunning) {
-        val data = trino.currentData().getData()
-        if (data != null) {
-          data.asScala.map(_.asScala.toList)
-            .foreach(e => putOrThrow(rowQueue, e))
+  def execute(): Iterator[List[Any]] = {
+    Iterator.continually {
+      @tailrec
+      def getData(): (Boolean, List[List[Any]]) = {
+        if (trino.isRunning) {
+          val data = trino.currentData().getData()
+          trino.advance()

Review Comment:
   `trino.advance` must be called each time to ensure that the results obtained 
each time is the latest, if put into 87line will lead to keep getting the same 
data



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to