Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
13 changes: 10 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ jobs:
fail-fast: false
matrix:
java: [ 8, 17 ]
scala: [ 2.12, 2.13 ]
spark: [ 3.3, 3.4, 3.5 ]
scala: [ '2.12', '2.13' ]
spark: [ '3.3', '3.4', '3.5', '4.0' ]
exclude:
# Spark 4.0 only supports Scala 2.13
- spark: '4.0'
scala: '2.12'
# Spark 4.0 requires Java 11+
- spark: '4.0'
java: 8
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down Expand Up @@ -58,7 +65,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
java-version: 17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can merge run-tests and run-tests-with-specific-clickhouse into one test. Do you know what version we are running on run-tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run-tests run on 23.8 (the default version in the ClickHouseSingleMixIn file).
We could merge them into one test but then we'll need to update the matrix that would run all tests on all CH versions (might actually be a good idea but it'll create a lot of new tests. maybe we should change this only when we fix the tests so that they will be able to run concurrently)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this test is against local ClickHouse, not the cloud, so it does not have the concurrency issue

cache: gradle
- run: >-
./gradlew clean test --no-daemon --refresh-dependencies
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/check-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@ jobs:
strategy:
fail-fast: false
matrix:
spark: [ 3.3, 3.4, 3.5 ]
spark: [ "3.3", "3.4", "3.5", "4.0" ]
include:
- spark: "3.3"
java: 8
- spark: "3.4"
java: 8
- spark: "3.5"
java: 8
- spark: "4.0"
java: 17
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
java-version: ${{ matrix.java }}
- run: >-
./gradlew rat --no-daemon
-Dspark_binary_version=${{ matrix.spark }}
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,21 @@ jobs:
max-parallel: 1
fail-fast: false
matrix:
spark: [ 3.3, 3.4, 3.5 ]
scala: [ 2.12, 2.13 ]
spark: [ '3.3', '3.4', '3.5', '4.0' ]
scala: [ '2.12', '2.13' ]
java: [ 8 ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not java: [ 8, 17 ]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again this would cause many more versions of the tests to run (today it is only running 8).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'am ok with that since we might have a so feature that is not supported in 8 that can break so it better to test

include:
# Spark 4.0 requires Java 11+ (using Java 17)
- spark: '4.0'
scala: '2.13'
java: 17
exclude:
# Spark 4.0 only supports Scala 2.13
- spark: '4.0'
scala: '2.12'
# Spark 4.0 requires Java 11+
- spark: '4.0'
java: 8
env:
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
Expand All @@ -44,7 +57,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
java-version: ${{ matrix.java }}
cache: gradle
- name: Wake up ClickHouse Cloud instance
env:
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ jobs:
strategy:
fail-fast: false
matrix:
spark: [ 3.3, 3.4, 3.5 ]
spark: [ "3.3", "3.4", "3.5", "4.0" ]
include:
- spark: "3.3"
java: 8
- spark: "3.4"
java: 8
- spark: "3.5"
java: 8
- spark: "4.0"
java: 17
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
java-version: ${{ matrix.java }}
cache: gradle
- run: >-
./gradlew spotlessCheck --no-daemon --refresh-dependencies
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/tpcds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,27 @@ jobs:
strategy:
fail-fast: false
matrix:
spark: [ 3.3, 3.4, 3.5 ]
scala: [ 2.12, 2.13 ]
spark: [ '3.3', '3.4', '3.5', '4.0' ]
scala: [ '2.12', '2.13' ]
java: [ 8 ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here java: [ 8, 17 ]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment

include:
# Spark 4.0 requires Java 11+ (using Java 17)
- spark: '4.0'
scala: '2.13'
java: 17
exclude:
# Spark 4.0 only supports Scala 2.13
- spark: '4.0'
scala: '2.12'
# Spark 4.0 requires Java 11+
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Spark 4.0 requires Java 11+
# Spark 4.0 requires Java 17+

- spark: '4.0'
java: 8
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 8
java-version: ${{ matrix.java }}
cache: gradle
- run: >-
./gradlew clean slowTest --no-daemon --refresh-dependencies
Expand Down
18 changes: 12 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ allprojects {
subprojects {
apply plugin: "scala"
apply plugin: "java-library"
apply plugin: "org.scoverage"
// Disable scoverage when running Metals' bloopInstall to avoid plugin resolution issues
def isBloopInstall = gradle.startParameter.taskNames.any { it.contains('bloopInstall') }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check if it does not affect IntelliJ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't affect as IntelliJ uses its own build server and it doesn't use Bloop at all

if (!project.hasProperty('disableScoverage') && !isBloopInstall) {
apply plugin: "org.scoverage"
}
apply plugin: "com.diffplug.spotless"
apply plugin: "com.github.maiflai.scalatest"

Expand Down Expand Up @@ -168,11 +172,13 @@ subprojects {
}
}

scoverage {
scoverageVersion = "2.0.11"
reportDir.set(file("${rootProject.buildDir}/reports/scoverage"))
highlighting.set(false)
minimumRate.set(0.0)
if (plugins.hasPlugin('org.scoverage')) {
scoverage {
scoverageVersion = "2.0.11"
reportDir.set(file("${rootProject.buildDir}/reports/scoverage"))
highlighting.set(false)
minimumRate.set(0.0)
}
}

spotless {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ package com.clickhouse.spark.base
import com.clickhouse.spark.Utils
import com.clickhouse.data.ClickHouseVersion
import com.dimafeng.testcontainers.{ForAllTestContainer, JdbcDatabaseContainer, SingleContainer}
import org.scalatest.BeforeAndAfterAll
import org.scalatest.funsuite.AnyFunSuite
import org.slf4j.LoggerFactory
import org.testcontainers.containers.ClickHouseContainer
import org.testcontainers.utility.{DockerImageName, MountableFile}
import java.nio.file.{Path, Paths}
import scala.collection.JavaConverters._

trait ClickHouseSingleMixIn extends AnyFunSuite with ForAllTestContainer with ClickHouseProvider {
trait ClickHouseSingleMixIn extends AnyFunSuite with BeforeAndAfterAll with ForAllTestContainer
with ClickHouseProvider {

private val logger = LoggerFactory.getLogger(getClass)
// format: off
private val CLICKHOUSE_IMAGE: String = Utils.load("CLICKHOUSE_IMAGE", "clickhouse/clickhouse-server:23.8")
private val CLICKHOUSE_USER: String = Utils.load("CLICKHOUSE_USER", "default")
Expand All @@ -34,6 +39,8 @@ trait ClickHouseSingleMixIn extends AnyFunSuite with ForAllTestContainer with Cl
private val CLICKHOUSE_TPC_PORT = 9000
// format: on

logger.info(s"Initializing with ClickHouse image: $CLICKHOUSE_IMAGE")

override val clickhouseVersion: ClickHouseVersion = ClickHouseVersion.of(CLICKHOUSE_IMAGE.split(":").last)

protected val rootProjectDir: Path = {
Expand Down Expand Up @@ -80,4 +87,20 @@ trait ClickHouseSingleMixIn extends AnyFunSuite with ForAllTestContainer with Cl
override def clickhousePassword: String = CLICKHOUSE_PASSWORD
override def clickhouseDatabase: String = CLICKHOUSE_DB
override def isSslEnabled: Boolean = false

override def beforeAll(): Unit = {
val startTime = System.currentTimeMillis()
logger.info(s"Starting ClickHouse container: $CLICKHOUSE_IMAGE")
super.beforeAll() // This starts the container and makes mappedPort available
val duration = System.currentTimeMillis() - startTime
logger.info(
s"ClickHouse container started in ${duration}ms at ${container.host}:${container.mappedPort(CLICKHOUSE_HTTP_PORT)}"
)
}

override def afterAll(): Unit = {
logger.info("Stopping ClickHouse container")
super.afterAll()
logger.info("ClickHouse container stopped")
}
}
12 changes: 9 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ mavenCentralMirror=https://repo1.maven.org/maven2/
mavenSnapshotsRepo=https://central.sonatype.com/repository/maven-snapshots/
mavenReleasesRepo=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/

systemProp.scala_binary_version=2.12
systemProp.scala_binary_version=2.13
systemProp.known_scala_binary_versions=2.12,2.13
systemProp.spark_binary_version=3.5
systemProp.known_spark_binary_versions=3.3,3.4,3.5
systemProp.spark_binary_version=4.0
systemProp.known_spark_binary_versions=3.3,3.4,3.5,4.0

group=com.clickhouse.spark

Expand All @@ -29,26 +29,32 @@ clickhouse_client_v2_version=0.9.4
spark_33_version=3.3.4
spark_34_version=3.4.2
spark_35_version=3.5.1
spark_40_version=4.0.1

spark_33_scala_212_version=2.12.15
spark_34_scala_212_version=2.12.17
spark_35_scala_212_version=2.12.18
spark_40_scala_212_version=2.12.18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spark 4.0 does not support scala 2.12

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch


spark_33_scala_213_version=2.13.8
spark_34_scala_213_version=2.13.8
spark_35_scala_213_version=2.13.8
spark_40_scala_213_version=2.13.8

spark_33_antlr_version=4.8
spark_34_antlr_version=4.9.3
spark_35_antlr_version=4.9.3
spark_40_antlr_version=4.13.1

spark_33_jackson_version=2.13.4
spark_34_jackson_version=2.14.2
spark_35_jackson_version=2.15.2
spark_40_jackson_version=2.17.0

spark_33_slf4j_version=1.7.32
spark_34_slf4j_version=2.0.6
spark_35_slf4j_version=2.0.7
spark_40_slf4j_version=2.0.7

# Align with Apache Spark, and don't bundle them in release jar.
commons_lang3_version=3.12.0
Expand Down
5 changes: 5 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version
include ":clickhouse-spark-it-${spark_binary_version}_$scala_binary_version"
project(":clickhouse-spark-it-${spark_binary_version}_$scala_binary_version").projectDir = file("spark-${spark_binary_version}/clickhouse-spark-it")
project(":clickhouse-spark-it-${spark_binary_version}_$scala_binary_version").name = "clickhouse-spark-it-${spark_binary_version}_$scala_binary_version"

// Examples module for running/debugging sample apps in IDE
include ":clickhouse-examples-${spark_binary_version}_$scala_binary_version"
project(":clickhouse-examples-${spark_binary_version}_$scala_binary_version").projectDir = file("spark-${spark_binary_version}/examples")
project(":clickhouse-examples-${spark_binary_version}_$scala_binary_version").name = "clickhouse-examples-${spark_binary_version}_$scala_binary_version"
104 changes: 104 additions & 0 deletions spark-4.0/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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.
*/

project.ext {
spark_version = project.getProperty("spark_40_version")
spark_binary_version = "4.0"
}


project(":clickhouse-spark-${spark_binary_version}_$scala_binary_version") {
dependencies {
api project(":clickhouse-core")

compileOnly "org.apache.spark:spark-sql_$scala_binary_version:$spark_version"

testImplementation "org.apache.spark:spark-sql_$scala_binary_version:$spark_version"
testImplementation "org.scalatest:scalatest_$scala_binary_version:$scalatest_version"
testRuntimeOnly "com.vladsch.flexmark:flexmark-all:$flexmark_version"
}
}

project(":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version") {
apply plugin: "com.github.johnrengelman.shadow"

tasks.jar.dependsOn tasks.shadowJar

dependencies {
compileOnly "org.scala-lang:scala-library:$scala_version"

implementation(project(":clickhouse-spark-${spark_binary_version}_$scala_binary_version")) {
exclude group: "org.antlr", module: "antlr4-runtime"
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.clickhouse", module: "clickhouse-jdbc"
exclude group: "com.fasterxml.jackson.core"
exclude group: "com.fasterxml.jackson.datatype"
exclude group: "com.fasterxml.jackson.module"
}
}

shadowJar {
zip64=true
archiveClassifier=null

mergeServiceFiles()
}

jar {
archiveClassifier="empty"
manifest {
attributes(
'Implementation-Title': 'Spark-ClickHouse-Connector',
'Implementation-Version': "${spark_binary_version}_${scala_binary_version}_${getProjectVersion()}"
)
}
}
}

project(":clickhouse-spark-it-${spark_binary_version}_$scala_binary_version") {
dependencies {
implementation "org.scala-lang:scala-library:$scala_version" // for scala plugin detect scala binary version

testImplementation project(path: ":clickhouse-spark-runtime-${spark_binary_version}_$scala_binary_version", configuration: "shadow")
testImplementation(testFixtures(project(":clickhouse-core"))) {
exclude module: "clickhouse-core"
}

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

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

testImplementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"

testImplementation("com.clickhouse:clickhouse-jdbc:$clickhouse_jdbc_version:all") { transitive = false }

testImplementation "org.apache.kyuubi:kyuubi-spark-connector-tpcds_${scala_binary_version}:$kyuubi_version"
}

test {
classpath += files("${project(':clickhouse-core').projectDir}/src/testFixtures/conf")
}

slowTest {
classpath += files("${project(':clickhouse-core').projectDir}/src/testFixtures/conf")
}

cloudTest {
classpath += files("${project(':clickhouse-core').projectDir}/src/testFixtures/conf")
}
}
Loading
Loading