Skip to content

Commit

Permalink
[KYUUBI #4115] [Authz] remove usage of ClassTagExtensions and make …
Browse files Browse the repository at this point in the history
…dependency `jackson-module-scala` in `provided` scope

### _Why are the changes needed?_

- to fix #4102
- remove usage of ClassTagExtensions for better compatibility to `jackson-module-scala`
- `spark-core` of Spark 3.x's core already has dependency on `com.fasterxml.jackson.module:jackson-module-scala_${scala.binary.version}`
- change the scope of `com.fasterxml.jackson.module:jackson-module-scala_${scala.binary.version}` to `provided`

### _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.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #4115 from bowenliang123/authz-jackson-provided.

Closes #4115

5d20ece [liangbowen] style
d4eb245 [liangbowen] Revert "ensure the earliest version of fasterxml.jackson provided in Spark 3.x"
112bb84 [liangbowen] ensure the earliest version of fasterxml.jackson provided in Spark 3.x
b481014 [liangbowen] remove usage of ClassTagExtensions for better compatibility to `jackson-module-scala` lib
0487674 [liangbowen] change the scope of `com.fasterxml.jackson.module:jackson-module-scala_${scala.binary.version}` to `provided`

Authored-by: liangbowen <liangbowen@gf.com.cn>
Signed-off-by: Cheng Pan <chengpan@apache.org>
  • Loading branch information
bowenliang123 authored and pan3793 committed Jan 7, 2023
1 parent daa8d45 commit beba36e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions extensions/spark/kyuubi-spark-authz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_${scala.binary.version}</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@

package org.apache.kyuubi.plugin.spark.authz

import com.fasterxml.jackson.core.`type`.TypeReference
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.scala.{ClassTagExtensions, DefaultScalaModule}
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan

import org.apache.kyuubi.plugin.spark.authz.OperationType.{OperationType, QUERY}

package object serde {

final val mapper = JsonMapper.builder()
.addModule(DefaultScalaModule)
.build() :: ClassTagExtensions
final val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build()

final lazy val DB_COMMAND_SPECS: Map[String, DatabaseCommandSpec] = {
val is = getClass.getClassLoader.getResourceAsStream("database_command_spec.json")
mapper.readValue[Array[DatabaseCommandSpec]](is).map(e => (e.classname, e)).toMap
mapper.readValue(is, new TypeReference[Array[DatabaseCommandSpec]] {})
.map(e => (e.classname, e)).toMap
}

final lazy val TABLE_COMMAND_SPECS: Map[String, TableCommandSpec] = {
val is = getClass.getClassLoader.getResourceAsStream("table_command_spec.json")
mapper.readValue[Array[TableCommandSpec]](is).map(e => (e.classname, e)).toMap
mapper.readValue(is, new TypeReference[Array[TableCommandSpec]] {})
.map(e => (e.classname, e)).toMap
}

def isKnownTableCommand(r: AnyRef): Boolean = {
Expand All @@ -49,12 +50,14 @@ package object serde {

final lazy val FUNCTION_COMMAND_SPECS: Map[String, FunctionCommandSpec] = {
val is = getClass.getClassLoader.getResourceAsStream("function_command_spec.json")
mapper.readValue[Array[FunctionCommandSpec]](is).map(e => (e.classname, e)).toMap
mapper.readValue(is, new TypeReference[Array[FunctionCommandSpec]] {})
.map(e => (e.classname, e)).toMap
}

final private lazy val SCAN_SPECS: Map[String, ScanSpec] = {
val is = getClass.getClassLoader.getResourceAsStream("scan_command_spec.json")
mapper.readValue[Array[ScanSpec]](is).map(e => (e.classname, e)).toMap
mapper.readValue(is, new TypeReference[Array[ScanSpec]] {})
.map(e => (e.classname, e)).toMap
}

def isKnownScan(r: AnyRef): Boolean = {
Expand Down

0 comments on commit beba36e

Please sign in to comment.