beliefer commented on code in PR #37393:
URL: https://github.com/apache/spark/pull/37393#discussion_r940853812


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemoryTableWithV2Filter.scala:
##########
@@ -30,7 +30,17 @@ class InMemoryTableWithV2Filter(
     schema: StructType,
     partitioning: Array[Transform],
     properties: util.Map[String, String])
-  extends InMemoryTable(name, schema, partitioning, properties) {
+  extends InMemoryBaseTable(name, schema, partitioning, properties) with 
SupportsDeleteV2 {
+
+  override def canDeleteWhere(filters: Array[Predicate]): Boolean = {
+    InMemoryTableWithV2Filter.supportsFilters(filters)
+  }
+
+  override def deleteWhere(filters: Array[Predicate]): Unit = 
dataMap.synchronized {
+    import 
org.apache.spark.sql.connector.catalog.CatalogV2Implicits.MultipartIdentifierHelper
+    dataMap --= InMemoryTableWithV2Filter
+      .filtersToKeys(dataMap.keys, partCols.map(_.toSeq.quoted), filters)

Review Comment:
   `import ...InMemoryTableWithV2Filter._`
   Then we can simplify the code.



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemoryTable.scala:
##########
@@ -17,218 +17,42 @@
 
 package org.apache.spark.sql.connector.catalog
 
-import java.time.{Instant, ZoneId}
-import java.time.temporal.ChronoUnit
 import java.util
-import java.util.OptionalLong
 
-import scala.collection.mutable
-
-import org.scalatest.Assertions._
-
-import org.apache.spark.sql.catalyst.InternalRow
-import org.apache.spark.sql.catalyst.expressions.{GenericInternalRow, 
JoinedRow}
-import org.apache.spark.sql.catalyst.util.{CharVarcharUtils, DateTimeUtils}
 import org.apache.spark.sql.connector.distributions.{Distribution, 
Distributions}
-import org.apache.spark.sql.connector.expressions._
-import org.apache.spark.sql.connector.metric.{CustomMetric, CustomTaskMetric}
-import org.apache.spark.sql.connector.read._
-import 
org.apache.spark.sql.connector.read.partitioning.{KeyGroupedPartitioning, 
Partitioning, UnknownPartitioning}
-import org.apache.spark.sql.connector.write._
-import 
org.apache.spark.sql.connector.write.streaming.{StreamingDataWriterFactory, 
StreamingWrite}
-import org.apache.spark.sql.internal.connector.SupportsStreamingUpdateAsAppend
-import org.apache.spark.sql.sources._
-import org.apache.spark.sql.types._
-import org.apache.spark.sql.util.CaseInsensitiveStringMap
-import org.apache.spark.unsafe.types.UTF8String
+import org.apache.spark.sql.connector.expressions.{SortOrder, Transform}
+import org.apache.spark.sql.sources.Filter
+import org.apache.spark.sql.types.StructType
 
 /**
  * A simple in-memory table. Rows are stored as a buffered group produced by 
each output task.
  */
 class InMemoryTable(
-    val name: String,
-    val schema: StructType,
+    val _name: String,
+    val _schema: StructType,

Review Comment:
   Why change the name ?



-- 
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