Copilot commented on code in PR #12626:
URL: https://github.com/apache/gluten/pull/12626#discussion_r3833329278


##########
gluten-substrait/src/test/scala/org/apache/gluten/execution/FileSourceScanExecTransformerPushedFiltersSuite.scala:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.gluten.execution
+
+import org.scalatest.funsuite.AnyFunSuite
+
+class FileSourceScanExecTransformerPushedFiltersSuite extends AnyFunSuite {
+
+  import FileSourceScanExecTransformerBase._
+
+  test("starPushedFilters marks every top-level entry") {
+    assert(
+      starPushedFilters("[IsNotNull(id), LessThan(id,5)]") ===
+        "[*IsNotNull(id), *LessThan(id,5)]")
+    assert(starPushedFilters("[IsNotNull(id)]") === "[*IsNotNull(id)]")
+  }
+
+  test("starPushedFilters keeps column names containing spaces intact") {
+    assert(
+      starPushedFilters("[IsNotNull(id with space), LessThan(id with 
space,5)]") ===
+        "[*IsNotNull(id with space), *LessThan(id with space,5)]")
+  }
+
+  test("starPushedFilters does not split on commas nested inside an entry") {
+    assert(
+      starPushedFilters("[In(id, [1,2,3]), IsNotNull(x)]") ===
+        "[*In(id, [1,2,3]), *IsNotNull(x)]")
+  }
+
+  test("starPushedFilters leaves an empty or non-list value unchanged") {
+    assert(starPushedFilters("[]") === "[]")
+    assert(starPushedFilters("") === "")
+    assert(starPushedFilters("not a list") === "not a list")
+  }
+
+  test("markPushedFilters rewrites only the PushedFilters list") {
+    val rendered =
+      "Output [2]: [id, v]\n" +
+        "DataFilters: [isnotnull(id#1), (id#1 < 5)]\n" +
+        "PushedFilters: [IsNotNull(id), LessThan(id,5)]\n" +
+        "ReadSchema: struct<id:int>"
+    val marked = markPushedFilters(rendered)
+    assert(marked.contains("PushedFilters: [*IsNotNull(id), *LessThan(id,5)]"))
+    // Neighbouring metadata entries must not be touched.
+    assert(marked.contains("DataFilters: [isnotnull(id#1), (id#1 < 5)]"))
+    assert(marked.contains("ReadSchema: struct<id:int>"))
+  }
+
+  test("markPushedFilters leaves text without a PushedFilters list unchanged") 
{
+    val rendered = "Output [1]: [id]\nReadSchema: struct<id:int>"
+    assert(markPushedFilters(rendered) === rendered)
+  }
+
+  test("markPushedFilters is a no-op when the list is unbalanced") {
+    // A string literal holding an unmatched bracket keeps the scan from 
finding the list end;
+    // the renderer must degrade to leaving the text untouched rather than 
corrupting it.

Review Comment:
   The test comment says an "unmatched bracket", but the example string is 
actually unbalanced due to a missing closing ')'. Updating the comment would 
avoid confusion about what case this test is covering.



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