You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2023/01/04 10:18:01 UTC

[GitHub] [kyuubi] bowenliang123 opened a new pull request, #4084: [Authz] generalize `extractorName` method preventing use String or class name directly

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

   <!--
   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.
   -->
   
   - generalize `extractorName` method
   - increase compilation alignment to extractor itself, and easier use for future third party adaptation
   - preventing use String or class name as magic value directly which easily causes mistakes
   - no changes with spec JSON file regeneration after this PR 
   
   
   ### _How was this patch tested?_
   - [x] 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.apache.org/docs/latest/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] yaooqinn commented on pull request #4084: [Authz] Implicitly extracting name of Extractors and OperationType in spec file generation preventing use class name String directly

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#issuecomment-1371815756

   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] yaooqinn commented on pull request #4084: [Authz] generalize `extractorName` method preventing use class name or getSimpleName directly

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#issuecomment-1371704194

   The extractor name has not necessarily to be simple classname


-- 
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 #4084: [Authz] generalize `extractorName` method preventing use class name or getSimpleName directly

Posted by GitBox <gi...@apache.org>.
bowenliang123 commented on PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#issuecomment-1371708713

   > The extractor name has not necessarily to be simple classname
   
   Or let's change the method name to `classSimpleName` in AuthzUtils ?


-- 
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] yaooqinn commented on a diff in pull request #4084: [Authz] generalize `extractorName` method preventing use class name or getSimpleName directly

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#discussion_r1062078942


##########
extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/package.scala:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.kyuubi.plugin.spark.authz
+
+import scala.reflect.ClassTag
+
+package object gen {
+  implicit def classSimpleName[T](implicit ct: ClassTag[T]): String = {

Review Comment:
   If you define it in such a way and call it explicitly, the `implicit` here is not necessary



-- 
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] yaooqinn closed pull request #4084: [Authz] Implicitly extracting name of Extractors and OperationType in spec file generation preventing use class name String directly

Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #4084: [Authz] Implicitly extracting name of Extractors and OperationType in spec file generation preventing use class name String directly
URL: https://github.com/apache/kyuubi/pull/4084


-- 
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] yaooqinn commented on pull request #4084: [Authz] generalize `extractorName` method preventing use class name or getSimpleName directly

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#issuecomment-1371733707

   Let's define an `implicit def` in the test package instead of `AuthZUtils`. Maybe a package object in `o.a.k.p.s.a.gen` or `JsonSpecFileGenerator`  
   
   ```scala  
   implicit def classSimpleName[T](clz: Class[_]): String = clz.getSimpleName
   ```
   
   And then, we can use it on the caller side like 
   ```scala
   DatabaseDesc("databaseName", classOf[StringDatabaseExtractor])
   ```
   
   Similarly, we can also have an `implicit def` for OperationType
   
   ```scala
   implicit def operationTypeStr(t: OperationType): String = t.toString
   ```


-- 
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 #4084: [Authz] generalize `extractorName` method preventing use class name or getSimpleName directly

Posted by GitBox <gi...@apache.org>.
bowenliang123 commented on code in PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#discussion_r1062088404


##########
extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/package.scala:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.kyuubi.plugin.spark.authz
+
+import scala.reflect.ClassTag
+
+package object gen {
+  implicit def classSimpleName[T](implicit ct: ClassTag[T]): String = {

Review Comment:
   OK, let's use it in an implicit way as you suggested example above.



-- 
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 #4084: [Authz] generalize `extractorName` method preventing use class name or getSimpleName directly

Posted by GitBox <gi...@apache.org>.
bowenliang123 commented on PR #4084:
URL: https://github.com/apache/kyuubi/pull/4084#issuecomment-1370737838

   cc @yaooqinn 


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