SteNicholas commented on code in PR #2678:
URL: https://github.com/apache/incubator-kyuubi/pull/2678#discussion_r878966728
##########
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()
+ if (data != null) {
+ (true, data.asScala.toList.map(_.asScala.toList))
+ } else {
+ getData()
+ }
+ } else {
+ Verify.verify(trino.isFinished)
+ val finalStatus = trino.finalStatusInfo()
+ if (finalStatus.getError() != null) {
+ throw KyuubiSQLException(
+ s"Query ${finalStatus.getId} failed:
${finalStatus.getError.getMessage}")
Review Comment:
If the user invokes the `getQueryId` interface, is this query id same as the
returned id of `getQueryId`?
--
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]