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/09 14:02:01 UTC

[GitHub] [kyuubi] bowenliang123 opened a new pull request, #4134: [Authz] Code improvement in Authz Serde

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

   <!--
   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.
   -->
   
   Code imporements in Authz's Serde:
   1. add implicit `actionTypeStr` for converting `PrivilegeObjectActionType` to String, preventing use magic values of PrivilegeObjectActionType name
   2. simplify `ActionTypeDesc` contrustor with default values
   3. add class hints for method comments of `extractors`
   
   
   ### _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
   
   - [ ] [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 #4134: [Authz] Code improvement in Authz Serde extractors and commands

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

   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 pull request #4134: [Authz] Code improvement in Authz Serde extractors and commands

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

   I tried but fail to generalize method `readCommandSpecToMap` in `org.apache.kyuubi.plugin.spark.authz.serde` object. 
   
   Change:
   ```scala
     final lazy val DB_COMMAND_SPECS: Map[String, DatabaseCommandSpec] = {
       val is = getClass.getClassLoader.getResourceAsStream("database_command_spec.json")
       mapper.readValue(is, new TypeReference[Array[DatabaseCommandSpec]] {})
         .map(e => (e.classname, e)).toMap
     }
   ```
   
   To:
   ```scala
     def readCommandSpecToMap[T <: CommandSpec](file: String): Map[String, T] = {
       val is = getClass.getClassLoader.getResourceAsStream(file)
       mapper.readValue(is, new TypeReference[Array[T]] {})
         .map(e => (e.classname, e)).toMap
     }
   
     final lazy val DB_COMMAND_SPECS: Map[String, DatabaseCommandSpec] = {
       readCommandSpecToMap[DatabaseCommandSpec]("database_command_spec.json")
     }
   ```
   
   Compilation: Pass
   
   Most of tests failed with exceptions:
   
   ```scala
   - AlterTableSetLocationCommand *** FAILED ***
     com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.apache.kyuubi.plugin.spark.authz.serde.CommandSpec` 
   (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
    at [Source: (BufferedInputStream); line: 1, column: 3] (through reference chain: java.lang.Object[][0])
     at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
     at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1909)
     at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:408)
     at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1354)
     at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:274)
     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:216)
     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:26)
     at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
     at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4730)
     at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3722)
     ...
   
   ```
   
   So this generaliztion will be skipped and left as it is.


-- 
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 #4134: [Authz] Code improvement in Authz Serde extractors and commands

Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #4134: [Authz] Code improvement in Authz Serde extractors and commands
URL: https://github.com/apache/kyuubi/pull/4134


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