HeartSaVioR commented on code in PR #56546:
URL: https://github.com/apache/spark/pull/56546#discussion_r3424357137


##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/StreamingDeduplicationConnectInteropSuite.scala:
##########
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.connect
+
+import java.io.File
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.util.UUID
+
+import org.apache.spark.sql.streaming.Trigger
+import org.apache.spark.sql.types.{IntegerType, StructField, StructType}
+
+/**
+ * Interop tests for dropDuplicates key resolution across Spark Classic and 
Spark Connect. Both
+ * engines now resolve the dedup keys through the same analyzer rule with a 
deterministic
+ * (positional) order, so a checkpoint written by one engine must be 
restartable under the other:
+ * the state-store keys (bound by position) line up and previously-seen rows 
are still recognized
+ * as duplicates.
+ *
+ * The in-process [[SparkConnectServerTest]] harness exposes a Classic session 
(`spark`) and a
+ * Connect session (`withSession`) sharing one SparkContext / filesystem, so 
both can drive the
+ * same checkpoint directory. Input is plain CSV files (no commit markers) 
read by a file source
+ * with Trigger.AvailableNow for deterministic batching; the sink is a 
recoverable parquet file
+ * sink. See SPARK-57489.
+ */
+class StreamingDeduplicationConnectInteropSuite extends SparkConnectServerTest 
{
+
+  private val rowSchema = StructType(
+    Seq(
+      StructField("a", IntegerType),
+      StructField("b", IntegerType),
+      StructField("c", IntegerType),
+      StructField("d", IntegerType),
+      StructField("e", IntegerType)))
+
+  /**
+   * Writes one CSV file (one batch worth of input) into `inputDir` without 
any commit markers.
+   */
+  private def writeInputCsv(inputDir: File, rows: Seq[(Int, Int, Int, Int, 
Int)]): Unit = {
+    inputDir.mkdirs()
+    val content =
+      rows.map { case (a, b, c, d, e) => s"$a,$b,$c,$d,$e" }.mkString("", 
"\n", "\n")
+    Files.write(
+      new File(inputDir, s"${UUID.randomUUID()}.csv").toPath,
+      content.getBytes(StandardCharsets.UTF_8))
+  }
+
+  /**
+   * Starts a dropDuplicates streaming query on `session` reading `inputDir`, 
processes all
+   * currently-available files against `checkpoint`, appending deduplicated 
rows to the parquet
+   * sink at `outputDir`.
+   */
+  // Fully qualified on purpose: this file lives in package 
org.apache.spark.sql.connect, which also
+  // defines a `SparkSession`; an import of the common type is shadowed by it 
under Scala 2.12. The

Review Comment:
   Ah we dropped cross build for Scala 2.12. Missed that.



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

To unsubscribe, e-mail: [email protected]

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


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

Reply via email to