costas-db commented on code in PR #47428:
URL: https://github.com/apache/spark/pull/47428#discussion_r1705963187


##########
sql/core/src/test/scala/org/apache/spark/sql/InlineTableParsingImprovementsSuite.scala:
##########
@@ -0,0 +1,239 @@
+/*
+ * 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
+
+import java.util.UUID
+
+import org.apache.spark.sql.{DataFrame, QueryTest}
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.test.SharedSparkSession
+
+class InlineTableParsingImprovementsSuite extends QueryTest with 
SharedSparkSession {
+
+  /**
+   * Generate a random table name.
+   */
+  private def getRandomTableName(): String =
+    s"test_${UUID.randomUUID()}".replaceAll("-", "_")
+
+  /**
+   * Create a table using a randomly generated name and return that name.
+   */
+  private def createTable: String = {
+    val tableName = getRandomTableName()
+    spark.sql(s"""
+      CREATE TABLE $tableName (
+        id INT,
+        first_name VARCHAR(50) DEFAULT 'John',
+        last_name VARCHAR(50) DEFAULT 'Doe',
+        age INT DEFAULT 25,
+        gender CHAR(1) DEFAULT 'M',
+        email VARCHAR(100) DEFAULT 'john....@databricks.com',
+        phone_number VARCHAR(20) DEFAULT '555-555-5555',
+        address VARCHAR(200) DEFAULT '123 John Doe St',
+        city VARCHAR(50) DEFAULT 'John Doe City',
+        state VARCHAR(50) DEFAULT 'CA',
+        zip_code VARCHAR(10) DEFAULT '12345',
+        country VARCHAR(50) DEFAULT 'USA',
+        registration_date String DEFAULT '2021-01-01')
+    """)
+    tableName
+  }
+
+  /**
+   * Generate an INSERT INTO VALUES statement with basic literals with the 
given number of rows.
+   */
+  private def generateInsertStatementWithLiterals(tableName: String, numRows: 
Int): String = {
+    val baseQuery = s"INSERT INTO $tableName (id, first_name, last_name, age, 
gender," +
+      s" email, phone_number, address, city, state, zip_code, country, 
registration_date) VALUES "
+    val rows = (1 to numRows).map { i =>
+      val id = i
+      val firstName = s"'FirstName_$id'"
+      val lastName = s"'LastName_$id'"
+      val age = (20 + i % 50) // Just a simple pattern for age
+      val gender = if (i % 2 == 0) "'M'" else "'F'"
+      val email = s"'user_$i...@example.com'"
+      val phoneNumber = s"'555-${1000 + i}'"
+      val address = s"'$id Fake St'"
+      val city = "'Anytown'"
+      val state = "'CA'"
+      val zipCode = "'12345'"
+      val country = "'USA'"
+      val registrationDate = s"'2021-${1 + i % 12}-01'" // Varying the month 
part of the date
+
+      s"($id, $firstName, $lastName, $age, $gender, $email, $phoneNumber," +
+        s" $address, $city, $state, $zipCode, $country, $registrationDate)"
+    }.mkString(",\n")
+
+    baseQuery + rows + ";"
+  }
+
+  /**
+   * Checks if two tables are equal.
+   */
+  private def areTablesEqual(df1: DataFrame, df2: DataFrame): Boolean = {
+    val df1ExceptDf2 = df1.except(df2).cache()
+    val df2ExceptDf1 = df2.except(df1).cache()

Review Comment:
   Good point. Fixed!



-- 
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: reviews-unsubscr...@spark.apache.org

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

Reply via email to