-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Add Scala Spark ETL example to Java-SDK e2e tests #68939
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
Open
jason810496
wants to merge
4
commits into
apache:main
Choose a base branch
from
jason810496:ci/java-sdk/add-scala-spark-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8dad3bd
Add Scala Spark ETL example bundle to the Java SDK e2e tests
jason810496 00c5ae2
Avoid copying jars for docker build
jason810496 f46122a
Verify the Scala Spark transform stage in the Java-SDK e2e test
jason810496 05770a1
Carry Spark's full Java 17 module options in the Scala Spark e2e test
jason810496 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| # Scala Spark example bundle | ||
|
|
||
| A Scala + Apache Spark bundle for the Java SDK, exercised by the `java_sdk` | ||
| end-to-end test. It shows a non-Java JVM language driving Spark from a | ||
| `@task.stub` task and routing Log4j 2 logs into Airflow via `airflow-sdk-log4j2`. | ||
|
|
||
| The `scala_spark_example` Dag chains three tasks, each running in its own JVM | ||
| with a local `SparkSession` and passing scalar results over XCom: | ||
|
|
||
| - `spark_extract` - builds a DataFrame, pushes its row count. | ||
| - `spark_transform` - aggregates total revenue. | ||
| - `spark_load` - returns the persisted total. | ||
|
|
||
| ## Build | ||
|
|
||
| ```bash | ||
| # From java-sdk/: publish the SDK to the local Maven repository first. | ||
| ./gradlew publishToMavenLocal -PskipSigning=true | ||
|
|
||
| cd scala_spark_example | ||
| ../gradlew bundle | ||
| ``` | ||
|
|
||
| `fatJar` is disabled, so `build/bundle/` holds the bundle JAR plus every runtime | ||
| JAR (Spark included) — copy it into a Java coordinator's `jars_root`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| plugins { | ||
| id("scala") | ||
| id("org.apache.airflow.sdk") version "${projectVersion}" | ||
| } | ||
|
|
||
| repositories { | ||
| mavenLocal() // Not needed for your own project. | ||
| mavenCentral() | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation("org.apache.airflow:airflow-sdk:${projectVersion}") | ||
|
|
||
| // Routes this bundle's Log4j 2 logging (and Spark's own) into Airflow task logs. | ||
| implementation("org.apache.airflow:airflow-sdk-log4j2:${projectVersion}") | ||
|
|
||
| // Spark 3.5.x ships its 2.13 artifacts built against Scala 2.13.8. | ||
| implementation("org.scala-lang:scala-library:2.13.8") | ||
| implementation("org.apache.spark:spark-sql_2.13:3.5.8") | ||
|
|
||
| // Spark pins Log4j 2 to 2.20.0 and airflow-sdk-log4j2 to 2.26.0; align the | ||
| // whole family onto one version so the AirflowAppender's api/core agree. | ||
| implementation(platform("org.apache.logging.log4j:log4j-bom:2.26.0")) | ||
| } | ||
|
|
||
| java { | ||
| // Spark 3.5.x supports Java 8/11/17; match the Java 17 worker runtime. | ||
| toolchain { | ||
| languageVersion.set(JavaLanguageVersion.of(17)) | ||
| } | ||
| } | ||
|
|
||
| sourceSets { | ||
| main { | ||
| scala.srcDir("src/scala") | ||
| } | ||
| } | ||
|
|
||
| airflowBundle { | ||
| mainClass = "org.apache.airflow.example.ScalaSparkBundleBuilder" | ||
| // Spark drags in hundreds of dependency JARs; a thin bundle copies every | ||
| // runtime JAR alongside the bundle JAR (JavaCoordinator globs them all) | ||
| // rather than shadow-merging, which collides on Log4j2Plugins.dat. | ||
| fatJar = false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../gradle.properties |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which word in the file triggers this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
master("local[1]")call triggers the inclusive-language.