parthchandra commented on code in PR #6784:
URL: https://github.com/apache/datafusion-comet/pull/6784#discussion_r4353271047


##########
spark/src/test/scala/org/apache/comet/text/CometTextNativeReadSuite.scala:
##########
@@ -0,0 +1,279 @@
+/*
+ * 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.comet.text
+
+import java.io.File
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+
+import org.apache.spark.sql.CometTestBase
+import org.apache.spark.sql.functions.input_file_name
+import org.apache.spark.sql.internal.SQLConf
+
+import org.apache.comet.CometConf
+
+class CometTextNativeReadSuite extends CometTestBase {
+  private val TEST_TEXT_PATH = "src/test/resources/test-data/text-test-1.txt"
+
+  private def withTextConf(f: => Unit): Unit = {
+    withSQLConf(
+      CometConf.COMET_TEXT_V2_NATIVE_ENABLED.key -> "true",
+      SQLConf.USE_V1_SOURCE_LIST.key -> "")(f)
+  }
+
+  test("native text read - lines to value column") {
+    withTextConf {
+      val df = spark.read.text(TEST_TEXT_PATH)
+      checkSparkAnswerAndOperator(df)
+    }
+  }
+
+  test("native text read - count") {
+    withTextConf {
+      val df = spark.read.text(TEST_TEXT_PATH).selectExpr("count(*) as c")
+      checkSparkAnswerAndOperator(df)
+    }
+  }
+
+  test("native text read - filter and projection") {
+    withTextConf {
+      val df = spark.read.text(TEST_TEXT_PATH).where("value like '%bar%'")
+      checkSparkAnswerAndOperator(df)
+    }
+  }
+
+  test("native text read - preserves line order within a file") {
+    withTempDir { dir =>
+      val file = new File(dir, "ordered.txt")
+      val lines = (1 to 500).map(i => s"row-$i")
+      Files.write(file.toPath, 
lines.mkString("\n").getBytes(StandardCharsets.UTF_8))
+      withTextConf {
+        val got = 
spark.read.text(file.getAbsolutePath).collect().map(_.getString(0)).toSeq

Review Comment:
    Done. preserves line order within a file now calls  
    `checkSparkAnswerAndOperator(df, Seq(classOf[CometTextNativeScanExec])) `
    first, so it fails if the scan falls back. The collect() is kept only to 
check order.



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