This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/main/pr-9493-43c398229d64be3931838aee0c2c08ea323018a1
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 4ff82fadc33126bf6475ec71fb03308ff8ecff85
Author: Xinyuan Lin <[email protected]>
AuthorDate: Tue Nov 17 06:02:31 2026 +0000

    refactor(amber): simplify workflow storage and export (#9493)
    
    ### What changes were proposed in this PR?
    
    Remove the unread completed-plan subscription and two unused request
    helpers from Amber. Simplify export response construction and Parquet
    stream cleanup while preserving response status, filenames, and stream
    closure.
    
    Read only the warehouse fields used for dashboard responses, deletion,
    or execution routing. The dashboard query goes from 12 columns to seven.
    Lakekeeper pagination uses the next-page token directly.
    
    **+107/−195 lines across seven files.** #2154 added the completed-plan
    field. #3306 removed its final reader. #3728 introduced the two export
    helpers with zero production callers.
    
    ### Any related issues, documentation, discussions?
    
    Closes #9458.
    
    ### How was this PR tested?
    
    205 tests passed across nine suites on JDK 17 with freshly generated
    jOOQ classes. The new PostgreSQL test fails at the test-only commit on
    the 12-column query and passes on the seven-column query. It also checks
    that only the caller's warehouse is returned. The 204 retained cases
    match the baseline. The five retired tests covered only the two removed
    helpers.
    
    ```text
    sbt --batch "WorkflowExecutionService/testOnly *ResultExportServiceSpec 
*WorkflowServiceSpec *WorkflowServiceWarehouseSpec *LakekeeperClientSpec 
*WarehouseResourceSpec *WorkflowExecutionsResourceSpec 
*ExecutionResultServiceSpec *WorkflowLifecycleManagerSpec 
*ExecutionStateStoreSpec" "WorkflowExecutionService/scalafmtCheck" 
"WorkflowExecutionService/Test/scalafmtCheck" 
"WorkflowExecutionService/scalafixAll --check"
    ```
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Codex (GPT-6), Claude Code (Claude Opus 5.5)
---
 .../user/warehouse/WarehouseResource.scala         | 54 +++++++-------
 .../texera/web/service/LakekeeperClient.scala      |  6 +-
 .../texera/web/service/ResultExportService.scala   | 85 +++++-----------------
 .../texera/web/service/WorkflowService.scala       | 31 ++------
 .../user/warehouse/WarehouseResourceSpec.scala     | 37 +++++++++-
 .../web/service/ResultExportServiceSpec.scala      | 83 ++++-----------------
 .../texera/web/service/WorkflowServiceSpec.scala   |  6 --
 7 files changed, 107 insertions(+), 195 deletions(-)

diff --git 
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResource.scala
 
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResource.scala
index dafc212fd0..7145d72941 100644
--- 
a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResource.scala
+++ 
b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResource.scala
@@ -29,10 +29,9 @@ import org.apache.texera.dao.SqlServer
 import org.apache.texera.dao.jooq.generated.Tables.{USER, USER_WAREHOUSE}
 import org.apache.texera.dao.jooq.generated.enums.UserWarehouseFlavorEnum
 import org.apache.texera.dao.jooq.generated.tables.pojos.User
-import org.apache.texera.dao.jooq.generated.tables.records.UserWarehouseRecord
 import 
org.apache.texera.web.resource.dashboard.user.warehouse.WarehouseResource._
 import org.apache.texera.web.service.LakekeeperClient
-import org.jooq.DSLContext
+import org.jooq.{DSLContext, Field, Record}
 import org.jooq.impl.DSL
 
 import javax.annotation.security.RolesAllowed
@@ -94,16 +93,24 @@ object WarehouseResource {
 
   private def ownerOf(user: User): Owner = ownerOf(user.getName, 
user.getAvatar)
 
+  private val dashboardFields: Seq[Field[_]] = Seq(
+    USER_WAREHOUSE.WHID,
+    USER_WAREHOUSE.NAME,
+    USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_NAME,
+    USER_WAREHOUSE.FLAVOR,
+    USER_WAREHOUSE.CREATED_AT
+  )
+
   private def toDashboardWarehouse(
-      row: UserWarehouseRecord,
+      row: Record,
       owner: Owner
   ): DashboardWarehouse =
     DashboardWarehouse(
-      row.getWhid,
-      row.getName,
-      row.getLakekeeperWarehouseName,
-      row.getFlavor.getLiteral,
-      row.getCreatedAt.toInstant.toEpochMilli,
+      row.get(USER_WAREHOUSE.WHID),
+      row.get(USER_WAREHOUSE.NAME),
+      row.get(USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_NAME),
+      row.get(USER_WAREHOUSE.FLAVOR).getLiteral,
+      row.get(USER_WAREHOUSE.CREATED_AT).toInstant.toEpochMilli,
       ownerName = owner._1,
       ownerAvatar = owner._2
     )
@@ -139,25 +146,19 @@ class WarehouseResource(client: LakekeeperClient, 
enabled: Boolean) extends Lazy
     }
     // Joined rather than resolved in a second query: one round trip, and 
every row
     // carries its own owner once warehouses can be shared.
-    val rows = context
-      .select(USER_WAREHOUSE.fields() ++ Seq(USER.NAME, USER.AVATAR): _*)
+    val warehouses = context
+      .select((dashboardFields ++ Seq(USER.NAME, USER.AVATAR)): _*)
       .from(USER_WAREHOUSE)
       .leftJoin(USER)
       .on(USER.UID.eq(USER_WAREHOUSE.UID))
       .where(USER_WAREHOUSE.UID.eq(current_user.getUid))
       .orderBy(USER_WAREHOUSE.CREATED_AT.asc())
-      .fetch()
+      .fetch { row =>
+        toDashboardWarehouse(row, ownerOf(row.get(USER.NAME), 
row.get(USER.AVATAR)))
+      }
       .asScala
       .toList
-    WarehouseStatus(
-      enabled = true,
-      warehouses = rows.map(r =>
-        toDashboardWarehouse(
-          r.into(USER_WAREHOUSE),
-          ownerOf(r.get(USER.NAME), r.get(USER.AVATAR))
-        )
-      )
-    )
+    WarehouseStatus(enabled = true, warehouses = warehouses)
   }
 
   @POST
@@ -212,7 +213,7 @@ class WarehouseResource(client: LakekeeperClient, enabled: 
Boolean) extends Lazy
     try {
       row.store()
       // created_at is filled by the DB default; fetch it back before 
serializing.
-      row.refresh()
+      row.refresh(USER_WAREHOUSE.CREATED_AT)
     } catch {
       case e: Exception =>
         // Compensate: without the row the user could neither list nor delete 
the
@@ -238,15 +239,16 @@ class WarehouseResource(client: LakekeeperClient, 
enabled: Boolean) extends Lazy
   @RolesAllowed(Array("REGULAR", "ADMIN"))
   def delete(@PathParam("whid") whid: Integer, @Auth current_user: 
SessionUser): Unit = {
     requireEnabled()
-    val row = context
-      .selectFrom(USER_WAREHOUSE)
+    val lakekeeperWarehouseId = context
+      .select(USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_ID)
+      .from(USER_WAREHOUSE)
       
.where(USER_WAREHOUSE.WHID.eq(whid).and(USER_WAREHOUSE.UID.eq(current_user.getUid)))
-      .fetchOne()
-    if (row == null) {
+      .fetchOne(USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_ID)
+    if (lakekeeperWarehouseId == null) {
       throw new NotFoundException(s"no warehouse with id $whid")
     }
     try {
-      client.deleteWarehouseEmptyFirst(row.getLakekeeperWarehouseId)
+      client.deleteWarehouseEmptyFirst(lakekeeperWarehouseId)
     } catch {
       case e: Exception =>
         throw new WebApplicationException(e.getMessage, 502)
diff --git 
a/amber/src/main/scala/org/apache/texera/web/service/LakekeeperClient.scala 
b/amber/src/main/scala/org/apache/texera/web/service/LakekeeperClient.scala
index eebde38cf4..14603f4d77 100644
--- a/amber/src/main/scala/org/apache/texera/web/service/LakekeeperClient.scala
+++ b/amber/src/main/scala/org/apache/texera/web/service/LakekeeperClient.scala
@@ -218,8 +218,7 @@ class LakekeeperClient(
   ): List[String] = {
     val results = ListBuffer[String]()
     var pageToken: Option[String] = None
-    var more = true
-    while (more) {
+    do {
       val request = Unirest.get(url)
       pageToken.foreach(request.queryString("pageToken", _))
       val response = request.asString()
@@ -233,8 +232,7 @@ class LakekeeperClient(
         .filterNot(_.isNull)
         .map(_.asText())
         .filter(_.nonEmpty)
-      more = pageToken.isDefined
-    }
+    } while (pageToken.isDefined)
     results.toList
   }
 }
diff --git 
a/amber/src/main/scala/org/apache/texera/web/service/ResultExportService.scala 
b/amber/src/main/scala/org/apache/texera/web/service/ResultExportService.scala
index 10667bc781..1ec1a70673 100644
--- 
a/amber/src/main/scala/org/apache/texera/web/service/ResultExportService.scala
+++ 
b/amber/src/main/scala/org/apache/texera/web/service/ResultExportService.scala
@@ -19,9 +19,6 @@
 
 package org.apache.texera.web.service
 
-import com.fasterxml.jackson.core.`type`.TypeReference
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.fasterxml.jackson.module.scala.DefaultScalaModule
 import com.github.tototoshi.csv.CSVWriter
 import org.apache.texera.amber.core.storage.{
   DocumentFactory,
@@ -59,7 +56,6 @@ import javax.ws.rs.WebApplicationException
 import javax.ws.rs.core.{MediaType, Response, StreamingOutput}
 import scala.collection.mutable
 import scala.collection.mutable.ArrayBuffer
-import scala.jdk.CollectionConverters._
 import scala.util.Using
 
 object Constants {
@@ -114,15 +110,13 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
       }
     }
 
-    var exportResponse: ResultExportResponse = null
-    if (errorMessages.isEmpty) {
-      exportResponse = ResultExportResponse("success", 
successMessages.mkString("\n"))
-    } else if (successMessages.isEmpty) {
-      exportResponse = ResultExportResponse("error", 
errorMessages.mkString("\n"))
-    } else {
-      // At least one success, so we consider overall success (with partial 
possible).
-      exportResponse = ResultExportResponse("success", 
successMessages.mkString("\n"))
-    }
+    // At least one successful export makes the overall result successful.
+    val exportResponse =
+      if (errorMessages.nonEmpty && successMessages.isEmpty) {
+        ResultExportResponse("error", errorMessages.mkString("\n"))
+      } else {
+        ResultExportResponse("success", successMessages.mkString("\n"))
+      }
 
     Response.ok(exportResponse).build()
   }
@@ -134,11 +128,7 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
     */
   def exportToLocal(request: ResultExportRequest): Response = {
     if (request.operators.size > 1) {
-      val (zipStream, zipFileNameOpt) = exportOperatorsAsZip(request)
-      if (zipStream == null) {
-        throw new RuntimeException("Zip stream is null")
-      }
-      val fileName = zipFileNameOpt.getOrElse("operators.zip")
+      val (zipStream, fileName) = exportOperatorsAsZip(request)
 
       Response
         .ok(zipStream, "application/zip")
@@ -147,11 +137,8 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
 
     } else {
       val op = request.operators.head
-      val (streamingOutput, fileNameOpt) = 
exportOperatorResultAsStream(request, op)
-      if (streamingOutput == null) {
-        throw new RuntimeException("Failed to export operator")
-      }
-      val fileName = fileNameOpt.getOrElse("download.dat")
+      val (streamingOutput, fileName) = exportOperatorResultAsStream(request, 
op)
+        .getOrElse(throw new RuntimeException("Failed to export operator"))
 
       Response
         .ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM)
@@ -204,15 +191,15 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
   def exportOperatorResultAsStream(
       request: ResultExportRequest,
       operatorRequest: OperatorExportInfo
-  ): (StreamingOutput, Option[String]) = {
+  ): Option[(StreamingOutput, String)] = {
     val execIdOpt = getLatestExecutionId(workflowIdentity, computingUnitId)
     if (execIdOpt.isEmpty) {
-      return (null, None)
+      return None
     }
 
     val operatorDocument = getOperatorDocument(operatorRequest.id, 
computingUnitId)
     if (operatorDocument == null || operatorDocument.getCount == 0) {
-      return (null, None)
+      return None
     }
 
     val fileName =
@@ -235,7 +222,7 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
       }
     }
 
-    (streamingOutput, Some(fileName))
+    Some((streamingOutput, fileName))
   }
 
   /**
@@ -243,7 +230,7 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
     */
   def exportOperatorsAsZip(
       request: ResultExportRequest
-  ): (StreamingOutput, Option[String]) = {
+  ): (StreamingOutput, String) = {
     val timestamp = LocalDateTime
       .now()
       .truncatedTo(ChronoUnit.SECONDS)
@@ -289,7 +276,7 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
       }
     }
 
-    (streamingOutput, Some(zipFileName))
+    (streamingOutput, zipFileName)
   }
 
   /**
@@ -425,19 +412,8 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
   private def streamDocumentAsParquetZip(
       doc: VirtualDocument[Tuple],
       outputStream: OutputStream
-  ): Unit = {
-    try {
-      val zipStream = doc.asInputStream()
-      try {
-        IOUtils.copy(zipStream, outputStream)
-      } finally {
-        zipStream.close()
-      }
-    } catch {
-      case e: Exception =>
-        throw e
-    }
-  }
+  ): Unit =
+    Using.resource(doc.asInputStream())(IOUtils.copy(_, outputStream))
 
   /*
    * Handle streaming a single (row, column) from an operator's result.
@@ -601,29 +577,4 @@ class ResultExportService(workflowIdentity: 
WorkflowIdentity, computingUnitId: I
     // remove path separators
     StringUtils.replaceEach(rawName, Array("/", "\\"), Array("", ""))
   }
-
-  /**
-    * Parse a JSON string array of operators into a list of OperatorExportInfo 
objects.
-    */
-  def parseOperators(operatorsJson: String): List[OperatorExportInfo] = {
-    new ObjectMapper()
-      .registerModule(DefaultScalaModule)
-      .readValue(operatorsJson, new TypeReference[List[OperatorExportInfo]] {})
-  }
-
-  /**
-    * Validate an export request by checking if any operators are selected.
-    * Return an error response if none are selected, otherwise None.
-    */
-  def validateExportRequest(request: ResultExportRequest): Option[Response] = {
-    if (request.operators.isEmpty) {
-      Some(
-        Response
-          .status(Response.Status.BAD_REQUEST)
-          .`type`(MediaType.APPLICATION_JSON)
-          .entity(Map("error" -> "No operator selected").asJava)
-          .build()
-      )
-    } else None
-  }
 }
diff --git 
a/amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala 
b/amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala
index fe138528fd..5d9b064af4 100644
--- a/amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala
+++ b/amber/src/main/scala/org/apache/texera/web/service/WorkflowService.scala
@@ -45,7 +45,6 @@ import 
org.apache.texera.amber.core.workflowruntimestate.FatalErrorType.EXECUTIO
 import org.apache.texera.amber.core.workflowruntimestate.WorkflowFatalError
 import 
org.apache.texera.amber.engine.architecture.coordinator.CoordinatorConfig
 import 
org.apache.texera.amber.engine.architecture.rpc.controlreturns.WorkflowAggregatedState.{
-  COMPLETED,
   FAILED
 }
 import org.apache.texera.amber.engine.architecture.worker.WorkflowWorker.{
@@ -65,7 +64,6 @@ import 
org.apache.texera.web.service.WorkflowService.mkWorkflowStateId
 import org.apache.texera.web.storage.ExecutionStateStore.updateWorkflowState
 import org.apache.texera.web.storage.{ExecutionStateStore, WorkflowStateStore}
 import org.apache.texera.web.{SubscriptionManager, WorkflowLifecycleManager}
-import org.apache.texera.common.compiler.model.LogicalPlan
 import play.api.libs.json.Json
 
 import java.net.URI
@@ -107,16 +105,17 @@ object WorkflowService {
       )
     }
     warehouseId.map(id => {
-      val row = SqlServer
+      val lakekeeperWarehouseName = SqlServer
         .getInstance()
         .createDSLContext()
-        .selectFrom(USER_WAREHOUSE)
+        .select(USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_NAME)
+        .from(USER_WAREHOUSE)
         .where(USER_WAREHOUSE.WHID.eq(id).and(USER_WAREHOUSE.UID.eq(uid)))
-        .fetchOne()
-      if (row == null) {
+        .fetchOne(USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_NAME)
+      if (lakekeeperWarehouseName == null) {
         throw new IllegalArgumentException(s"no warehouse with id $id owned by 
this user")
       }
-      row.getLakekeeperWarehouseName
+      lakekeeperWarehouseName
     })
   }
   val cleanUpDeadlineInSeconds: Int = 
ApplicationConfig.executionStateCleanUpInSecs
@@ -177,22 +176,6 @@ class WorkflowService(
     }
   )
 
-  var lastCompletedLogicalPlan: Option[LogicalPlan] = Option.empty
-
-  executionService.subscribe { executionService: WorkflowExecutionService =>
-    {
-      executionService.executionStateStore.metadataStore.registerDiffHandler {
-        (oldState, newState) =>
-          {
-            if (oldState.state != COMPLETED && newState.state == COMPLETED) {
-              lastCompletedLogicalPlan = 
Option.apply(executionService.workflow.logicalPlan)
-            }
-            Iterable.empty
-          }
-      }
-    }
-  }
-
   def connect(onNext: TexeraWebSocketEvent => Unit): Disposable = {
     lifeCycleManager.increaseUserCount()
     val subscriptions = stateStore.getAllStores
@@ -320,7 +303,7 @@ class WorkflowService(
           val fromActorOpt = t match {
             case ex: WorkflowRuntimeException =>
               ex.relatedWorkerId
-            case other =>
+            case _ =>
               None
           }
           val (operatorId, workerId) = getOperatorFromActorIdOpt(fromActorOpt)
diff --git 
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResourceSpec.scala
 
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResourceSpec.scala
index b7510980ad..e71ad3c3e0 100644
--- 
a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResourceSpec.scala
+++ 
b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/warehouse/WarehouseResourceSpec.scala
@@ -22,7 +22,7 @@ package 
org.apache.texera.web.resource.dashboard.user.warehouse
 import org.apache.texera.auth.SessionUser
 import org.apache.texera.common.config.StorageConfig
 import org.apache.texera.dao.MockTexeraDB
-import org.apache.texera.dao.jooq.generated.Tables.USER_WAREHOUSE
+import org.apache.texera.dao.jooq.generated.Tables.{USER, USER_WAREHOUSE}
 import org.apache.texera.dao.jooq.generated.tables.daos.UserDao
 import org.apache.texera.dao.jooq.generated.tables.pojos.User
 import 
org.apache.texera.web.resource.dashboard.user.warehouse.WarehouseResource.{
@@ -30,6 +30,8 @@ import 
org.apache.texera.web.resource.dashboard.user.warehouse.WarehouseResource
   CreateWarehouseRequest
 }
 import org.apache.texera.web.service.LakekeeperClient
+import org.jooq.{ExecuteContext, ExecuteListener}
+import org.jooq.impl.{DefaultConfiguration, DefaultExecuteListenerProvider}
 import org.scalatest.flatspec.AnyFlatSpec
 import org.scalatest.matchers.should.Matchers
 import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
@@ -125,6 +127,39 @@ class WarehouseResourceSpec
     a[ForbiddenException] should be thrownBy disabledResource.delete(1, 
sessionUser)
   }
 
+  "status" should "read only the fields returned for an owned warehouse" in {
+    val owned = resource.create(CreateWarehouseRequest("mine"), sessionUser)
+    resource.create(CreateWarehouseRequest("theirs"), otherUser)
+
+    val selectedFields = mutable.Buffer.empty[List[String]]
+    val configuration = 
getDSLContext.configuration().asInstanceOf[DefaultConfiguration]
+    val previousListeners = configuration.executeListenerProviders()
+    configuration.set(new DefaultExecuteListenerProvider(new ExecuteListener {
+      override def executeEnd(ctx: ExecuteContext): Unit = {
+        val metadata = ctx.resultSet().getMetaData
+        selectedFields += (1 to metadata.getColumnCount).iterator
+          .map(i => 
s"${metadata.getTableName(i)}.${metadata.getColumnName(i)}")
+          .toList
+      }
+    }))
+    val status =
+      try resource.status(sessionUser)
+      finally configuration.set(previousListeners: _*)
+
+    status.warehouses shouldBe List(owned)
+    selectedFields.toList shouldBe List(
+      List(
+        USER_WAREHOUSE.WHID,
+        USER_WAREHOUSE.NAME,
+        USER_WAREHOUSE.LAKEKEEPER_WAREHOUSE_NAME,
+        USER_WAREHOUSE.FLAVOR,
+        USER_WAREHOUSE.CREATED_AT,
+        USER.NAME,
+        USER.AVATAR
+      ).map(field => s"${field.getTable.getName}.${field.getName}")
+    )
+  }
+
   // 
---------------------------------------------------------------------------
   // Create / list / delete
   // 
---------------------------------------------------------------------------
diff --git 
a/amber/src/test/scala/org/apache/texera/web/service/ResultExportServiceSpec.scala
 
b/amber/src/test/scala/org/apache/texera/web/service/ResultExportServiceSpec.scala
index 81b931898f..de76bad7f1 100644
--- 
a/amber/src/test/scala/org/apache/texera/web/service/ResultExportServiceSpec.scala
+++ 
b/amber/src/test/scala/org/apache/texera/web/service/ResultExportServiceSpec.scala
@@ -19,7 +19,6 @@
 
 package org.apache.texera.web.service
 
-import com.fasterxml.jackson.core.JsonProcessingException
 import com.github.tototoshi.csv.CSVReader
 import com.sun.net.httpserver.{HttpExchange, HttpHandler, HttpServer}
 import org.apache.arrow.memory.RootAllocator
@@ -85,8 +84,7 @@ import scala.collection.mutable.ArrayBuffer
   *
   * Two layers are covered:
   *
-  *  - The pure helpers (parseOperators / validateExportRequest) and the 
private
-  *    export-encoding writers. Every writer takes a VirtualDocument parameter,
+  *  - The private export-encoding writers. Every writer takes a 
VirtualDocument parameter,
   *    so an in-spec fake document is enough for those.
   *
   *  - The request-level entry points (exportToLocal / exportToDataset /
@@ -132,46 +130,6 @@ class ResultExportServiceSpec
       computingUnitId = 0
     )
 
-  // -- parseOperators 
---------------------------------------------------------
-
-  "parseOperators" should "deserialize a JSON array into OperatorExportInfo 
objects" in {
-    val json =
-      
"""[{"id":"op-1","outputType":"csv"},{"id":"op-2","outputType":"arrow"}]"""
-    val parsed = service.parseOperators(json)
-
-    parsed shouldBe List(
-      OperatorExportInfo("op-1", "csv"),
-      OperatorExportInfo("op-2", "arrow")
-    )
-  }
-
-  it should "round-trip an empty JSON array to an empty list" in {
-    service.parseOperators("[]") shouldBe List.empty[OperatorExportInfo]
-  }
-
-  it should "throw when given a malformed JSON string" in {
-    a[JsonProcessingException] should be thrownBy service.parseOperators("not 
json")
-  }
-
-  // -- validateExportRequest 
--------------------------------------------------
-
-  "validateExportRequest" should "return a 400 response when no operators are 
selected" in {
-    val result = service.validateExportRequest(requestWith(List.empty))
-
-    val response = result.getOrElse(fail("expected a validation error 
response"))
-    response.getStatus shouldBe Response.Status.BAD_REQUEST.getStatusCode
-    response.getEntity match {
-      case m: java.util.Map[_, _] => m.get("error") shouldBe "No operator 
selected"
-      case other                  => fail(s"unexpected entity: $other")
-    }
-  }
-
-  it should "return None when at least one operator is selected" in {
-    val result =
-      
service.validateExportRequest(requestWith(List(OperatorExportInfo("op-1", 
"csv"))))
-    result shouldBe None
-  }
-
   // -- fakes for the export writers 
-------------------------------------------
 
   private val schema: Schema = Schema()
@@ -591,11 +549,7 @@ class ResultExportServiceSpec
 
   "exportOperatorResultAsStream" should "yield no stream when the workflow 
never ran" in {
     val op = OperatorExportInfo("op-1", "csv")
-    val (stream, fileName) =
-      exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op)
-
-    stream shouldBe null
-    fileName shouldBe None
+    exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op) 
shouldBe None
   }
 
   it should "yield no stream when no stored result URI belongs to the 
operator" in {
@@ -606,11 +560,7 @@ class ResultExportServiceSpec
     insertResultUri(execution.getEid, resultUriOf(execution.getEid, 
"other-op"))
 
     val op = OperatorExportInfo("op-1", "csv")
-    val (stream, fileName) =
-      exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op)
-
-    stream shouldBe null
-    fileName shouldBe None
+    exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op) 
shouldBe None
   }
 
   it should "round-trip CSV special characters through the streamed export" in 
{
@@ -619,10 +569,11 @@ class ResultExportServiceSpec
     storeResult(execution.getEid, "rexs-special", Seq(tupleOf(special, 42)))
 
     val op = OperatorExportInfo("rexs-special", "csv")
-    val (stream, fileName) =
-      exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op)
+    val (stream, fileName) = exportService
+      .exportOperatorResultAsStream(dbRequestWith(List(op)), op)
+      .getOrElse(fail("expected a stream"))
 
-    fileName.getOrElse(fail("expected a file name")) should fullyMatch regex
+    fileName should fullyMatch regex
       s"""wf-oprexs-special-v${testVersion.getVid}-$timestampPattern\\.csv"""
 
     val out = new ByteArrayOutputStream()
@@ -640,12 +591,8 @@ class ResultExportServiceSpec
     insertExecution() // newer, and it registered no result
 
     val op = OperatorExportInfo("rexs-latest", "csv")
-    val (stream, fileName) =
-      exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op)
-
     // The older execution's rows must not leak into the newest execution's 
export.
-    stream shouldBe null
-    fileName shouldBe None
+    exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op) 
shouldBe None
   }
 
   it should "read the newest execution's rows when several executions stored 
results" in {
@@ -655,8 +602,9 @@ class ResultExportServiceSpec
     storeResult(newer.getEid, "rexs-latest2", Seq(tupleOf("new", 2)))
 
     val op = OperatorExportInfo("rexs-latest2", "csv")
-    val (stream, _) =
-      exportService.exportOperatorResultAsStream(dbRequestWith(List(op)), op)
+    val (stream, _) = exportService
+      .exportOperatorResultAsStream(dbRequestWith(List(op)), op)
+      .getOrElse(fail("expected a stream"))
 
     val out = new ByteArrayOutputStream()
     stream.write(out)
@@ -676,7 +624,9 @@ class ResultExportServiceSpec
     val op = OperatorExportInfo("rexs-cell", "data")
     val request =
       dbRequestWith(List(op)).copy(rowIndex = rowIndex, columnIndex = 
columnIndex)
-    val (stream, _) = exportService.exportOperatorResultAsStream(request, op)
+    val (stream, _) = exportService
+      .exportOperatorResultAsStream(request, op)
+      .getOrElse(fail("expected a stream"))
     val out = new ByteArrayOutputStream()
     stream.write(out)
     out
@@ -817,7 +767,7 @@ class ResultExportServiceSpec
     )
 
     // Deliberate asymmetry with exportOperatorResultAsStream, which reports 
the
-    // same condition as (null, None) and leaves the failure to its caller.
+    // same condition as None and leaves the failure to its caller.
     val ex = intercept[WebApplicationException] {
       exportService.exportOperatorsAsZip(request)
     }
@@ -841,8 +791,7 @@ class ResultExportServiceSpec
     )
 
     val (stream, zipName) = exportService.exportOperatorsAsZip(request)
-    zipName.getOrElse(fail("expected a zip file name")) should fullyMatch regex
-      s"""wf-$timestampPattern\\.zip"""
+    zipName should fullyMatch regex s"""wf-$timestampPattern\\.zip"""
 
     val body = new ByteArrayOutputStream()
     stream.write(body)
diff --git 
a/amber/src/test/scala/org/apache/texera/web/service/WorkflowServiceSpec.scala 
b/amber/src/test/scala/org/apache/texera/web/service/WorkflowServiceSpec.scala
index 4c1e8549b8..c26dd76d0b 100644
--- 
a/amber/src/test/scala/org/apache/texera/web/service/WorkflowServiceSpec.scala
+++ 
b/amber/src/test/scala/org/apache/texera/web/service/WorkflowServiceSpec.scala
@@ -144,12 +144,6 @@ import scala.collection.mutable.ArrayBuffer
   *   - the fault-tolerance block of `initExecutionService`, gated on
   *     `ApplicationConfig.faultToleranceLogRootFolder`: a `val` on a Scala 
`object` with no
   *     override seam, read at class-initialization time in a JVM shared with 
every other suite.
-  *   - `lastCompletedLogicalPlan` and the constructor's 
`executionService.subscribe` block that
-  *     maintains it. Nothing in the repository ever reads that field, so a 
test could only assert
-  *     which plan a write-only var holds — cementing code that should be 
deleted instead. Worth
-  *     knowing if it ever acquires a reader: the completion diff handler runs 
only while something
-  *     consumes the metadata store's websocket-event stream, so the snapshot 
silently does not
-  *     happen when no client is connected.
   *   - `resolveLakekeeperWarehouseName`, owned by 
`WorkflowServiceWarehouseSpec`.
   */
 class WorkflowServiceSpec

Reply via email to