You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "liujiayi771 (via GitHub)" <gi...@apache.org> on 2025/10/01 05:41:07 UTC

[PR] [spark] Paimon Spark support describe partition [paimon]

liujiayi771 opened a new pull request, #6359:
URL: https://github.com/apache/paimon/pull/6359

   ### Purpose
   
   Spark does not support DESCRIBE TABLE PARTITION for v2 tables. 
   
   ```
   Error running query: [_LEGACY_ERROR_TEMP_1111] org.apache.spark.sql.AnalysisException: DESCRIBE does not support partition for v2 tables.
   ```
   
   This PR supports this usage via a strategy rule.
   
   ### Tests
   
   Add new test case in `DescribeTableTestBase`.
   
   ### API and Format
   
   N/A
   
   ### Documentation
   
   N/A
   


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "YannByron (via GitHub)" <gi...@apache.org>.
YannByron commented on code in PR #6359:
URL: https://github.com/apache/paimon/pull/6359#discussion_r2420194101


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/spark/sql/execution/PaimonDescribeTableExec.scala:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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
+
+import org.apache.paimon.partition.PartitionStatistics
+import org.apache.paimon.spark.SparkTable
+import org.apache.paimon.spark.catalog.SparkBaseCatalog
+import org.apache.paimon.spark.leafnode.PaimonLeafV2CommandExec
+import org.apache.paimon.spark.utils.CatalogUtils.{checkNamespace, toIdentifier}
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.catalog.{CatalogStatistics, CatalogStorageFormat, CatalogTablePartition, CatalogTableType}
+import org.apache.spark.sql.catalyst.catalog.CatalogTypes.TablePartitionSpec
+import org.apache.spark.sql.catalyst.expressions.Attribute
+import org.apache.spark.sql.catalyst.util.quoteIfNeeded
+import org.apache.spark.sql.connector.catalog.{CatalogV2Util, Identifier, SupportsMetadataColumns, TableCatalog}
+import org.apache.spark.sql.connector.expressions.IdentityTransform
+import org.apache.spark.sql.types.StructType
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+case class PaimonDescribeTableExec(
+    output: Seq[Attribute],
+    catalog: SparkBaseCatalog,
+    identifier: Identifier,
+    table: SparkTable,
+    partitionSpec: TablePartitionSpec,
+    isExtended: Boolean)
+  extends PaimonLeafV2CommandExec {
+
+  override protected def run(): Seq[InternalRow] = {

Review Comment:
   Can we call `DescribeTableExec(output, table, isExtended).run()`  which has already implement in Spark at first, and then append the partition info if `partitionSpec` is not empty?



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "liujiayi771 (via GitHub)" <gi...@apache.org>.
liujiayi771 commented on code in PR #6359:
URL: https://github.com/apache/paimon/pull/6359#discussion_r2422359799


##########
paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DescribeTableTestBase.scala:
##########
@@ -156,4 +157,71 @@ abstract class DescribeTableTestBase extends PaimonSparkTestBase {
     // check comment in schema
     Assertions.assertTrue(Objects.equals(comment, loadTable(tableName).schema().comment()))
   }
+
+  protected def describeTablePartitionCreateTable(): Unit = {
+    spark.sql("""
+                |CREATE TABLE T (
+                |  id INT NOT NULL,
+                |  name STRING DEFAULT 'Bob',
+                |  age INT COMMENT 'Age')
+                |  PARTITIONED BY (year INT COMMENT 'Year', month INT, day INT)
+                |""".stripMargin)
+  }
+
+  protected def describeTablePartitionCheckDefaultValue(res: DataFrame): Unit = {
+    checkAnswer(
+      res
+        .filter("col_name = 'name' AND comment != ''")
+        .select("col_name", "data_type", "comment"),
+      Row("name", "string", "'Bob'") :: Nil
+    )
+  }
+
+  test("Paimon describe: describe table partition") {
+    describeTablePartitionCreateTable()

Review Comment:
   spark 3.2/3 not support default keyword, so they override this methods and create table without default keyword.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "YannByron (via GitHub)" <gi...@apache.org>.
YannByron commented on code in PR #6359:
URL: https://github.com/apache/paimon/pull/6359#discussion_r2420003351


##########
paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DescribeTableTestBase.scala:
##########
@@ -156,4 +157,71 @@ abstract class DescribeTableTestBase extends PaimonSparkTestBase {
     // check comment in schema
     Assertions.assertTrue(Objects.equals(comment, loadTable(tableName).schema().comment()))
   }
+
+  protected def describeTablePartitionCreateTable(): Unit = {
+    spark.sql("""
+                |CREATE TABLE T (
+                |  id INT NOT NULL,
+                |  name STRING DEFAULT 'Bob',
+                |  age INT COMMENT 'Age')
+                |  PARTITIONED BY (year INT COMMENT 'Year', month INT, day INT)
+                |""".stripMargin)
+  }
+
+  protected def describeTablePartitionCheckDefaultValue(res: DataFrame): Unit = {
+    checkAnswer(
+      res
+        .filter("col_name = 'name' AND comment != ''")
+        .select("col_name", "data_type", "comment"),
+      Row("name", "string", "'Bob'") :: Nil
+    )
+  }
+
+  test("Paimon describe: describe table partition") {
+    describeTablePartitionCreateTable()

Review Comment:
   This is the only place which call `describeTablePartitionCreateTable`, so shall we create table here directly without any function call.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "YannByron (via GitHub)" <gi...@apache.org>.
YannByron commented on code in PR #6359:
URL: https://github.com/apache/paimon/pull/6359#discussion_r2419928476


##########
paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DescribeTableTestBase.scala:
##########
@@ -156,4 +157,71 @@ abstract class DescribeTableTestBase extends PaimonSparkTestBase {
     // check comment in schema
     Assertions.assertTrue(Objects.equals(comment, loadTable(tableName).schema().comment()))
   }
+
+  protected def describeTablePartitionCreateTable(): Unit = {

Review Comment:
   This method don't have to be overwritten by sub-classes, right ?



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "liujiayi771 (via GitHub)" <gi...@apache.org>.
liujiayi771 commented on PR #6359:
URL: https://github.com/apache/paimon/pull/6359#issuecomment-3354860743

   cc @Zouxxyy @YannByron


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "liujiayi771 (via GitHub)" <gi...@apache.org>.
liujiayi771 commented on code in PR #6359:
URL: https://github.com/apache/paimon/pull/6359#discussion_r2422362628


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/spark/sql/execution/PaimonDescribeTableExec.scala:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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
+
+import org.apache.paimon.partition.PartitionStatistics
+import org.apache.paimon.spark.SparkTable
+import org.apache.paimon.spark.catalog.SparkBaseCatalog
+import org.apache.paimon.spark.leafnode.PaimonLeafV2CommandExec
+import org.apache.paimon.spark.utils.CatalogUtils.{checkNamespace, toIdentifier}
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.catalog.{CatalogStatistics, CatalogStorageFormat, CatalogTablePartition, CatalogTableType}
+import org.apache.spark.sql.catalyst.catalog.CatalogTypes.TablePartitionSpec
+import org.apache.spark.sql.catalyst.expressions.Attribute
+import org.apache.spark.sql.catalyst.util.quoteIfNeeded
+import org.apache.spark.sql.connector.catalog.{CatalogV2Util, Identifier, SupportsMetadataColumns, TableCatalog}
+import org.apache.spark.sql.connector.expressions.IdentityTransform
+import org.apache.spark.sql.types.StructType
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+case class PaimonDescribeTableExec(
+    output: Seq[Attribute],
+    catalog: SparkBaseCatalog,
+    identifier: Identifier,
+    table: SparkTable,
+    partitionSpec: TablePartitionSpec,
+    isExtended: Boolean)
+  extends PaimonLeafV2CommandExec {
+
+  override protected def run(): Seq[InternalRow] = {

Review Comment:
   `DescribeTableExec.run` is protected.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "Zouxxyy (via GitHub)" <gi...@apache.org>.
Zouxxyy merged PR #6359:
URL: https://github.com/apache/paimon/pull/6359


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [spark] Paimon Spark support describe table partition [paimon]

Posted by "YannByron (via GitHub)" <gi...@apache.org>.
YannByron commented on code in PR #6359:
URL: https://github.com/apache/paimon/pull/6359#discussion_r2425324462


##########
paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/DescribeTableTestBase.scala:
##########
@@ -156,4 +157,71 @@ abstract class DescribeTableTestBase extends PaimonSparkTestBase {
     // check comment in schema
     Assertions.assertTrue(Objects.equals(comment, loadTable(tableName).schema().comment()))
   }
+
+  protected def describeTablePartitionCreateTable(): Unit = {
+    spark.sql("""
+                |CREATE TABLE T (
+                |  id INT NOT NULL,
+                |  name STRING DEFAULT 'Bob',
+                |  age INT COMMENT 'Age')
+                |  PARTITIONED BY (year INT COMMENT 'Year', month INT, day INT)
+                |""".stripMargin)
+  }
+
+  protected def describeTablePartitionCheckDefaultValue(res: DataFrame): Unit = {
+    checkAnswer(
+      res
+        .filter("col_name = 'name' AND comment != ''")
+        .select("col_name", "data_type", "comment"),
+      Row("name", "string", "'Bob'") :: Nil
+    )
+  }
+
+  test("Paimon describe: describe table partition") {
+    describeTablePartitionCreateTable()

Review Comment:
   ok



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org