Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shade Jackson to avoid class conflict #153

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ subprojects {
force "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
force "com.fasterxml.jackson.core:jackson-core:$jackson_version"
force "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
force "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
force "com.fasterxml.jackson.module:jackson-module-paranamer:$jackson_version"
force "com.fasterxml.jackson.module:jackson-module-scala_$scala_binary_version:$jackson_version"

Expand Down Expand Up @@ -164,6 +165,7 @@ project(':clickhouse-core') {
api "org.apache.commons:commons-lang3:$commons_lang3_version"

api "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
api "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
api "com.fasterxml.jackson.module:jackson-module-scala_$scala_binary_version:$jackson_version"

api("com.google.guava:guava:$guava_version") {
Expand Down
7 changes: 5 additions & 2 deletions spark-3.2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version
exclude group: "org.scala-lang", module: "scala-library"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.apache.commons", module: "commons-lang3"
exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
exclude group: "com.fasterxml.jackson.module", module: "jackson-module-scala_$scala_binary_version"
}
}

Expand All @@ -55,7 +53,9 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version
exclude "META-INF/native/**"
exclude "META-INF/native-image/**"

relocate "com.fasterxml.jackson", "xenon.relocated.com.fasterxml.jackson"
relocate "com.google", "xenon.relocated.com.google"
relocate "com.thoughtworks.paranamer", "xenon.relocated.com.thoughtworks.paranamer"
relocate "io.grpc", "xenon.relocated.io.grpc"
relocate "io.perfmark", "xenon.relocated.io.perfmark"

Expand All @@ -82,7 +82,10 @@ project(":clickhouse-spark-it-${spark_binary_version}_$scala_binary_version") {

testImplementation "org.apache.spark:spark-sql_$scala_binary_version:$spark_version"
testImplementation "org.apache.spark:spark-sql_$scala_binary_version:$spark_version:tests"

testImplementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
testImplementation "com.fasterxml.jackson.module:jackson-module-scala_$scala_binary_version:$jackson_version"

if (scala_binary_version == "2.12") {
testImplementation "org.apache.kyuubi:kyuubi-spark-connector-tpcds_${scala_binary_version}:1.6.0-SNAPSHOT"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed 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
*
* https://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.spark.sql.clickhouse

import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.module.scala.ClassTagExtensions

object TestUtils {

@transient lazy val om: ObjectMapper with ClassTagExtensions = {
val _om = new ObjectMapper() with ClassTagExtensions
_om.findAndRegisterModules()
_om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
_om
}

def toJson(value: Any): String = om.writeValueAsString(value)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

package org.apache.spark.sql.clickhouse.cluster

import xenon.clickhouse.JsonProtocol.om
import xenon.clickhouse.base.ClickHouseClusterMixIn
import xenon.clickhouse.Logging

import java.lang.{Long => JLong}
import org.apache.spark.sql.clickhouse.BaseSparkSuite
import org.apache.spark.sql.clickhouse.TestUtils.om

class ClickHouseClusterUDFSuite extends BaseSparkSuite
with ClickHouseClusterMixIn
Expand Down
7 changes: 5 additions & 2 deletions spark-3.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version
exclude group: "org.scala-lang", module: "scala-library"
exclude group: "org.slf4j", module: "slf4j-api"
exclude group: "org.apache.commons", module: "commons-lang3"
exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
exclude group: "com.fasterxml.jackson.module", module: "jackson-module-scala_$scala_binary_version"
}
}

Expand All @@ -55,7 +53,9 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version
exclude "META-INF/native/**"
exclude "META-INF/native-image/**"

relocate "com.fasterxml.jackson", "xenon.relocated.com.fasterxml.jackson"
relocate "com.google", "xenon.relocated.com.google"
relocate "com.thoughtworks.paranamer", "xenon.relocated.com.thoughtworks.paranamer"
relocate "io.grpc", "xenon.relocated.io.grpc"
relocate "io.perfmark", "xenon.relocated.io.perfmark"

Expand All @@ -82,7 +82,10 @@ project(":clickhouse-spark-it-${spark_binary_version}_$scala_binary_version") {

testImplementation "org.apache.spark:spark-sql_$scala_binary_version:$spark_version"
testImplementation "org.apache.spark:spark-sql_$scala_binary_version:$spark_version:tests"

testImplementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
testImplementation "com.fasterxml.jackson.module:jackson-module-scala_$scala_binary_version:$jackson_version"

if (scala_binary_version == "2.12") {
testImplementation "org.apache.kyuubi:kyuubi-spark-connector-tpcds_${scala_binary_version}:1.6.0-SNAPSHOT"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed 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
*
* https://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.spark.sql.clickhouse

import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.module.scala.ClassTagExtensions

object TestUtils {

@transient lazy val om: ObjectMapper with ClassTagExtensions = {
val _om = new ObjectMapper() with ClassTagExtensions
_om.findAndRegisterModules()
_om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
_om
}

def toJson(value: Any): String = om.writeValueAsString(value)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

package org.apache.spark.sql.clickhouse.cluster

import xenon.clickhouse.JsonProtocol.om
import xenon.clickhouse.base.ClickHouseClusterMixIn
import xenon.clickhouse.Logging

import java.lang.{Long => JLong}
import org.apache.spark.sql.clickhouse.BaseSparkSuite
import org.apache.spark.sql.clickhouse.TestUtils.om

class ClickHouseClusterUDFSuite extends BaseSparkSuite
with ClickHouseClusterMixIn
Expand Down