cloud-fan commented on a change in pull request #28598: URL: https://github.com/apache/spark/pull/28598#discussion_r428614900
########## File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetTest.scala ########## @@ -162,4 +162,36 @@ private[sql] trait ParquetTest extends FileBasedDataSourceTest { protected def getResourceParquetFilePath(name: String): String = { Thread.currentThread().getContextClassLoader.getResource(name).toString } + + def withParquetReaderFlags[T](vectorizedOSS: Boolean) + (code: => T): T = { + val sqlConfs = Seq(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> vectorizedOSS.toString) + var ret = null.asInstanceOf[T] + withSQLConf(sqlConfs: _*) { ret = code } + ret + } + + def withParquetReader[T](reader: String)(code: => T): T = reader match { + case "parquet-mr" => withParquetReaderFlags(false)(code) + case "vectorized-oss" => withParquetReaderFlags(true)(code) + case unknown => + // scalastyle:off throwerror + throw new NotImplementedError(s"Unsupported Parquet reader '$unknown'.") + // scalastyle:on throwerror + } + + def withParquetReaders(readers: String*)(code: => Unit): Unit = for (reader <- readers) { + // scalastyle:off + println(s"with $reader reader") + // scalastyle:on + withParquetReader(reader)(code) + } + + def withOssParquetReaders(code: => Unit): Unit = { + withParquetReaders("parquet-mr", "vectorized-oss")(code) + } + + def withAllParquetReaders(code: => Unit): Unit = { Review comment: can we simplify it? ``` def withAllParquetReaders(code: => Unit): Unit = { // test the row-based reader withSQLConf(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "false")(code) // test the vectorized reader withSQLConf(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "true")(code) } ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org