viirya commented on a change in pull request #34149:
URL: https://github.com/apache/spark/pull/34149#discussion_r719103865



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetVectorizedSuite.scala
##########
@@ -0,0 +1,426 @@
+/*
+ * 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.parquet
+
+import java.util.{Optional, PrimitiveIterator}
+
+import scala.collection.mutable.ArrayBuffer
+import scala.language.implicitConversions
+
+import org.apache.parquet.column.{ColumnDescriptor, ParquetProperties}
+import org.apache.parquet.column.impl.ColumnWriteStoreV1
+import org.apache.parquet.column.page._
+import org.apache.parquet.column.page.mem.MemPageStore
+import org.apache.parquet.io.ParquetDecodingException
+import org.apache.parquet.io.api.Binary
+import org.apache.parquet.schema.{MessageType, MessageTypeParser}
+import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName
+
+import org.apache.spark.memory.MemoryMode
+import org.apache.spark.sql.{QueryTest, Row}
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.RowOrdering
+import org.apache.spark.sql.catalyst.util.DateTimeUtils
+import 
org.apache.spark.sql.execution.datasources.parquet.SpecificParquetRecordReaderBase.ParquetRowGroupReader
+import org.apache.spark.sql.execution.vectorized.ColumnVectorUtils
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types._
+
+/**
+ * A test suite on the vectorized Parquet reader. Unlike `ParquetIOSuite`, 
this focuses on
+ * low-level decoding logic covering column index, dictionary, different batch 
and page sizes, etc.
+ */
+class ParquetVectorizedSuite extends QueryTest with ParquetTest with 
SharedSparkSession {
+  private val VALUES: Seq[String] = ('a' to 'z').map(_.toString)
+  private val NUM_VALUES: Int = VALUES.length
+  private val BATCH_SIZE_CONFIGS: Seq[Int] = Seq(1, 3, 5, 7, 10, 20, 40)
+  private val PAGE_SIZE_CONFIGS: Seq[Seq[Int]] = Seq(Seq(6, 6, 7, 7), Seq(4, 
9, 4, 9))
+
+  implicit def toStrings(ints: Seq[Int]): Seq[String] = ints.map(i => ('a' + 
i).toChar.toString)
+
+  test("primitive type - no column index") {
+    BATCH_SIZE_CONFIGS.foreach { batchSize =>
+      PAGE_SIZE_CONFIGS.foreach { pageSizes =>
+        Seq(true, false).foreach { dictionaryEnabled =>
+          testPrimitiveString(None, None, pageSizes, VALUES, batchSize,
+            dictionaryEnabled = dictionaryEnabled)
+        }
+      }
+    }
+  }
+
+  test("primitive type - column index with ranges") {
+    BATCH_SIZE_CONFIGS.foreach { batchSize =>
+      PAGE_SIZE_CONFIGS.foreach { pageSizes =>
+        Seq(true, false).foreach { dictionaryEnabled =>
+          var ranges = Seq((0L, 9L))
+          testPrimitiveString(None, Some(ranges), pageSizes, 0 to 9, batchSize,
+            dictionaryEnabled = dictionaryEnabled)
+
+          ranges = Seq((30, 50))
+          testPrimitiveString(None, Some(ranges), pageSizes, Seq.empty, 
batchSize,
+            dictionaryEnabled = dictionaryEnabled)
+
+          ranges = Seq((15, 25))
+          testPrimitiveString(None, Some(ranges), pageSizes, 15 to 19, 
batchSize,
+            dictionaryEnabled = dictionaryEnabled)
+
+          ranges = Seq((19, 20))
+          testPrimitiveString(None, Some(ranges), pageSizes, 19 to 20, 
batchSize,
+            dictionaryEnabled = dictionaryEnabled)
+
+          ranges = Seq((0, 3), (5, 7), (15, 18))
+          testPrimitiveString(None, Some(ranges), pageSizes,
+            toStrings(Seq(0, 1, 2, 3, 5, 6, 7, 15, 16, 17, 18)),

Review comment:
       Isn't `toStrings` implicit?




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