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-9675-aefc7ec5408f37b4ab0ce432e033c52962be963c
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 111350d47dcb532812fb63ce3ee4b060e7f39573
Author: Xinyuan Lin <[email protected]>
AuthorDate: Wed Nov 25 01:05:23 2026 +0000

    test(verify): share harness and comparator spec fixtures (#9675)
    
    ### What changes were proposed in this PR?
    The three specs that check the translator's verification harness
    repeated their fixtures in every case. Each spec now shares them:
    
    - `PyOpExecHarnessSpec` builds its test operators from one parameterized
    Python descriptor in place of seven single-purpose classes. Shared
    helpers write the input port, run the operator and read the output
    column.
    - `HarnessSpec` builds rows with `rowOf` and `twoColRows`.
    `runStandalone` writes the input, runs `StandaloneRunner` in a
    `standalone` work directory and returns the output lines. `blobKind` now
    uses that directory too, as the other cases already did.
    - `ComparatorSpec` writes typed JSONL with `writeTyped` and checks
    results with `assertEqualOk` and `assertMismatch`. `runPythonScript`
    starts Python through `PyOpExecHarness.resolvePython()`, so without
    `UDF_PYTHON_PATH` the spec now falls back to `python3.12`, as
    `Comparator` does; on main it fell back to `python3`. Four helpers write
    and check the Plotly cases.
    
    Every test keeps its name, its position, its inputs and its expected
    values. Only test code changes.
    
    ### Any related issues, documentation, discussions?
    Closes #9674.
    
    ### How was this PR tested?
    - `sbt "WorkflowCompilingService/test"`, with `UDF_PYTHON_PATH` pointing
    at Python 3.12 and amber's Python bindings generated as
    `bin/python-proto-gen.sh` does: 152 tests across 11 suites pass on main
    and on this branch. The two runs have the same names in the same order,
    compared case by case from the JUnit XML reports.
    - Mutation check, run the same way on main and on this branch. Three
    mutations go in together: `PyOpExecHarness` drives every operator as a
    source, `StandaloneRunner` leaves a holed boolean column as float64 and
    a plain binary cell as base64 text, and `Comparator` inverts
    `orderSensitive`. The same 12 of the 50 tests in the three specs fail on
    both (7 in `PyOpExecHarnessSpec`, 3 in `ComparatorSpec`, 2 in
    `HarnessSpec`), and every other test passes.
    - `sbt "WorkflowCompilingService/scalafmtCheck"
    "WorkflowCompilingService/Test/scalafmtCheck"
    "WorkflowCompilingService/scalafix --check"
    "WorkflowCompilingService/Test/scalafix --check"`
    - After review, b692a54d5f changes only the interpreter
    `runPythonScript` uses. `ComparatorSpec` passes 31/31 on it with the
    same names in the same order, and `Test/scalafmtCheck` and
    `Test/scalafix --check` pass.
    
    ### Was this PR authored or co-authored using generative AI tooling?
    Generated-by: Antigravity (Gemini) and Claude Code (Claude Opus 5.5)
---
 .../amber/translator/verify/ComparatorSpec.scala   | 529 +++++++++------------
 .../amber/translator/verify/HarnessSpec.scala      | 221 +++------
 .../translator/verify/PyOpExecHarnessSpec.scala    | 477 ++++++++-----------
 3 files changed, 487 insertions(+), 740 deletions(-)

diff --git 
a/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/ComparatorSpec.scala
 
b/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/ComparatorSpec.scala
index da41526c34..44e1311010 100644
--- 
a/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/ComparatorSpec.scala
+++ 
b/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/ComparatorSpec.scala
@@ -48,12 +48,37 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
       .add(nameAttr, name)
       .build()
 
+  private def tempDir(suffix: String): Path =
+    Files.createTempDirectory(s"comparator-spec-$suffix-")
+
   private def writeJsonl(dir: Path, name: String, rows: Seq[Tuple]): Path = {
     val p = dir.resolve(name)
     TupleIO.writeTuples(p, rows.iterator, schema)
     p
   }
 
+  private def writeTyped(
+      dir: Path,
+      name: String,
+      attrs: Seq[(String, AttributeType)],
+      rows: Seq[Seq[AnyRef]]
+  ): Path = {
+    val typedSchema = attrs.foldLeft(Schema()) {
+      case (s, (col, tpe)) => s.add(new Attribute(col, tpe))
+    }
+    val p = dir.resolve(name)
+    val tuples = rows.map { values =>
+      attrs
+        .zip(values)
+        .foldLeft(Tuple.builder(typedSchema)) {
+          case (builder, ((col, _), value)) => 
builder.add(typedSchema.getAttribute(col), value)
+        }
+        .build()
+    }
+    TupleIO.writeTuples(p, tuples.iterator, typedSchema)
+    p
+  }
+
   // Written by hand rather than through TupleIO: these cases need a column set
   // the fixed schema above does not carry.
   private def writeLines(dir: Path, name: String, lines: Seq[String]): Path = {
@@ -62,140 +87,131 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
     p
   }
 
+  private def assertEqualOk(
+      actual: Path,
+      expected: Path,
+      orderSensitive: Boolean = true,
+      modelColumns: Seq[String] = Seq.empty,
+      probePath: Option[Path] = None
+  ): Unit =
+    noException should be thrownBy Comparator.assertEqual(
+      actual,
+      expected,
+      orderSensitive = orderSensitive,
+      modelColumns = modelColumns,
+      probePath = probePath
+    )
+
+  private def assertMismatch(
+      actual: Path,
+      expected: Path,
+      orderSensitive: Boolean = true,
+      modelColumns: Seq[String] = Seq.empty,
+      probePath: Option[Path] = None
+  ): String =
+    intercept[ComparatorMismatchException] {
+      Comparator.assertEqual(
+        actual,
+        expected,
+        orderSensitive = orderSensitive,
+        modelColumns = modelColumns,
+        probePath = probePath
+      )
+    }.getMessage
+
   "Comparator.assertEqual" should "pass when JSONL files contain identical 
rows" in {
-    val dir = Files.createTempDirectory("comparator-spec-equal-")
+    val dir = tempDir("equal")
     val rows = Seq(row(1, "alice"), row(2, "bob"))
-    val a = writeJsonl(dir, "a.jsonl", rows)
-    val b = writeJsonl(dir, "b.jsonl", rows)
-    noException should be thrownBy Comparator.assertEqual(a, b)
+    assertEqualOk(writeJsonl(dir, "a.jsonl", rows), writeJsonl(dir, "b.jsonl", 
rows))
   }
 
   it should "throw ComparatorMismatchException when JSONL files differ" in {
-    val dir = Files.createTempDirectory("comparator-spec-diff-")
-    val a = writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob")))
-    val b = writeJsonl(dir, "b.jsonl", Seq(row(1, "alice"), row(2, "carol")))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }
+    val dir = tempDir("diff")
+    assertMismatch(
+      writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob"))),
+      writeJsonl(dir, "b.jsonl", Seq(row(1, "alice"), row(2, "carol")))
+    )
   }
 
   it should "treat row-reordered files as unequal under positional comparison" 
in {
-    val dir = Files.createTempDirectory("comparator-spec-reorder-strict-")
-    val a = writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob")))
-    val b = writeJsonl(dir, "b.jsonl", Seq(row(2, "bob"), row(1, "alice")))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }
+    val dir = tempDir("reorder-strict")
+    assertMismatch(
+      writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob"))),
+      writeJsonl(dir, "b.jsonl", Seq(row(2, "bob"), row(1, "alice")))
+    )
   }
 
   it should "treat row-reordered files as equal under orderSensitive=false" in 
{
-    val dir = Files.createTempDirectory("comparator-spec-reorder-loose-")
-    val a = writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob")))
-    val b = writeJsonl(dir, "b.jsonl", Seq(row(2, "bob"), row(1, "alice")))
-    noException should be thrownBy Comparator.assertEqual(a, b, orderSensitive 
= false)
+    val dir = tempDir("reorder-loose")
+    assertEqualOk(
+      writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob"))),
+      writeJsonl(dir, "b.jsonl", Seq(row(2, "bob"), row(1, "alice"))),
+      orderSensitive = false
+    )
   }
 
   it should "still report value mismatches under orderSensitive=false" in {
     // orderSensitive=false relaxes row ORDER, not row CONTENT — a genuinely
     // different cell must still fail.
-    val dir = 
Files.createTempDirectory("comparator-spec-reorder-content-diff-")
-    val a = writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob")))
-    val b = writeJsonl(dir, "b.jsonl", Seq(row(2, "bob"), row(1, "carol")))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b, orderSensitive = false)
-    }
+    val dir = tempDir("reorder-content-diff")
+    assertMismatch(
+      writeJsonl(dir, "a.jsonl", Seq(row(1, "alice"), row(2, "bob"))),
+      writeJsonl(dir, "b.jsonl", Seq(row(2, "bob"), row(1, "carol"))),
+      orderSensitive = false
+    )
   }
 
   // Sorting on the float first paired 1.0 with 1.0 across the two sides, which
   // put "a" beside "b". The exact column has to decide the pairing.
   it should "pair rows by their exact columns before a float under 
orderSensitive=false" in {
-    val dir = Files.createTempDirectory("comparator-spec-reorder-float-")
+    val dir = tempDir("reorder-float")
     val a = writeLines(dir, "a.jsonl", Seq("""{"x":1.0,"s":"a"}""", 
"""{"x":1.000001,"s":"b"}"""))
     val b = writeLines(dir, "b.jsonl", Seq("""{"x":1.000001,"s":"a"}""", 
"""{"x":1.0,"s":"b"}"""))
-    noException should be thrownBy Comparator.assertEqual(a, b, orderSensitive 
= false)
+    assertEqualOk(a, b, orderSensitive = false)
   }
 
   // With no exact column, sorting on x put 1.0 first on both sides, which put
   // y = 10.0 beside y = 100.0. Rows are paired within tolerance on every 
float.
   it should "pair rows within tolerance across every float under 
orderSensitive=false" in {
-    val dir = Files.createTempDirectory("comparator-spec-reorder-two-floats-")
-    val doubles = Schema()
-      .add(new Attribute("x", AttributeType.DOUBLE))
-      .add(new Attribute("y", AttributeType.DOUBLE))
-    def write(name: String, rows: Seq[(Double, Double)]): Path = {
-      val p = dir.resolve(name)
-      val tuples = rows.map {
-        case (x, y) =>
-          Tuple
-            .builder(doubles)
-            .add(doubles.getAttribute("x"), Double.box(x))
-            .add(doubles.getAttribute("y"), Double.box(y))
-            .build()
-      }
-      TupleIO.writeTuples(p, tuples.iterator, doubles)
-      p
-    }
+    val dir = tempDir("reorder-two-floats")
+    val attrs = Seq("x" -> AttributeType.DOUBLE, "y" -> AttributeType.DOUBLE)
+    def write(name: String, rows: Seq[(Double, Double)]): Path =
+      writeTyped(dir, name, attrs, rows.map { case (x, y) => 
Seq(Double.box(x), Double.box(y)) })
     val a = write("a.jsonl", Seq((1.0, 10.0), (1.000001, 100.0)))
-    noException should be thrownBy Comparator.assertEqual(
-      a,
-      write("b.jsonl", Seq((1.000001, 10.0), (1.0, 100.0))),
-      orderSensitive = false
-    )
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(
-        a,
-        write("c.jsonl", Seq((1.000001, 10.0), (1.0, 99.0))),
-        orderSensitive = false
-      )
-    }
+    assertEqualOk(a, write("b.jsonl", Seq((1.000001, 10.0), (1.0, 100.0))), 
orderSensitive = false)
+    assertMismatch(a, write("c.jsonl", Seq((1.000001, 10.0), (1.0, 99.0))), 
orderSensitive = false)
   }
 
   // The tolerance a double needs was being applied to integers as well, so two
   // whole numbers a workflow would never call the same compared equal. The
   // declared type is what separates them: a double keeps the tolerance.
-  private val longSchema: Schema = Schema().add(new Attribute("n", 
AttributeType.LONG))
-
-  private def writeLongs(dir: Path, name: String, values: 
Seq[java.lang.Long]): Path = {
-    val p = dir.resolve(name)
-    val rows =
-      values.map(v => 
Tuple.builder(longSchema).add(longSchema.getAttribute("n"), v).build())
-    TupleIO.writeTuples(p, rows.iterator, longSchema)
-    p
-  }
+  private def writeLongs(dir: Path, name: String, values: 
Seq[java.lang.Long]): Path =
+    writeTyped(dir, name, Seq("n" -> AttributeType.LONG), values.map(v => 
Seq[AnyRef](v)))
 
   it should "reject two integers the float tolerance would have accepted" in {
-    val dir = Files.createTempDirectory("comparator-spec-long-tolerance-")
-    val a = writeLongs(dir, "a.jsonl", Seq(100000L))
-    val b = writeLongs(dir, "b.jsonl", Seq(100001L))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }
+    val dir = tempDir("long-tolerance")
+    assertMismatch(
+      writeLongs(dir, "a.jsonl", Seq(100000L)),
+      writeLongs(dir, "b.jsonl", Seq(100001L))
+    )
   }
 
   it should "reject a nullable integer that only a rounding read made equal" 
in {
     // A null widens the column to float on the way into pandas, and 
9007199254740993
     // is already 9007199254740992 before anything compares it.
-    val dir = Files.createTempDirectory("comparator-spec-long-precision-")
-    val a = writeLongs(dir, "a.jsonl", Seq(9007199254740993L, null))
-    val b = writeLongs(dir, "b.jsonl", Seq(9007199254740992L, null))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }
+    val dir = tempDir("long-precision")
+    assertMismatch(
+      writeLongs(dir, "a.jsonl", Seq(9007199254740993L, null)),
+      writeLongs(dir, "b.jsonl", Seq(9007199254740992L, null))
+    )
   }
 
   it should "keep the tolerance a double needs" in {
-    val dir = Files.createTempDirectory("comparator-spec-double-tolerance-")
-    val doubleSchema = Schema().add(new Attribute("x", AttributeType.DOUBLE))
-    def write(name: String, v: Double): Path = {
-      val p = dir.resolve(name)
-      val row =
-        Tuple.builder(doubleSchema).add(doubleSchema.getAttribute("x"), 
Double.box(v)).build()
-      TupleIO.writeTuples(p, Iterator(row), doubleSchema)
-      p
-    }
-    noException should be thrownBy Comparator.assertEqual(
-      write("a.jsonl", 1.000001),
-      write("b.jsonl", 1.0000011)
+    val dir = tempDir("double-tolerance")
+    val attrs = Seq("x" -> AttributeType.DOUBLE)
+    assertEqualOk(
+      writeTyped(dir, "a.jsonl", attrs, Seq(Seq(Double.box(1.000001)))),
+      writeTyped(dir, "b.jsonl", attrs, Seq(Seq(Double.box(1.0000011))))
     )
   }
 
@@ -203,12 +219,10 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
     // This passed on the grounds that 6.0 and 6 spell the same integer. They 
do
     // not survive the same: a later cast to text writes "6" from one and "6.0"
     // from the other.
-    val dir = Files.createTempDirectory("comparator-spec-int-spelling-")
+    val dir = tempDir("int-spelling")
     val a = writeLongs(dir, "a.jsonl", Seq(6L))
     val b = writeLines(dir, "b.jsonl", Seq("""{"n":6.0}"""))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }.getMessage should include("the two sides wrote it differently")
+    assertMismatch(a, b) should include("the two sides wrote it differently")
   }
 
   it should "accept an integer column both sides widened alike" in {
@@ -216,42 +230,35 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
     // pandas too, so a hole widens the column on both paths and the two still
     // agree. What is asked here is whether the paths match, not whether pandas
     // kept the type.
-    val dir = Files.createTempDirectory("comparator-spec-int-both-widened-")
+    val dir = tempDir("int-both-widened")
     // writeLongs for the schema sidecar it leaves; the rows are then rewritten
     // as the widened form both paths would have produced. The null is the hole
     // that widened it, and float64 has to hold it too.
     val a = writeLongs(dir, "a.jsonl", Seq(6L, null))
     Files.writeString(a, "{\"n\":6.0}\n{\"n\":null}\n")
     val b = writeLines(dir, "b.jsonl", Seq("""{"n":6.0}""", """{"n":null}"""))
-    noException should be thrownBy Comparator.assertEqual(a, b)
+    assertEqualOk(a, b)
   }
 
   // The comparison took its columns from the actual side and selected those 
out
   // of the expected one, so a column only the expected side carried was never
   // looked at.
   it should "report a column only one side carries" in {
-    val dir = Files.createTempDirectory("comparator-spec-extra-column-")
+    val dir = tempDir("extra-column")
     val a = writeLines(dir, "a.jsonl", Seq("""{"id":1,"name":"alice"}"""))
     val b = writeLines(dir, "b.jsonl", 
Seq("""{"id":1,"name":"alice","extra":9}"""))
 
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }.getMessage should include("only in expected")
-
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(b, a)
-    }.getMessage should include("only in actual")
+    assertMismatch(a, b) should include("only in expected")
+    assertMismatch(b, a) should include("only in actual")
   }
 
   // Column order is part of the schema: it decides what a positional UDF 
reads,
   // what a file export writes, and what code asking for the first column gets.
   it should "treat column-reordered files as unequal" in {
-    val dir = Files.createTempDirectory("comparator-spec-column-order-")
+    val dir = tempDir("column-order")
     val a = writeLines(dir, "a.jsonl", Seq("""{"a":1,"b":2}"""))
     val b = writeLines(dir, "b.jsonl", Seq("""{"b":2,"a":1}"""))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }.getMessage should include("different order")
+    assertMismatch(a, b) should include("different order")
   }
 
   // Reading both sides with `dtype=str` settles them on one spelling, which a
@@ -259,141 +266,87 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
   // a side that wrote a number where the engine declared text compared equal 
to
   // the text. What the file actually holds is what separates them.
   it should "reject a number written where the schema declares text" in {
-    val dir = Files.createTempDirectory("comparator-spec-text-number-")
-    val textSchema = Schema().add(new Attribute("code", AttributeType.STRING))
-    val a = dir.resolve("a.jsonl")
-    TupleIO.writeTuples(
-      a,
-      Iterator(Tuple.builder(textSchema).add(textSchema.getAttribute("code"), 
"6").build()),
-      textSchema
-    )
+    val dir = tempDir("text-number")
+    val a = writeTyped(dir, "a.jsonl", Seq("code" -> AttributeType.STRING), 
Seq(Seq("6")))
     val b = writeLines(dir, "b.jsonl", Seq("""{"code":6}"""))
 
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }.getMessage should include("declared text but holds 6")
+    assertMismatch(a, b) should include("declared text but holds 6")
   }
 
   // numpy counts True as 1 and the frame comparison is asked not to check
   // dtypes, so a column of booleans compared equal to a column of ones. The
   // engine says a BOOLEAN column holds true and false.
   it should "reject a number written where the schema declares a boolean" in {
-    val dir = Files.createTempDirectory("comparator-spec-bool-number-")
-    val boolSchema = Schema().add(new Attribute("flag", AttributeType.BOOLEAN))
-    val a = dir.resolve("a.jsonl")
-    TupleIO.writeTuples(
-      a,
-      Iterator(
-        Tuple.builder(boolSchema).add(boolSchema.getAttribute("flag"), 
Boolean.box(true)).build()
-      ),
-      boolSchema
-    )
+    val dir = tempDir("bool-number")
+    val a =
+      writeTyped(dir, "a.jsonl", Seq("flag" -> AttributeType.BOOLEAN), 
Seq(Seq(Boolean.box(true))))
     val b = writeLines(dir, "b.jsonl", Seq("""{"flag":1}"""))
 
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }.getMessage should include("the two sides wrote it differently")
+    assertMismatch(a, b) should include("the two sides wrote it differently")
   }
 
   it should "accept a boolean column both sides widened alike" in {
     // A hole costs a pandas boolean column its type on both paths alike, so
     // both write the true as 1.0 next to the null.
-    val dir = Files.createTempDirectory("comparator-spec-bool-both-widened-")
-    val boolSchema = Schema().add(new Attribute("flag", AttributeType.BOOLEAN))
-    val a = dir.resolve("a.jsonl")
-    TupleIO.writeTuples(
-      a,
-      Iterator(
-        Tuple.builder(boolSchema).add(boolSchema.getAttribute("flag"), 
Boolean.box(true)).build()
-      ),
-      boolSchema
-    )
+    val dir = tempDir("bool-both-widened")
+    val a =
+      writeTyped(dir, "a.jsonl", Seq("flag" -> AttributeType.BOOLEAN), 
Seq(Seq(Boolean.box(true))))
     Files.writeString(a, "{\"flag\":1.0}\n{\"flag\":null}\n")
     val b = writeLines(dir, "b.jsonl", Seq("""{"flag":1.0}""", 
"""{"flag":null}"""))
-    noException should be thrownBy Comparator.assertEqual(a, b)
+    assertEqualOk(a, b)
   }
 
   // Both files are UTF-8. Read with the platform's encoding, a text value
   // outside ASCII failed to decode, and a LONG column whose name is outside
   // ASCII lost its declared type and went back under the float tolerance.
   it should "read a name and a value outside ASCII as the UTF-8 they are" in {
-    val dir = Files.createTempDirectory("comparator-spec-utf8-")
-    val utf8Schema = Schema()
-      .add(new Attribute("é", AttributeType.LONG))
-      .add(new Attribute("v", AttributeType.STRING))
-    def write(name: String, n: Long): Path = {
-      val p = dir.resolve(name)
-      val row = Tuple
-        .builder(utf8Schema)
-        .add(utf8Schema.getAttribute("é"), Long.box(n))
-        .add(utf8Schema.getAttribute("v"), "ひ")
-        .build()
-      TupleIO.writeTuples(p, Iterator(row), utf8Schema)
-      p
-    }
+    val dir = tempDir("utf8")
+    val attrs = Seq("é" -> AttributeType.LONG, "v" -> AttributeType.STRING)
+    def write(name: String, n: Long): Path =
+      writeTyped(dir, name, attrs, Seq(Seq(Long.box(n), "ひ")))
     val a = write("a.jsonl", 100000L)
 
-    noException should be thrownBy Comparator.assertEqual(a, 
write("same.jsonl", 100000L))
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, write("b.jsonl", 100001L))
-    }.getMessage should include("100001")
+    assertEqualOk(a, write("same.jsonl", 100000L))
+    assertMismatch(a, write("b.jsonl", 100001L)) should include("100001")
   }
 
   // What kind of value each DOUBLE cell holds used to be added to the frame as
   // a column with a made-up name. An output column of that name was 
overwritten
   // on both sides alike, so a difference in it went unseen.
   it should "not let a DOUBLE column's kinds hide an output column" in {
-    val dir = Files.createTempDirectory("comparator-spec-double-kind-name-")
-    val collidingSchema = Schema()
-      .add(new Attribute("v", AttributeType.DOUBLE))
-      .add(new Attribute("v (null/NaN/±Infinity/-0.0)", AttributeType.STRING))
-    def write(name: String, text: String): Path = {
-      val p = dir.resolve(name)
-      val row = Tuple
-        .builder(collidingSchema)
-        .add(collidingSchema.getAttribute("v"), Double.box(1.0))
-        .add(collidingSchema.getAttribute("v (null/NaN/±Infinity/-0.0)"), text)
-        .build()
-      TupleIO.writeTuples(p, Iterator(row), collidingSchema)
-      p
-    }
-    val a = write("a.jsonl", "before")
-    val b = write("b.jsonl", "after")
+    val dir = tempDir("double-kind-name")
+    val attrs =
+      Seq("v" -> AttributeType.DOUBLE, "v (null/NaN/±Infinity/-0.0)" -> 
AttributeType.STRING)
+    val a = writeTyped(dir, "a.jsonl", attrs, Seq(Seq(Double.box(1.0), 
"before")))
+    val b = writeTyped(dir, "b.jsonl", attrs, Seq(Seq(Double.box(1.0), 
"after")))
 
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b)
-    }.getMessage should include("after")
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(a, b, orderSensitive = false)
-    }.getMessage should include("after")
+    assertMismatch(a, b) should include("after")
+    assertMismatch(a, b, orderSensitive = false) should include("after")
   }
 
   it should "report a model column only one side produced" in {
     // Model columns are compared by behavior and then dropped from both 
frames,
     // so a side that never wrote one has to fail here: once the column is 
gone,
     // the frame diff sees two identical column sets and passes.
-    val dir = Files.createTempDirectory("comparator-spec-model-missing-")
+    val dir = tempDir("model-missing")
     val withModel = writeLines(dir, "with-model.jsonl", 
Seq("""{"model":"eA==","score":1.0}"""))
     val withoutModel = writeLines(dir, "without-model.jsonl", 
Seq("""{"score":1.0}"""))
     val probe = writeLines(dir, "probe.jsonl", 
Seq("""{"petal_length":1.0,"label":0}"""))
 
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(
-        withModel,
-        withoutModel,
-        modelColumns = Seq("model"),
-        probePath = Some(probe)
-      )
-    }.getMessage should include("missing from expected")
-
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(
-        withoutModel,
-        withModel,
-        modelColumns = Seq("model"),
-        probePath = Some(probe)
-      )
-    }.getMessage should include("missing from actual")
+    assertMismatch(
+      withModel,
+      withoutModel,
+      modelColumns = Seq("model"),
+      probePath = Some(probe)
+    ) should
+      include("missing from expected")
+    assertMismatch(
+      withoutModel,
+      withModel,
+      modelColumns = Seq("model"),
+      probePath = Some(probe)
+    ) should
+      include("missing from actual")
   }
 
   /** A model column holds a pickled estimator, which only Python can fit. 
Writes
@@ -428,17 +381,22 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
     (dir.resolve("actual.jsonl"), dir.resolve("expected.jsonl"), 
dir.resolve("probe.jsonl"))
   }
 
+  private def runPythonScript(script: Path, args: String*): (Int, String) = {
+    val python = PyOpExecHarness.resolvePython()
+    val process = new ProcessBuilder((python +: script.toString +: args): _*)
+      .redirectErrorStream(true)
+      .start()
+    val said = Source.fromInputStream(process.getInputStream).mkString
+    process.waitFor(120, TimeUnit.SECONDS)
+    (process.exitValue(), said)
+  }
+
   private def runPython(program: String): Unit = {
     val script = Files.createTempFile("comparator-spec-fit-", ".py")
     script.toFile.deleteOnExit()
     Files.writeString(script, program)
-
-    val python = 
sys.env.get("UDF_PYTHON_PATH").filter(_.nonEmpty).getOrElse("python3")
-    val process =
-      new ProcessBuilder(python, 
script.toString).redirectErrorStream(true).start()
-    val said = Source.fromInputStream(process.getInputStream).mkString
-    process.waitFor(120, TimeUnit.SECONDS)
-    require(process.exitValue() == 0, s"fitting the models failed:\n$said")
+    val (exit, said) = runPythonScript(script)
+    require(exit == 0, s"fitting the models failed:\n$said")
   }
 
   // A classifier predicts a class, and a class that changed is a different
@@ -446,24 +404,17 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
   // numeric tolerance, where 100000 and 100001 are one part in 1e5 apart and
   // compared equal, so every row's class could change and the models still 
pass.
   it should "catch a classifier whose predicted classes all changed" in {
-    val dir = Files.createTempDirectory("comparator-spec-model-classes-")
+    val dir = tempDir("model-classes")
     val (actual, expected, probe) =
       writeFittedModels(dir, "DecisionTreeClassifier", "[100000] * 3", 
"[100001] * 3")
-
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(
-        actual,
-        expected,
-        modelColumns = Seq("model"),
-        probePath = Some(probe)
-      )
-    }.getMessage should include("predictions differ")
+    assertMismatch(actual, expected, modelColumns = Seq("model"), probePath = 
Some(probe)) should
+      include("predictions differ")
   }
 
   // What a model was fitted on is part of the model. Two fitted on different
   // columns answer alike on a probe carrying both, so only the names part 
them.
   it should "catch two models fitted on different columns that predict alike" 
in {
-    val dir = Files.createTempDirectory("comparator-spec-model-features-")
+    val dir = tempDir("model-features")
     val (actual, expected, probe) =
       writeFittedModels(
         dir,
@@ -472,21 +423,14 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
         "[0, 1, 1]",
         expectedFeature = "petal_width"
       )
-
-    intercept[ComparatorMismatchException] {
-      Comparator.assertEqual(
-        actual,
-        expected,
-        modelColumns = Seq("model"),
-        probePath = Some(probe)
-      )
-    }.getMessage should include("fitted feature names differ")
+    assertMismatch(actual, expected, modelColumns = Seq("model"), probePath = 
Some(probe)) should
+      include("fitted feature names differ")
   }
 
   // The tolerance still has to reach what it was for: a regressor computes its
   // answer, so the two paths can land a float's last bits apart on the same 
fit.
   it should "allow a regressor's predictions to differ within tolerance" in {
-    val dir = Files.createTempDirectory("comparator-spec-model-regressor-")
+    val dir = tempDir("model-regressor")
     val (actual, expected, probe) =
       writeFittedModels(
         dir,
@@ -494,19 +438,13 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
         "[1.0, 2.0, 3.0]",
         "[1.0, 2.0, 3.0 + 1e-12]"
       )
-
-    noException should be thrownBy Comparator.assertEqual(
-      actual,
-      expected,
-      modelColumns = Seq("model"),
-      probePath = Some(probe)
-    )
+    assertEqualOk(actual, expected, modelColumns = Seq("model"), probePath = 
Some(probe))
   }
 
   // Unordered rows were paired only after the models had been compared by
   // position, so a model could change rows and still pass.
   it should "keep each model beside its row under orderSensitive=false" in {
-    val dir = Files.createTempDirectory("comparator-spec-model-unordered-")
+    val dir = tempDir("model-unordered")
     runPython(
       s"""import base64, json, pickle
          |import pandas as pd
@@ -565,79 +503,56 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
     require(stream != null, "compare.py not found at /python/compare.py")
     try Files.copy(stream, script, StandardCopyOption.REPLACE_EXISTING)
     finally stream.close()
-
-    val python = 
sys.env.get("UDF_PYTHON_PATH").filter(_.nonEmpty).getOrElse("python3")
-    val process = new ProcessBuilder(
-      python,
-      script.toString,
-      "--plotly",
-      actual.toString,
-      expected.toString
-    ).redirectErrorStream(true).start()
-    val said = Source.fromInputStream(process.getInputStream).mkString
-    process.waitFor(120, TimeUnit.SECONDS)
-    (process.exitValue(), said)
+    runPythonScript(script, "--plotly", actual.toString, expected.toString)
   }
 
-  "Comparator's plotly comparison" should "read every chart on both sides" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-all-")
-    val actual = writeLines(
-      dir,
-      "actual.jsonl",
-      Seq(1, 2, 3).map(v => s"""{"json-content": ${plotlyFigure(v)}}""")
-    )
-    val expected = writeLines(
-      dir,
-      "expected.json",
-      Seq(Seq(1, 2, 3).map(plotlyFigure).mkString("[", ",", "]"))
-    )
+  private def writePlotlyRows(dir: Path, values: Int*): Path =
+    writeLines(dir, "actual.jsonl", values.map(v => s"""{"json-content": 
${plotlyFigure(v)}}"""))
+
+  private def writePlotlyArray(dir: Path, values: Int*): Path =
+    writeLines(dir, "expected.json", 
Seq(values.map(plotlyFigure).mkString("[", ",", "]")))
+
+  private def assertPlotlyPass(actual: Path, expected: Path): Unit = {
     val (exit, said) = runPlotly(actual, expected)
     withClue(s"compare.py said:\n$said") { exit shouldBe 0 }
   }
 
-  it should "catch a chart that differs after the first" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-second-")
-    val actual = writeLines(
-      dir,
-      "actual.jsonl",
-      Seq(1, 2, 3).map(v => s"""{"json-content": ${plotlyFigure(v)}}""")
-    )
-    val expected = writeLines(
-      dir,
-      "expected.json",
-      Seq(Seq(1, 99, 3).map(plotlyFigure).mkString("[", ",", "]"))
-    )
+  private def assertPlotlyFail(actual: Path, expected: Path, expectedSnippets: 
String*): Unit = {
     val (exit, said) = runPlotly(actual, expected)
     withClue(s"compare.py said:\n$said") {
       exit should not be 0
-      said should include("chart 2 of 3")
+      expectedSnippets.foreach(said should include(_))
     }
   }
 
+  "Comparator's plotly comparison" should "read every chart on both sides" in {
+    val dir = tempDir("plotly-all")
+    assertPlotlyPass(writePlotlyRows(dir, 1, 2, 3), writePlotlyArray(dir, 1, 
2, 3))
+  }
+
+  it should "catch a chart that differs after the first" in {
+    val dir = tempDir("plotly-second")
+    assertPlotlyFail(writePlotlyRows(dir, 1, 2, 3), writePlotlyArray(dir, 1, 
99, 3), "chart 2 of 3")
+  }
+
   it should "catch an exported script that drew fewer charts than the run" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-count-")
-    val actual = writeLines(
-      dir,
-      "actual.jsonl",
-      Seq(1, 2, 3).map(v => s"""{"json-content": ${plotlyFigure(v)}}""")
+    val dir = tempDir("plotly-count")
+    assertPlotlyFail(
+      writePlotlyRows(dir, 1, 2, 3),
+      writeLines(dir, "expected.json", Seq(plotlyFigure(1))),
+      "drew 3",
+      "drew 1"
     )
-    val expected = writeLines(dir, "expected.json", Seq(plotlyFigure(1)))
-    val (exit, said) = runPlotly(actual, expected)
-    withClue(s"compare.py said:\n$said") {
-      exit should not be 0
-      said should include("drew 3")
-      said should include("drew 1")
-    }
   }
 
   // The operators that draw one chart write a lone figure, and there are far
   // more of those than there are of the other kind.
   it should "still read a lone figure as the one chart it is" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-one-")
-    val actual = writeLines(dir, "actual.jsonl", Seq(s"""{"json-content": 
${plotlyFigure(7)}}"""))
-    val expected = writeLines(dir, "expected.json", Seq(plotlyFigure(7)))
-    val (exit, said) = runPlotly(actual, expected)
-    withClue(s"compare.py said:\n$said") { exit shouldBe 0 }
+    val dir = tempDir("plotly-one")
+    assertPlotlyPass(
+      writePlotlyRows(dir, 7),
+      writeLines(dir, "expected.json", Seq(plotlyFigure(7)))
+    )
   }
 
   // A bullet or gauge chart draws its charts onto one page and yields that 
page
@@ -659,29 +574,27 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
   }
 
   it should "read every chart on a page the run drew as one row" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-page-")
-    val actual = writeLines(dir, "actual.jsonl", Seq(plotlyPageRow(1, 2, 3)))
-    val expected = writeLines(dir, "expected.html", Seq(plotlyPage(1, 2, 3)))
-    val (exit, said) = runPlotly(actual, expected)
-    withClue(s"compare.py said:\n$said") { exit shouldBe 0 }
+    val dir = tempDir("plotly-page")
+    assertPlotlyPass(
+      writeLines(dir, "actual.jsonl", Seq(plotlyPageRow(1, 2, 3))),
+      writeLines(dir, "expected.html", Seq(plotlyPage(1, 2, 3)))
+    )
   }
 
   it should "catch a chart after the first on a page the script wrote" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-page-second-")
-    val actual = writeLines(dir, "actual.jsonl", Seq(plotlyPageRow(1, 2, 3)))
-    val expected = writeLines(dir, "expected.html", Seq(plotlyPage(1, 99, 3)))
-    val (exit, said) = runPlotly(actual, expected)
-    withClue(s"compare.py said:\n$said") {
-      exit should not be 0
-      said should include("chart 2 of 3")
-    }
+    val dir = tempDir("plotly-page-second")
+    assertPlotlyFail(
+      writeLines(dir, "actual.jsonl", Seq(plotlyPageRow(1, 2, 3))),
+      writeLines(dir, "expected.html", Seq(plotlyPage(1, 99, 3))),
+      "chart 2 of 3"
+    )
   }
 
   // `bool` is a subclass of `int` in Python, so a boolean setting fell into 
the
   // numeric branch and True compared equal to 1. A column whose declared type
   // changed from boolean to integer reaches a figure as exactly that.
   it should "treat a boolean setting and the number 1 as different" in {
-    val dir = Files.createTempDirectory("comparator-spec-plotly-bool-")
+    val dir = tempDir("plotly-bool")
     val actual = writeLines(
       dir,
       "actual.jsonl",
@@ -694,9 +607,7 @@ class ComparatorSpec extends AnyFlatSpec with Matchers {
         Seq(s"""{"data": [{"visible": $visible}], "layout": {}}""")
       )
 
-    val (asNumber, said) = runPlotly(actual, expected("1"))
-    withClue(s"compare.py said:\n$said") { asNumber should not be 0 }
-    val (asBoolean, alsoSaid) = runPlotly(actual, expected("true"))
-    withClue(s"compare.py said:\n$alsoSaid") { asBoolean shouldBe 0 }
+    assertPlotlyFail(actual, expected("1"))
+    assertPlotlyPass(actual, expected("true"))
   }
 }
diff --git 
a/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/HarnessSpec.scala
 
b/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/HarnessSpec.scala
index 35675b5907..a29fc1e72f 100644
--- 
a/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/HarnessSpec.scala
+++ 
b/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/HarnessSpec.scala
@@ -54,13 +54,44 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
     new Attribute("name", AttributeType.STRING)
   )
 
-  private def tuple(id: Int, name: String): Tuple = {
-    val b = Tuple.builder(schema)
-    b.add(schema.getAttribute("id"), Int.box(id))
-    b.add(schema.getAttribute("name"), name)
+  private def rowOf(rowSchema: Schema)(values: (String, Any)*): Tuple = {
+    val b = Tuple.builder(rowSchema)
+    values.foreach { case (col, value) => b.add(rowSchema.getAttribute(col), 
value) }
     b.build()
   }
 
+  private def twoColRows(col: String, attrType: AttributeType)(
+      entries: (Int, Any)*
+  ): (Schema, Seq[Tuple]) = {
+    val s = new Schema(new Attribute("id", AttributeType.INTEGER), new 
Attribute(col, attrType))
+    (s, entries.map { case (id, value) => rowOf(s)("id" -> Int.box(id), col -> 
value) })
+  }
+
+  private def runStandalone(
+      prefix: String,
+      rowSchema: Schema,
+      inputRows: Seq[Tuple],
+      opDesc: LogicalOp with StandaloneCodeGenerator = new DistinctOpDesc,
+      outputSchemas: Map[PortIdentity, Schema] = Map.empty
+  ): (Path, java.util.List[String]) = {
+    val dir = Files.createTempDirectory(prefix)
+    val input = dir.resolve("input_port_0.jsonl")
+    TupleIO.writeTuples(input, inputRows.iterator, rowSchema)
+    val work = dir.resolve("standalone")
+    Files.createDirectories(work)
+    val result = StandaloneRunner.run(
+      opDesc = opDesc,
+      inputs = Map(1 -> input),
+      outputPortCount = 1,
+      workDir = work,
+      outputSchemas = outputSchemas
+    )
+    (work, Files.readAllLines(result.outputs(1)))
+  }
+
+  private def tuple(id: Int, name: String): Tuple =
+    rowOf(schema)("id" -> Int.box(id), "name" -> name)
+
   /** Four rows, the last a repeat of the second. */
   private val rows = Seq(tuple(1, "a"), tuple(2, "b"), tuple(3, "c"), tuple(2, 
"b"))
 
@@ -150,20 +181,12 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
 
   private def blobKind(cell: Array[Byte], opDesc: BlobTypeOp = new 
BlobTypeOp): String = {
     val blobOnly = new Schema(new Attribute("blob", AttributeType.BINARY))
-    val dir = Files.createTempDirectory("harness-spec-blob-kind-")
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(
-      input,
-      Iterator(Tuple.builder(blobOnly).add(blobOnly.getAttribute("blob"), 
cell).build()),
-      blobOnly
+    val (_, lines) = runStandalone(
+      "harness-spec-blob-kind-",
+      blobOnly,
+      Seq(rowOf(blobOnly)("blob" -> cell)),
+      opDesc
     )
-    val result = StandaloneRunner.run(
-      opDesc = opDesc,
-      inputs = Map(1 -> input),
-      outputPortCount = 1,
-      workDir = dir
-    )
-    val lines = Files.readAllLines(result.outputs(1))
     lines should have size 1
     lines.get(0)
   }
@@ -195,26 +218,15 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
   }
 
   "StandaloneRunner" should "run the generated script and reach the same 
answer" taggedAs NeedsPython in {
-    withInput { (dir, input) =>
-      val work = dir.resolve("standalone")
-      Files.createDirectories(work)
-      val result = StandaloneRunner.run(
-        opDesc = new DistinctOpDesc,
-        inputs = Map(1 -> input),
-        outputPortCount = 1,
-        workDir = work
-      )
+    val (work, lines) = runStandalone("harness-spec-", schema, rows)
 
-      // The script is kept where it ran, so a failing operator can be opened 
as
-      // generated rather than described second-hand.
-      Files.exists(work.resolve("script.py")) shouldBe true
+    // The script is kept where it ran, so a failing operator can be opened as
+    // generated rather than described second-hand.
+    Files.exists(work.resolve("script.py")) shouldBe true
 
-      val produced = result.outputs(1)
-      val lines = Files.readAllLines(produced)
-      lines should have size 3
-      lines.get(0) should include("\"id\":1")
-      lines.get(2) should include("\"id\":3")
-    }
+    lines should have size 3
+    lines.get(0) should include("\"id\":1")
+    lines.get(2) should include("\"id\":3")
   }
 
   // A source writes a placeholder where its file should be named, since only
@@ -250,31 +262,10 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
   // run had true and false. The prologue takes the column back to the nullable
   // boolean dtype, which carries the two values and the hole.
   it should "hand a boolean column with a hole to the script as booleans" 
taggedAs NeedsPython in {
-    val holed = new Schema(
-      new Attribute("id", AttributeType.INTEGER),
-      new Attribute("flag", AttributeType.BOOLEAN)
-    )
-    def row(id: Int, flag: java.lang.Boolean): Tuple = {
-      val b = Tuple.builder(holed)
-      b.add(holed.getAttribute("id"), Int.box(id))
-      b.add(holed.getAttribute("flag"), flag)
-      b.build()
-    }
-
-    val dir = Files.createTempDirectory("harness-spec-boolean-")
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(input, Iterator(row(1, true), row(2, null), row(3, 
false)), holed)
-    val work = dir.resolve("standalone")
-    Files.createDirectories(work)
+    val (holed, inputRows) =
+      twoColRows("flag", AttributeType.BOOLEAN)(1 -> true, 2 -> null, 3 -> 
false)
+    val (_, lines) = runStandalone("harness-spec-boolean-", holed, inputRows)
 
-    val result = StandaloneRunner.run(
-      opDesc = new DistinctOpDesc,
-      inputs = Map(1 -> input),
-      outputPortCount = 1,
-      workDir = work
-    )
-
-    val lines = Files.readAllLines(result.outputs(1))
     lines should have size 3
     lines.get(0) should include("\"flag\":true")
     lines.get(1) should include("\"flag\":null")
@@ -286,32 +277,15 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
   // null, so the same column left the script as 6.0 as soon as a row was
   // missing, and the two sides disagreed on every value in it.
   it should "write an integral column with a hole the way the engine writes 
it" taggedAs NeedsPython in {
-    val holed = new Schema(
-      new Attribute("id", AttributeType.INTEGER),
-      new Attribute("n", AttributeType.INTEGER)
-    )
-    def row(id: Int, n: Integer): Tuple = {
-      val b = Tuple.builder(holed)
-      b.add(holed.getAttribute("id"), Int.box(id))
-      b.add(holed.getAttribute("n"), n)
-      b.build()
-    }
-
-    val dir = Files.createTempDirectory("harness-spec-integral-")
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(input, Iterator(row(1, 6), row(2, null), row(3, 7)), 
holed)
-    val work = dir.resolve("standalone")
-    Files.createDirectories(work)
-
-    val result = StandaloneRunner.run(
-      opDesc = new DistinctOpDesc,
-      inputs = Map(1 -> input),
-      outputPortCount = 1,
-      workDir = work,
-      outputSchemas = Map(PortIdentity(0) -> holed)
-    )
+    val (holed, inputRows) = twoColRows("n", AttributeType.INTEGER)(1 -> 6, 2 
-> null, 3 -> 7)
+    val (_, lines) =
+      runStandalone(
+        "harness-spec-integral-",
+        holed,
+        inputRows,
+        outputSchemas = Map(PortIdentity(0) -> holed)
+      )
 
-    val lines = Files.readAllLines(result.outputs(1))
     lines should have size 3
     lines.get(0) should include("\"n\":6")
     lines.get(0) should not include "\"n\":6.0"
@@ -329,26 +303,12 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
       "2024-01-01 00:00:00.123456789",
       "2500-01-01 00:00:00.0"
     )
-    val dir = Files.createTempDirectory("harness-spec-timestamp-")
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(
-      input,
-      values.iterator.map { v =>
-        Tuple.builder(stamped).add(stamped.getAttribute("ts"), 
Timestamp.valueOf(v)).build()
-      },
-      stamped
-    )
-    val work = dir.resolve("standalone")
-    Files.createDirectories(work)
-
-    val result = StandaloneRunner.run(
-      opDesc = new DistinctOpDesc,
-      inputs = Map(1 -> input),
-      outputPortCount = 1,
-      workDir = work
+    val (_, lines) = runStandalone(
+      "harness-spec-timestamp-",
+      stamped,
+      values.map(v => rowOf(stamped)("ts" -> Timestamp.valueOf(v)))
     )
 
-    val lines = Files.readAllLines(result.outputs(1))
     lines should have size 3
     values.zipWithIndex.foreach {
       case (v, i) => lines.get(i) should include("\"ts\":\"" + v + "\"")
@@ -360,26 +320,13 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
   // operator that prints the value answered "-0.0" there and "0.0" here.
   it should "keep the sign of a negative zero in a DOUBLE column without a 
NaN" taggedAs NeedsPython in {
     val zeros = new Schema(new Attribute("x", AttributeType.DOUBLE))
-    val dir = Files.createTempDirectory("harness-spec-signed-zero-")
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(
-      input,
-      Iterator(-0.0, 0.0).map { v =>
-        Tuple.builder(zeros).add(zeros.getAttribute("x"), 
Double.box(v)).build()
-      },
-      zeros
-    )
-    val work = dir.resolve("standalone")
-    Files.createDirectories(work)
-
-    val result = StandaloneRunner.run(
-      opDesc = new DoubleTextOp,
-      inputs = Map(1 -> input),
-      outputPortCount = 1,
-      workDir = work
+    val (_, lines) = runStandalone(
+      "harness-spec-signed-zero-",
+      zeros,
+      Seq(-0.0, 0.0).map(v => rowOf(zeros)("x" -> Double.box(v))),
+      new DoubleTextOp
     )
 
-    val lines = Files.readAllLines(result.outputs(1))
     lines should have size 2
     lines.get(0) should include("\"text\":\"-0.0\"")
     lines.get(1) should include("\"text\":\"0.0\"")
@@ -390,33 +337,12 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
   // operator is handed a str where the run's was handed bytes, and anything it
   // does with them answers for the base64 rather than for the value.
   it should "hand a binary column to the script as bytes" taggedAs NeedsPython 
in {
-    val withBlob = new Schema(
-      new Attribute("id", AttributeType.INTEGER),
-      new Attribute("blob", AttributeType.BINARY)
-    )
-    def row(id: Int, blob: Array[Byte]): Tuple = {
-      val b = Tuple.builder(withBlob)
-      b.add(withBlob.getAttribute("id"), Int.box(id))
-      b.add(withBlob.getAttribute("blob"), blob)
-      b.build()
-    }
-
-    val dir = Files.createTempDirectory("harness-spec-binary-")
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(
-      input,
-      Iterator(row(1, "hi".getBytes(StandardCharsets.UTF_8)), row(2, null)),
-      withBlob
-    )
-    val work = dir.resolve("standalone")
-    Files.createDirectories(work)
-
-    val result = StandaloneRunner.run(
-      opDesc = new DistinctOpDesc,
-      inputs = Map(1 -> input),
-      outputPortCount = 1,
-      workDir = work
-    )
+    val (withBlob, inputRows) =
+      twoColRows("blob", AttributeType.BINARY)(
+        1 -> "hi".getBytes(StandardCharsets.UTF_8),
+        2 -> null
+      )
+    val (work, lines) = runStandalone("harness-spec-binary-", withBlob, 
inputRows)
 
     // The prologue decodes that column and no other. Distinct answers the same
     // whether it is handed the bytes or the base64 spelling of them, so what 
the
@@ -428,7 +354,6 @@ class HarnessSpec extends AnyFlatSpec with Matchers {
 
     // And the column still leaves as the base64 the engine's writer wrote:
     // decoding it on the way in must not turn it into a pickle on the way out.
-    val lines = Files.readAllLines(result.outputs(1))
     lines should have size 2
     lines.get(0) should include("\"blob\":\"aGk=\"")
     lines.get(1) should include("\"blob\":null")
diff --git 
a/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/PyOpExecHarnessSpec.scala
 
b/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/PyOpExecHarnessSpec.scala
index 2f917bccd8..86f7575aa7 100644
--- 
a/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/PyOpExecHarnessSpec.scala
+++ 
b/workflow-compiling-service/src/test/scala/org/apache/texera/amber/translator/verify/PyOpExecHarnessSpec.scala
@@ -27,7 +27,7 @@ import 
org.apache.texera.amber.translator.verify.tags.IntegrationTest
 import org.scalatest.flatspec.AnyFlatSpec
 import org.scalatest.matchers.should.Matchers
 
-import java.nio.file.Files
+import java.nio.file.{Files, Path}
 import java.sql.Timestamp
 import java.util.Base64
 import scala.sys.process._
@@ -39,48 +39,20 @@ import scala.sys.process._
 @IntegrationTest
 class PyOpExecHarnessSpec extends AnyFlatSpec with Matchers {
 
-  /** Yields one dict twice, changing it in between. `DataProcessor` reads a
-    * yield where it happens, so the engine records 1 and then 2; a driver that
-    * collects the yields first and converts them afterwards sees the same
-    * object twice and records 2 twice.
+  /** A Python operator with one input and one output port that declares one
+    * output column and runs the code it is given.
     */
-  private class MutatingYieldOpDesc extends PythonOperatorDescriptor {
-    override def operatorInfo: OperatorInfo =
-      OperatorInfo(
-        userFriendlyName = "Mutating Yield",
-        operatorDescription = "yields one dict twice, changing it in between",
-        operatorGroupName = OperatorGroupConstants.UTILITY_GROUP,
-        inputPorts = List(InputPort()),
-        outputPorts = List(OutputPort())
-      )
-
-    override def getOutputSchemas(
-        inputSchemas: Map[PortIdentity, Schema]
-    ): Map[PortIdentity, Schema] =
-      Map(
-        operatorInfo.outputPorts.head.id -> Schema().add(new Attribute("x", 
AttributeType.INTEGER))
-      )
-
-    override def generatePythonCode(): String =
-      """from pytexera import *
-        |
-        |class ProcessTableOperator(UDFTableOperator):
-        |
-        |    @overrides
-        |    def process_table(self, table: Table, port: int) -> 
Iterator[Optional[TableLike]]:
-        |        row = {"x": 1}
-        |        yield row
-        |        row["x"] = 2
-        |        yield row
-        |""".stripMargin
-  }
-
-  /** Reports the column names of the table it was handed, as one row. */
-  private class TableColumnsOpDesc extends PythonOperatorDescriptor {
+  private class InlinePythonOpDesc(
+      name: String,
+      desc: String,
+      outName: String,
+      outType: AttributeType,
+      pythonCode: String
+  ) extends PythonOperatorDescriptor {
     override def operatorInfo: OperatorInfo =
       OperatorInfo(
-        userFriendlyName = "Table Columns",
-        operatorDescription = "yields the column names of its input table",
+        userFriendlyName = name,
+        operatorDescription = desc,
         operatorGroupName = OperatorGroupConstants.UTILITY_GROUP,
         inputPorts = List(InputPort()),
         outputPorts = List(OutputPort())
@@ -89,154 +61,103 @@ class PyOpExecHarnessSpec extends AnyFlatSpec with 
Matchers {
     override def getOutputSchemas(
         inputSchemas: Map[PortIdentity, Schema]
     ): Map[PortIdentity, Schema] =
-      Map(
-        operatorInfo.outputPorts.head.id -> Schema().add(
-          new Attribute("columns", AttributeType.STRING)
-        )
-      )
+      Map(operatorInfo.outputPorts.head.id -> Schema().add(new 
Attribute(outName, outType)))
 
-    override def generatePythonCode(): String =
-      """from pytexera import *
-        |
-        |class ProcessTableOperator(UDFTableOperator):
-        |
-        |    @overrides
-        |    def process_table(self, table: Table, port: int) -> 
Iterator[Optional[TableLike]]:
-        |        yield {"columns": ",".join(table.columns)}
-        |""".stripMargin
+    override def generatePythonCode(): String = pythonCode
   }
 
-  /** Reports the timestamp it was handed, as Python prints it. */
-  private class TimestampTextOpDesc extends BinaryTypeOpDesc {
-    override def generatePythonCode(): String =
-      """from pytexera import *
-        |
-        |class ProcessTupleOperator(UDFOperatorV2):
-        |
-        |    @overrides
-        |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:
-        |        yield {"kind": str(tuple_["ts"])}
-        |""".stripMargin
-  }
-
-  /** Declares one INTEGER column `x` and yields `row`, a Python dict literal. 
*/
-  private class YieldOpDesc(row: String) extends PythonOperatorDescriptor {
-    override def operatorInfo: OperatorInfo =
-      OperatorInfo(
-        userFriendlyName = "Yield",
-        operatorDescription = "yields one row as given",
-        operatorGroupName = OperatorGroupConstants.UTILITY_GROUP,
-        inputPorts = List(InputPort()),
-        outputPorts = List(OutputPort())
-      )
-
-    override def getOutputSchemas(
-        inputSchemas: Map[PortIdentity, Schema]
-    ): Map[PortIdentity, Schema] =
-      Map(
-        operatorInfo.outputPorts.head.id -> Schema().add(new Attribute("x", 
AttributeType.INTEGER))
-      )
-
-    override def generatePythonCode(): String =
+  /** Puts `bodyLines` inside `process_tuple`, or inside `process_table` when
+    * `tableOp` is set.
+    */
+  private def inlinePyOp(
+      name: String,
+      desc: String,
+      outName: String,
+      outType: AttributeType,
+      bodyLines: Seq[String],
+      tableOp: Boolean = false
+  ): PythonOperatorDescriptor = {
+    val header =
+      if (tableOp)
+        """class ProcessTableOperator(UDFTableOperator):
+          |
+          |    @overrides
+          |    def process_table(self, table: Table, port: int) -> 
Iterator[Optional[TableLike]]:""".stripMargin
+      else
+        """class ProcessTupleOperator(UDFOperatorV2):
+          |
+          |    @overrides
+          |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:""".stripMargin
+    val body = bodyLines.map("        " + _).mkString("\n")
+    val code =
       s"""from pytexera import *
          |
-         |class ProcessTupleOperator(UDFOperatorV2):
-         |
-         |    @overrides
-         |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:
-         |        yield $row
+         |$header
+         |$body
          |""".stripMargin
+    new InlinePythonOpDesc(name, desc, outName, outType, code)
   }
 
+  /** Yields one dict twice, changing it in between. `DataProcessor` reads a
+    * yield where it happens, so the engine records 1 and then 2; a driver that
+    * collects the yields first and converts them afterwards sees the same
+    * object twice and records 2 twice.
+    */
+  private val mutatingYieldOpDesc: PythonOperatorDescriptor = inlinePyOp(
+    name = "Mutating Yield",
+    desc = "yields one dict twice, changing it in between",
+    outName = "x",
+    outType = AttributeType.INTEGER,
+    bodyLines = Seq("""row = {"x": 1}""", "yield row", """row["x"] = 2""", 
"yield row"),
+    tableOp = true
+  )
+
+  /** Reports the column names of the table it was handed, as one row. */
+  private val tableColumnsOpDesc: PythonOperatorDescriptor = inlinePyOp(
+    name = "Table Columns",
+    desc = "yields the column names of its input table",
+    outName = "columns",
+    outType = AttributeType.STRING,
+    bodyLines = Seq("""yield {"columns": ",".join(table.columns)}"""),
+    tableOp = true
+  )
+
+  private def kindOp(desc: String, expr: String): PythonOperatorDescriptor =
+    inlinePyOp(
+      name = "Binary Type",
+      desc = desc,
+      outName = "kind",
+      outType = AttributeType.STRING,
+      bodyLines = Seq(s"""yield {"kind": $expr}""")
+    )
+
+  /** Declares one INTEGER column `x` and yields `row`, a Python dict literal. 
*/
+  private def yieldOp(row: String): PythonOperatorDescriptor =
+    inlinePyOp(
+      name = "Yield",
+      desc = "yields one row as given",
+      outName = "x",
+      outType = AttributeType.INTEGER,
+      bodyLines = Seq(s"yield $row")
+    )
+
   /** Reads a LARGE_BINARY column and writes out the reference it holds.
     *
     * The bytes of a large binary live in S3 and the field is the s3:// URI 
that
     * points at them, so an operator can be handed one, and can hand one back,
     * without any storage being reachable.
     */
-  private class LargeBinaryOpDesc(readsInput: Boolean) extends 
PythonOperatorDescriptor {
-    override def operatorInfo: OperatorInfo =
-      OperatorInfo(
-        userFriendlyName = "Large Binary",
-        operatorDescription = "reads or writes a reference to a large binary",
-        operatorGroupName = OperatorGroupConstants.UTILITY_GROUP,
-        inputPorts = List(InputPort()),
-        outputPorts = List(OutputPort())
-      )
-
-    override def getOutputSchemas(
-        inputSchemas: Map[PortIdentity, Schema]
-    ): Map[PortIdentity, Schema] =
-      Map(
-        operatorInfo.outputPorts.head.id ->
-          (if (readsInput) Schema().add(new Attribute("uri", 
AttributeType.STRING))
-           else Schema().add(new Attribute("blob", 
AttributeType.LARGE_BINARY)))
-      )
-
-    override def generatePythonCode(): String =
-      if (readsInput)
-        """from pytexera import *
-          |
-          |class ProcessTupleOperator(UDFOperatorV2):
-          |
-          |    @overrides
-          |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:
-          |        yield {"uri": tuple_["blob"].uri}
-          |""".stripMargin
-      else
-        """from pytexera import *
-          |
-          |class ProcessTupleOperator(UDFOperatorV2):
-          |
-          |    @overrides
-          |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:
-          |        yield {"blob": largebinary(tuple_["uri"])}
-          |""".stripMargin
-  }
-
-  /** Reports the Python type of the BINARY cell it is handed. */
-  private class BinaryTypeOpDesc extends PythonOperatorDescriptor {
-    override def operatorInfo: OperatorInfo =
-      OperatorInfo(
-        userFriendlyName = "Binary Type",
-        operatorDescription = "reports the type of a binary cell",
-        operatorGroupName = OperatorGroupConstants.UTILITY_GROUP,
-        inputPorts = List(InputPort()),
-        outputPorts = List(OutputPort())
+  private def largeBinaryOp(readsInput: Boolean): PythonOperatorDescriptor =
+    inlinePyOp(
+      name = "Large Binary",
+      desc = "reads or writes a reference to a large binary",
+      outName = if (readsInput) "uri" else "blob",
+      outType = if (readsInput) AttributeType.STRING else 
AttributeType.LARGE_BINARY,
+      bodyLines = Seq(
+        if (readsInput) """yield {"uri": tuple_["blob"].uri}"""
+        else """yield {"blob": largebinary(tuple_["uri"])}"""
       )
-
-    override def getOutputSchemas(
-        inputSchemas: Map[PortIdentity, Schema]
-    ): Map[PortIdentity, Schema] =
-      Map(
-        operatorInfo.outputPorts.head.id -> Schema().add(
-          new Attribute("kind", AttributeType.STRING)
-        )
-      )
-
-    override def generatePythonCode(): String =
-      """from pytexera import *
-        |
-        |class ProcessTupleOperator(UDFOperatorV2):
-        |
-        |    @overrides
-        |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:
-        |        yield {"kind": type(tuple_["blob"]).__name__}
-        |""".stripMargin
-  }
-
-  /** Calls predict on the BINARY cell it is handed, as a model's consumer 
does. */
-  private class ModelPredictOpDesc extends BinaryTypeOpDesc {
-    override def generatePythonCode(): String =
-      """from pytexera import *
-        |
-        |class ProcessTupleOperator(UDFOperatorV2):
-        |
-        |    @overrides
-        |    def process_tuple(self, tuple_: Tuple, port: int) -> 
Iterator[Optional[TupleLike]]:
-        |        yield {"kind": str(tuple_["blob"].predict([[1.0]])[0])}
-        |""".stripMargin
-  }
+    )
 
   // A fitted DecisionTreeClassifier behind the marker the cast writes, pickled
   // by the interpreter the harness runs so the two share a sklearn. The script
@@ -256,64 +177,95 @@ class PyOpExecHarnessSpec extends AnyFlatSpec with 
Matchers {
     Base64.getDecoder.decode(encoded.trim)
   }
 
-  private def binaryCellKind(
-      cell: Array[Byte],
-      opDesc: PythonOperatorDescriptor = new BinaryTypeOpDesc
-  ): String = {
-    val dir = Files.createTempDirectory("py-op-harness-binary-")
-    val inputSchema = Schema().add(new Attribute("blob", AttributeType.BINARY))
+  private def writeInputPort0(
+      prefix: String,
+      inputSchema: Schema,
+      rows: Seq[Tuple]
+  ): (Path, Path) = {
+    val dir = Files.createTempDirectory(prefix)
     val input = dir.resolve("input_port_0.jsonl")
-    val row = Tuple.builder(inputSchema).add("blob", AttributeType.BINARY, 
cell).build()
-    TupleIO.writeTuples(input, Iterator(row), inputSchema)
+    TupleIO.writeTuples(input, rows.iterator, inputSchema)
+    (dir, input)
+  }
+
+  private def singleColRow(col: String, tpe: AttributeType, value: Any): 
(Schema, Seq[Tuple]) = {
+    val schema = Schema().add(new Attribute(col, tpe))
+    val row = Tuple.builder(schema).add(col, tpe, value).build()
+    (schema, Seq(row))
+  }
 
+  private def runSinglePort[T](
+      prefix: String,
+      inputSchema: Schema,
+      rows: Seq[Tuple],
+      opDesc: PythonOperatorDescriptor,
+      readField: Tuple => T
+  ): Seq[T] = {
+    val (dir, input) = writeInputPort0(prefix, inputSchema, rows)
     val result = PyOpExecHarness.execute(
       opDesc,
       inputs = Map(PortIdentity(0) -> input),
       outputDir = dir.resolve("actual")
     )
-
     val out = result.outputs(PortIdentity(0))
-    TupleIO
-      .readTuples(out, TupleIO.readSchemaSidecar(out))
-      .map(_.getField[String]("kind"))
-      .toSeq
-      .head
+    TupleIO.readTuples(out, 
TupleIO.readSchemaSidecar(out)).map(readField).toSeq
+  }
+
+  private def runSingleCell[T](
+      prefix: String,
+      col: String,
+      tpe: AttributeType,
+      value: Any,
+      opDesc: PythonOperatorDescriptor,
+      readField: Tuple => T
+  ): Seq[T] = {
+    val (schema, rows) = singleColRow(col, tpe, value)
+    runSinglePort(prefix, schema, rows, opDesc, readField)
   }
 
   // A model column arrives as the marker followed by the pickle, and the 
worker
   // unpickles it before the operator sees it, so predict works on it.
   "PyOpExecHarness" should "hand a pickled model cell to the operator as the 
model" in {
-    binaryCellKind(fittedTreeCell(), new ModelPredictOpDesc) shouldBe "1"
+    val modelPredictOp = kindOp(
+      "calls predict on a binary model cell",
+      """str(tuple_["blob"].predict([[1.0]])[0])"""
+    )
+    runSingleCell(
+      "py-op-harness-binary-",
+      "blob",
+      AttributeType.BINARY,
+      fittedTreeCell(),
+      modelPredictOp,
+      _.getField[String]("kind")
+    ).head shouldBe "1"
   }
 
   it should "hand any other binary cell to the operator as bytes" in {
-    binaryCellKind(Array[Byte](0, 1, 2)) shouldBe "bytes"
+    val binaryTypeOp =
+      kindOp("reports the type of a binary cell", 
"""type(tuple_["blob"]).__name__""")
+    runSingleCell(
+      "py-op-harness-binary-",
+      "blob",
+      AttributeType.BINARY,
+      Array[Byte](0, 1, 2),
+      binaryTypeOp,
+      _.getField[String]("kind")
+    ).head shouldBe "bytes"
   }
 
   // The worker gets the wall clock as a zoneless Arrow microsecond timestamp,
   // so the operator holds a naive datetime cut to the microsecond, and a year
   // past pandas' nanosecond range reaches it all the same.
   it should "hand a timestamp to the operator as the worker hands it" in {
-    val dir = Files.createTempDirectory("py-op-harness-timestamp-")
-    val inputSchema = Schema().add(new Attribute("ts", 
AttributeType.TIMESTAMP))
-    val input = dir.resolve("input_port_0.jsonl")
-    val row = Tuple
-      .builder(inputSchema)
-      .add("ts", AttributeType.TIMESTAMP, Timestamp.valueOf("2500-01-01 
00:00:00.123456789"))
-      .build()
-    TupleIO.writeTuples(input, Iterator(row), inputSchema)
-
-    val result = PyOpExecHarness.execute(
-      new TimestampTextOpDesc,
-      inputs = Map(PortIdentity(0) -> input),
-      outputDir = dir.resolve("actual")
-    )
-
-    val out = result.outputs(PortIdentity(0))
-    TupleIO
-      .readTuples(out, TupleIO.readSchemaSidecar(out))
-      .map(_.getField[String]("kind"))
-      .toSeq shouldBe Seq("2500-01-01 00:00:00.123456")
+    val timestampTextOp = kindOp("reports a timestamp cell", 
"""str(tuple_["ts"])""")
+    runSingleCell(
+      "py-op-harness-timestamp-",
+      "ts",
+      AttributeType.TIMESTAMP,
+      Timestamp.valueOf("2500-01-01 00:00:00.123456789"),
+      timestampTextOp,
+      _.getField[String]("kind")
+    ) shouldBe Seq("2500-01-01 00:00:00.123456")
   }
 
   private val someObject = "s3://a-bucket/a/large/object"
@@ -322,63 +274,39 @@ class PyOpExecHarnessSpec extends AnyFlatSpec with 
Matchers {
   // well as out. The operator reads the reference itself, which a column 
handed
   // over as plain text could not answer for.
   "PyOpExecHarness" should "hand a large binary column to the operator as a 
reference" in {
-    val dir = Files.createTempDirectory("py-op-harness-large-binary-in-")
-    val inputSchema = Schema().add(new Attribute("blob", 
AttributeType.LARGE_BINARY))
-    val input = dir.resolve("input_port_0.jsonl")
-    val row = Tuple
-      .builder(inputSchema)
-      .add("blob", AttributeType.LARGE_BINARY, new LargeBinary(someObject))
-      .build()
-    TupleIO.writeTuples(input, Iterator(row), inputSchema)
-
-    val result = PyOpExecHarness.execute(
-      new LargeBinaryOpDesc(readsInput = true),
-      inputs = Map(PortIdentity(0) -> input),
-      outputDir = dir.resolve("actual")
-    )
-
-    val out = result.outputs(PortIdentity(0))
-    TupleIO
-      .readTuples(out, TupleIO.readSchemaSidecar(out))
-      .map(_.getField[String]("uri"))
-      .toSeq shouldBe Seq(someObject)
+    runSingleCell(
+      "py-op-harness-large-binary-in-",
+      "blob",
+      AttributeType.LARGE_BINARY,
+      new LargeBinary(someObject),
+      largeBinaryOp(readsInput = true),
+      _.getField[String]("uri")
+    ) shouldBe Seq(someObject)
   }
 
   it should "write back a large binary the operator made" in {
-    val dir = Files.createTempDirectory("py-op-harness-large-binary-out-")
-    val inputSchema = Schema().add(new Attribute("uri", AttributeType.STRING))
-    val input = dir.resolve("input_port_0.jsonl")
-    val row = Tuple.builder(inputSchema).add("uri", AttributeType.STRING, 
someObject).build()
-    TupleIO.writeTuples(input, Iterator(row), inputSchema)
-
-    val result = PyOpExecHarness.execute(
-      new LargeBinaryOpDesc(readsInput = false),
-      inputs = Map(PortIdentity(0) -> input),
-      outputDir = dir.resolve("actual")
-    )
-
-    val out = result.outputs(PortIdentity(0))
     // Read back as a LargeBinary and not as the text of one: the column is
     // declared large_binary, and this is the type the rest of the pipeline 
gets.
-    TupleIO
-      .readTuples(out, TupleIO.readSchemaSidecar(out))
-      .map(_.getField[LargeBinary]("blob").getUri)
-      .toSeq shouldBe Seq(someObject)
+    runSingleCell(
+      "py-op-harness-large-binary-out-",
+      "uri",
+      AttributeType.STRING,
+      someObject,
+      largeBinaryOp(readsInput = false),
+      _.getField[LargeBinary]("blob").getUri
+    ) shouldBe Seq(someObject)
   }
 
   // The worker finalizes each yielded row against the output schema, and so
   // does the driver: a value the cast cannot bring to the declared type, and a
   // field the schema does not have or lacks, end the run in both.
   "PyOpExecHarness" should "refuse a row the output schema does not describe" 
in {
-    val dir = Files.createTempDirectory("py-op-harness-finalize-")
-    val inputSchema = Schema().add(new Attribute("seed", 
AttributeType.INTEGER))
-    val input = dir.resolve("input_port_0.jsonl")
-    val seed = Tuple.builder(inputSchema).add("seed", AttributeType.INTEGER, 
Int.box(1)).build()
-    TupleIO.writeTuples(input, Iterator(seed), inputSchema)
+    val (inputSchema, rows) = singleColRow("seed", AttributeType.INTEGER, 
Int.box(1))
+    val (dir, input) = writeInputPort0("py-op-harness-finalize-", inputSchema, 
rows)
 
     def run(row: String): Unit =
       PyOpExecHarness.execute(
-        new YieldOpDesc(row),
+        yieldOp(row),
         inputs = Map(PortIdentity(0) -> input),
         outputDir = dir.resolve("actual")
       )
@@ -392,23 +320,14 @@ class PyOpExecHarnessSpec extends AnyFlatSpec with 
Matchers {
   }
 
   "PyOpExecHarness" should "record each yield as it was yielded" in {
-    val dir = Files.createTempDirectory("py-op-harness-")
-    val inputSchema = Schema().add(new Attribute("seed", 
AttributeType.INTEGER))
-    val input = dir.resolve("input_port_0.jsonl")
-    val seed = Tuple.builder(inputSchema).add("seed", AttributeType.INTEGER, 
Int.box(1)).build()
-    TupleIO.writeTuples(input, Iterator(seed), inputSchema)
-
-    val result = PyOpExecHarness.execute(
-      new MutatingYieldOpDesc,
-      inputs = Map(PortIdentity(0) -> input),
-      outputDir = dir.resolve("actual")
+    val (inputSchema, rows) = singleColRow("seed", AttributeType.INTEGER, 
Int.box(1))
+    val values = runSinglePort(
+      "py-op-harness-",
+      inputSchema,
+      rows,
+      mutatingYieldOpDesc,
+      _.getField[Integer]("x")
     )
-
-    val out = result.outputs(PortIdentity(0))
-    val values = TupleIO
-      .readTuples(out, TupleIO.readSchemaSidecar(out))
-      .map(_.getField[Integer]("x"))
-      .toSeq
     withClue(s"schema was $inputSchema\n") {
       values shouldBe Seq(1, 2)
     }
@@ -417,23 +336,15 @@ class PyOpExecHarnessSpec extends AnyFlatSpec with 
Matchers {
   // A port that carried no rows gives the table no tuples to read column names
   // off, so the worker hands the operator the port's declared schema instead.
   "PyOpExecHarness" should "hand a port that carried no rows its declared 
columns" in {
-    val dir = Files.createTempDirectory("py-op-harness-empty-")
     val inputSchema = Schema()
       .add(new Attribute("name", AttributeType.STRING))
       .add(new Attribute("n", AttributeType.INTEGER))
-    val input = dir.resolve("input_port_0.jsonl")
-    TupleIO.writeTuples(input, Iterator.empty, inputSchema)
-
-    val result = PyOpExecHarness.execute(
-      new TableColumnsOpDesc,
-      inputs = Map(PortIdentity(0) -> input),
-      outputDir = dir.resolve("actual")
-    )
-
-    val out = result.outputs(PortIdentity(0))
-    TupleIO
-      .readTuples(out, TupleIO.readSchemaSidecar(out))
-      .map(_.getField[String]("columns"))
-      .toSeq shouldBe Seq("name,n")
+    runSinglePort(
+      "py-op-harness-empty-",
+      inputSchema,
+      Seq.empty,
+      tableColumnsOpDesc,
+      _.getField[String]("columns")
+    ) shouldBe Seq("name,n")
   }
 }

Reply via email to