srowen commented on a change in pull request #23628: [SPARK-26702][TEST] Create 
a test trait for Parquet and Orc test
URL: https://github.com/apache/spark/pull/23628#discussion_r251029258
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/FileBasedDataSourceTest.scala
 ##########
 @@ -0,0 +1,99 @@
+/*
+ * 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.execution.datasources
+
+import java.io.File
+
+import scala.reflect.ClassTag
+import scala.reflect.runtime.universe.TypeTag
+
+import org.apache.spark.sql.{DataFrame, SaveMode}
+import org.apache.spark.sql.test.SQLTestUtils
+
+private[sql] trait FileBasedDataSourceTest extends SQLTestUtils {
+
+  protected val dataSourceName: String
+  protected val vectorizedReaderEnabledKey: String
+
+  /**
+   * Reads data source file from given `path` as `DataFrame` and passes it to 
given function.
+   *
+   * @param path           The path to file
+   * @param testVectorized Whether to read the file with vectorized reader. If 
the data source
+   *                       doesn't support vectorized reader, this is no op.
+   * @param f              The given function that takes a `DataFrame` as 
input.
+   */
+  protected def readFile(path: String, testVectorized: Boolean = true)
+      (f: DataFrame => Unit): Unit = {
+    (true :: false :: Nil).foreach { vectorized =>
 
 Review comment:
   `Seq(true, false)` seems simpler... but is this just less confusing to split 
out into two cases?
   You always test without vectorized, and then if `testVectored` is true, test 
with it enabled. I know you'd repeat the same block twice but it's the same 
amount of code and easier to reason about I think.
   (I know this is how the code was already.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to