imback82 commented on code in PR #42577:
URL: https://github.com/apache/spark/pull/42577#discussion_r1382761816


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala:
##########
@@ -253,7 +270,8 @@ case class CatalogTable(
     tracksPartitionsInCatalog: Boolean = false,
     schemaPreservesCase: Boolean = true,
     ignoredProperties: Map[String, String] = Map.empty,
-    viewOriginalText: Option[String] = None) {
+    viewOriginalText: Option[String] = None,
+    clusterBySpec: Option[ClusterBySpec] = None) {

Review Comment:
   We haven't added any field to `CatalogTable` in the last 5 years and should 
we _not_ add this new field? Alternatively, we can store clustering columns in 
the property and make the property as reserved?



##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -502,13 +502,16 @@ private[hive] class HiveClientImpl(
       "comment",
       // For EXTERNAL_TABLE, the table properties has a particular field 
"EXTERNAL". This is added
       // in the function toHiveTable.
-      "EXTERNAL"
+      "EXTERNAL",
+      // Used to store clusterBySpec.
+      "clusteringColumns"
     )
 
     val filteredProperties = properties.filterNot {
       case (key, _) => excludedTableProperties.contains(key)
     }
     val comment = properties.get("comment")
+    val clusterBySpec = 
properties.get("clusteringColumns").map(ClusterBySpec(_))

Review Comment:
   should we make this property as reserved?



##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/CreateTableClusterBySuite.scala:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.hive.execution.command
+
+import org.apache.spark.sql.execution.command.v1
+
+/**
+ * The class contains tests for the `CREATE TABLE ... CLUSTER BY` command to 
check V1 Hive external
+ * table catalog.
+ */
+class CreateTableClusterBySuite extends v1.CreateTableClusterBySuiteBase with 
CommandSuiteBase {
+  // Hive doesn't support nested column names with space and dot.

Review Comment:
   Actually, the exception stack trace looks like the following:
   ```
    [CANNOT_RECOGNIZE_HIVE_TYPE] Cannot recognize hive type string: 
"STRUCT<COL4.1:INT>", column: `col3`. The specified data type for the field 
cannot be recognized by Spark SQL. Please check the data type of the specified 
field and ensure that it is a valid Spark SQL data type. Refer to the Spark SQL 
documentation for a list of valid data types and their format. If the data type 
is correct, please ensure that you are using a supported version of Spark SQL. 
SQLSTATE: 429BB
   org.apache.spark.SparkException: [CANNOT_RECOGNIZE_HIVE_TYPE] Cannot 
recognize hive type string: "STRUCT<COL4.1:INT>", column: `col3`. The specified 
data type for the field cannot be recognized by Spark SQL. Please check the 
data type of the specified field and ensure that it is a valid Spark SQL data 
type. Refer to the Spark SQL documentation for a list of valid data types and 
their format. If the data type is correct, please ensure that you are using a 
supported version of Spark SQL. SQLSTATE: 429BB
        at 
org.apache.spark.sql.errors.QueryExecutionErrors$.cannotRecognizeHiveTypeError(QueryExecutionErrors.scala:1637)
        at 
org.apache.spark.sql.hive.client.HiveClientImpl$.getSparkSQLDataType(HiveClientImpl.scala:1067)
        at 
org.apache.spark.sql.hive.client.HiveClientImpl$.$anonfun$verifyColumnDataType$1(HiveClientImpl.scala:1082)
        at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
        at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
        at org.apache.spark.sql.types.StructType.foreach(StructType.scala:102)
   ```
   
   `COL4.1` in `"STRUCT<COL4.1:INT>"` is not quoted, so the parser fails. We 
prob. need to fix `DataType.catalogString`...
   



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