You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "askwang (via GitHub)" <gi...@apache.org> on 2024/10/13 11:49:29 UTC

[PR] [spark] Add show tags sql syntax [paimon]

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

   <!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
   
   ### Purpose
   
   Add show tags sql syntax like show partitions. 
   ```
   show tags table_identifier
   ```
   
   <!-- What is the purpose of the change -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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] Add show tags sql syntax [paimon]

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


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/PaimonStrategy.scala:
##########
@@ -18,16 +18,25 @@
 
 package org.apache.paimon.spark.execution
 
-import org.apache.paimon.spark.catalyst.plans.logical.PaimonCallCommand
+import org.apache.paimon.spark.{SparkCatalog, SparkUtils}
+import org.apache.paimon.spark.catalyst.plans.logical.{PaimonCallCommand, ShowTagsCommand}
 
 import org.apache.spark.sql.{SparkSession, Strategy}
 import org.apache.spark.sql.catalyst.InternalRow
 import org.apache.spark.sql.catalyst.expressions.{Expression, GenericInternalRow, PredicateHelper}
 import org.apache.spark.sql.catalyst.plans.logical.{CreateTableAsSelect, LogicalPlan}
+import org.apache.spark.sql.connector.catalog.{CatalogManager, Identifier, PaimonLookupCatalog, TableCatalog}
 import org.apache.spark.sql.execution.SparkPlan
 import org.apache.spark.sql.execution.shim.PaimonCreateTableAsSelectStrategy
 
-case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHelper {
+import scala.collection.JavaConverters._
+
+case class PaimonStrategy(spark: SparkSession)
+  extends Strategy
+  with PredicateHelper
+  with PaimonLookupCatalog {
+
+  protected lazy val catalogManager = spark.sessionState.catalogManager

Review Comment:
   Protected type is inherited from the parent interface `PaimonLookupCatalog`, cannot be changed.
   
   Type annotation means that you need to specify the variable type like `val catalogManager : CatalogManager`, but class CatalogManager is inaccessible from here due to the limitation of package name.
   



-- 
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] Add show tags sql syntax [paimon]

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

   +1


-- 
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] Add show tags sql syntax [paimon]

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

   > Could you add this syntax in doc https://paimon.apache.org/docs/master/spark/sql-ddl/ ?
   
   doc added. and addressed comments, thanks @wwj6591812 


-- 
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] Add show tags sql syntax [paimon]

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

   +1


-- 
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] Add show tags sql syntax [paimon]

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


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/PaimonStrategy.scala:
##########
@@ -48,4 +59,16 @@ case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHe
     new GenericInternalRow(values)
   }
 
+  private object PaimonCatalogAndIdentifier {

Review Comment:
   It's an extractor object  with an unapply method in Scala, not a member method of class PaimonStrategy.



-- 
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] Add show tags sql syntax [paimon]

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


-- 
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] Add show tags sql syntax [paimon]

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


##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/ShowTagsExec.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.paimon.spark.execution
+
+import org.apache.paimon.spark.SparkTable
+import org.apache.paimon.spark.leafnode.PaimonLeafV2CommandExec
+import org.apache.paimon.table.FileStoreTable
+
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.expressions.Attribute
+import org.apache.spark.sql.connector.catalog.{Identifier, TableCatalog}
+import org.apache.spark.unsafe.types.UTF8String
+
+import scala.collection.JavaConverters._
+
+case class ShowTagsExec(catalog: TableCatalog, ident: Identifier, out: Seq[Attribute])
+  extends PaimonLeafV2CommandExec {
+
+  override protected def run(): Seq[InternalRow] = {
+    val table = catalog.loadTable(ident)
+    assert(table.isInstanceOf[SparkTable])
+
+    var tags: Seq[InternalRow] = Nil
+    table.asInstanceOf[SparkTable].getTable match {
+      case paimonTable: FileStoreTable =>
+        val tagNames = paimonTable.tagManager().allTagNames()
+        tags = tagNames.asScala.toList.sorted.map(t => InternalRow(UTF8String.fromString(t)))
+      case t =>
+        throw new UnsupportedOperationException(s"Can not show tags for non-paimon table: $t")

Review Comment:
   Can not show tags for non-paimon FileStoreTable



##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/PaimonStrategy.scala:
##########
@@ -18,16 +18,25 @@
 
 package org.apache.paimon.spark.execution
 
-import org.apache.paimon.spark.catalyst.plans.logical.PaimonCallCommand
+import org.apache.paimon.spark.{SparkCatalog, SparkUtils}
+import org.apache.paimon.spark.catalyst.plans.logical.{PaimonCallCommand, ShowTagsCommand}
 
 import org.apache.spark.sql.{SparkSession, Strategy}
 import org.apache.spark.sql.catalyst.InternalRow
 import org.apache.spark.sql.catalyst.expressions.{Expression, GenericInternalRow, PredicateHelper}
 import org.apache.spark.sql.catalyst.plans.logical.{CreateTableAsSelect, LogicalPlan}
+import org.apache.spark.sql.connector.catalog.{CatalogManager, Identifier, PaimonLookupCatalog, TableCatalog}
 import org.apache.spark.sql.execution.SparkPlan
 import org.apache.spark.sql.execution.shim.PaimonCreateTableAsSelectStrategy
 
-case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHelper {
+import scala.collection.JavaConverters._
+
+case class PaimonStrategy(spark: SparkSession)
+  extends Strategy
+  with PredicateHelper
+  with PaimonLookupCatalog {
+
+  protected lazy val catalogManager = spark.sessionState.catalogManager

Review Comment:
   1、Why protected?
   2、In my idea, it says : "Type annotation required for protected member".
   



##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/PaimonStrategy.scala:
##########
@@ -37,6 +46,8 @@ case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHe
     case c @ PaimonCallCommand(procedure, args) =>
       val input = buildInternalRow(args)
       PaimonCallExec(c.output, procedure, input) :: Nil

Review Comment:
   Add a blank line?



##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/PaimonStrategy.scala:
##########
@@ -48,4 +59,16 @@ case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHe
     new GenericInternalRow(values)
   }
 
+  private object PaimonCatalogAndIdentifier {

Review Comment:
   Why not paimonCatalogAndIdentifier?



##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/execution/PaimonStrategy.scala:
##########
@@ -48,4 +59,16 @@ case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHe
     new GenericInternalRow(values)
   }
 
+  private object PaimonCatalogAndIdentifier {
+    def unapply(identifier: Seq[String]): Option[(TableCatalog, Identifier)] = {
+      val catalogAndIdentifer =

Review Comment:
   catalogAndIdentifier



-- 
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] Add show tags sql syntax [paimon]

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

   Could you add this syntax in doc https://paimon.apache.org/docs/master/spark/sql-ddl/ ?


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