You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "bowenliang123 (via GitHub)" <gi...@apache.org> on 2023/06/01 03:27:15 UTC

[GitHub] [kyuubi] bowenliang123 opened a new pull request, #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter crossing supported extractor types

bowenliang123 opened a new pull request, #4914:
URL: https://github.com/apache/kyuubi/pull/4914

   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/CONTRIBUTING.html
     2. If the PR is related to an issue in https://github.com/apache/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### _Why are the changes needed?_
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you add a feature, you can talk about the use case of it.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   - Reuse extractor singleton instance for less memory footprint, as Authz's extractors are stateless and ready for sharing
   - Reneralized getter crossing supported extractor types
      - get extractor by class type
      - get extractor by explicit class name
   
   ### _How was this patch tested?_
   - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
   
   - [ ] Add screenshots for manual tests if appropriate
   
   - [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
   


-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217403547


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  def getExtractor[T <: Extractor](implicit ct: ClassTag[T]): T =
+    getExtractor[T](extractorKey = null)(ct)
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def getExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   `lookupExtractor` is more accurate for this case



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217421216


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def lookupExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   Made `extractorKey` not null by default.



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217413638


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def lookupExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   `extractorKey: String = null` => `extractorKey: Option[String] = None`



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#issuecomment-1576055868

   Thanks, merged to master.


-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217412118


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  def getExtractor[T <: Extractor](implicit ct: ClassTag[T]): T =
+    getExtractor[T](extractorKey = null)(ct)

Review Comment:
   Adopted.



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] codecov-commenter commented on pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#issuecomment-1571356029

   ## [Codecov](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#4914](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (51c02bf) into [master](https://app.codecov.io/gh/apache/kyuubi/commit/cf886c96765971403afd2f271c9d5a5d9f8620b4?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (cf886c9) will **not change** coverage.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@          Coverage Diff           @@
   ##           master   #4914   +/-   ##
   ======================================
     Coverage    0.00%   0.00%           
   ======================================
     Files         557     557           
     Lines       30694   30708   +14     
     Branches     3995    4004    +9     
   ======================================
   - Misses      30694   30708   +14     
   ```
   
   
   | [Impacted Files](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...e/kyuubi/plugin/spark/authz/serde/Descriptor.scala](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXh0ZW5zaW9ucy9zcGFyay9reXV1Ymktc3BhcmstYXV0aHovc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvcGx1Z2luL3NwYXJrL2F1dGh6L3NlcmRlL0Rlc2NyaXB0b3Iuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...i/plugin/spark/authz/serde/catalogExtractors.scala](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXh0ZW5zaW9ucy9zcGFyay9reXV1Ymktc3BhcmstYXV0aHovc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvcGx1Z2luL3NwYXJrL2F1dGh6L3NlcmRlL2NhdGFsb2dFeHRyYWN0b3JzLnNjYWxh) | `0.00% <0.00%> (ø)` | |
   | [.../plugin/spark/authz/serde/databaseExtractors.scala](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXh0ZW5zaW9ucy9zcGFyay9reXV1Ymktc3BhcmstYXV0aHovc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvcGx1Z2luL3NwYXJrL2F1dGh6L3NlcmRlL2RhdGFiYXNlRXh0cmFjdG9ycy5zY2FsYQ==) | `0.00% <0.00%> (ø)` | |
   | [...gin/spark/authz/serde/functionTypeExtractors.scala](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXh0ZW5zaW9ucy9zcGFyay9reXV1Ymktc3BhcmstYXV0aHovc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvcGx1Z2luL3NwYXJrL2F1dGh6L3NlcmRlL2Z1bmN0aW9uVHlwZUV4dHJhY3RvcnMuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...ache/kyuubi/plugin/spark/authz/serde/package.scala](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXh0ZW5zaW9ucy9zcGFyay9reXV1Ymktc3BhcmstYXV0aHovc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvcGx1Z2luL3NwYXJrL2F1dGh6L3NlcmRlL3BhY2thZ2Uuc2NhbGE=) | `0.00% <0.00%> (ø)` | |
   | [...ubi/plugin/spark/authz/serde/tableExtractors.scala](https://app.codecov.io/gh/apache/kyuubi/pull/4914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXh0ZW5zaW9ucy9zcGFyay9reXV1Ymktc3BhcmstYXV0aHovc3JjL21haW4vc2NhbGEvb3JnL2FwYWNoZS9reXV1YmkvcGx1Z2luL3NwYXJrL2F1dGh6L3NlcmRlL3RhYmxlRXh0cmFjdG9ycy5zY2FsYQ==) | `0.00% <0.00%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1212603841


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  def getExtractor[T <: Extractor](implicit ct: ClassTag[T]): T =
+    getExtractor[T](extractorKey = null)(ct)
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def getExtractor[T <: Extractor](extractorKey: String = null)(
+      implicit ct: ClassTag[T]): T = {
+    val extractorClass = ct.runtimeClass
+    val extractors: Map[String, Extractor] = extractorClass match {
+      case c if classOf[CatalogExtractor].isAssignableFrom(c) => catalogExtractors
+      case c if classOf[DatabaseExtractor].isAssignableFrom(c) => dbExtractors
+      case c if classOf[TableExtractor].isAssignableFrom(c) => tableExtractors
+      case c if classOf[TableTypeExtractor].isAssignableFrom(c) => tableTypeExtractors
+      case c if classOf[ColumnExtractor].isAssignableFrom(c) => columnExtractors
+      case c if classOf[QueryExtractor].isAssignableFrom(c) => queryExtractors
+      case c if classOf[FunctionExtractor].isAssignableFrom(c) => functionExtractors
+      case c if classOf[FunctionTypeExtractor].isAssignableFrom(c) => functionTypeExtractors
+      case c if classOf[ActionTypeExtractor].isAssignableFrom(c) => actionTypeExtractors

Review Comment:
   Is there any better way in more scala style for matching class type here ?
   Or shall we just load the extractor from all the possible extractor mapss regardless of theextractor type here.
   cc @yaooqinn @pan3793 



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217411805


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  def getExtractor[T <: Extractor](implicit ct: ClassTag[T]): T =
+    getExtractor[T](extractorKey = null)(ct)
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def getExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   Adopted.



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217416908


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def lookupExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   Adopted.



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217421657


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -115,9 +115,9 @@ package object serde {
       case c if classOf[ActionTypeExtractor].isAssignableFrom(c) => actionTypeExtractors
       case _ => throw new IllegalArgumentException(s"Unknown extractor type: $ct")
     }
-    extractors(extractorKey.getOrElse(extractorClass.getSimpleName)).asInstanceOf[T]
+    extractors(Option(extractorKey).getOrElse(extractorClass.getSimpleName)).asInstanceOf[T]

Review Comment:
   ```suggestion
       extractors(extractorKey).asInstanceOf[T]
   ```



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#issuecomment-1571282079

   also cc @zhouyifan279 


-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217416908


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def lookupExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   Adopted.



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217401656


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  def getExtractor[T <: Extractor](implicit ct: ClassTag[T]): T =
+    getExtractor[T](extractorKey = null)(ct)

Review Comment:
   how about calculating the `extractorKey` in this place? to avoid `null` propagation



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 closed pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 closed pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types
URL: https://github.com/apache/kyuubi/pull/4914


-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] bowenliang123 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217422560


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -115,9 +115,9 @@ package object serde {
       case c if classOf[ActionTypeExtractor].isAssignableFrom(c) => actionTypeExtractors
       case _ => throw new IllegalArgumentException(s"Unknown extractor type: $ct")
     }
-    extractors(extractorKey.getOrElse(extractorClass.getSimpleName)).asInstanceOf[T]
+    extractors(Option(extractorKey).getOrElse(extractorClass.getSimpleName)).asInstanceOf[T]

Review Comment:
   Adopted.



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [kyuubi] pan3793 commented on a diff in pull request #4914: [AUTHZ] Reuse extractor singleton instance with generalized getter for supported extractor types

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #4914:
URL: https://github.com/apache/kyuubi/pull/4914#discussion_r1217413638


##########
extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/package.scala:
##########
@@ -82,4 +91,33 @@ package object serde {
       .map(s => s.operationType)
       .getOrElse(QUERY)
   }
+
+  /**
+   * get extractor instance by extractor class name
+   * @param extractorKey explicitly load extractor by its simple class name.
+   *                           null by default means get extractor by extractor class.
+   * @param ct class tag of extractor class type
+   * @tparam T extractor class type
+   * @return
+   */
+  def lookupExtractor[T <: Extractor](extractorKey: String = null)(

Review Comment:
   extractorKey can not be null then?



-- 
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: notifications-unsubscribe@kyuubi.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org