blob: f233c4845d2553b9c578921de12e522e62f925a8 [file] [log] [blame]
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Building Spark - Spark 3.5.0 Documentation</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&Courier+Prime:wght@400;700&display=swap" rel="stylesheet">
<link href="css/custom.css" rel="stylesheet">
<script src="js/vendor/modernizr-2.6.1-respond-1.1.0.min.js"></script>
<link rel="stylesheet" href="css/pygments-default.css">
<link rel="stylesheet" href="css/docsearch.min.css" />
<link rel="stylesheet" href="css/docsearch.css">
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '40']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body class="global">
<!--[if lt IE 7]>
<p class="chromeframe">You are using an outdated browser. <a href="https://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
<![endif]-->
<!-- This code is taken from http://twitter.github.com/bootstrap/examples/hero.html -->
<nav class="navbar navbar-expand-lg navbar-dark p-0 px-4 fixed-top" style="background: #1d6890;" id="topbar">
<div class="navbar-brand"><a href="index.html">
<img src="img/spark-logo-rev.svg" width="141" height="72"/></a><span class="version">3.5.0</span>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarCollapse" aria-controls="navbarCollapse"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav me-auto">
<li class="nav-item"><a href="index.html" class="nav-link">Overview</a></li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarQuickStart" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Programming Guides</a>
<div class="dropdown-menu" aria-labelledby="navbarQuickStart">
<a class="dropdown-item" href="quick-start.html">Quick Start</a>
<a class="dropdown-item" href="rdd-programming-guide.html">RDDs, Accumulators, Broadcasts Vars</a>
<a class="dropdown-item" href="sql-programming-guide.html">SQL, DataFrames, and Datasets</a>
<a class="dropdown-item" href="structured-streaming-programming-guide.html">Structured Streaming</a>
<a class="dropdown-item" href="streaming-programming-guide.html">Spark Streaming (DStreams)</a>
<a class="dropdown-item" href="ml-guide.html">MLlib (Machine Learning)</a>
<a class="dropdown-item" href="graphx-programming-guide.html">GraphX (Graph Processing)</a>
<a class="dropdown-item" href="sparkr.html">SparkR (R on Spark)</a>
<a class="dropdown-item" href="api/python/getting_started/index.html">PySpark (Python on Spark)</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarAPIDocs" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">API Docs</a>
<div class="dropdown-menu" aria-labelledby="navbarAPIDocs">
<a class="dropdown-item" href="api/scala/org/apache/spark/index.html">Scala</a>
<a class="dropdown-item" href="api/java/index.html">Java</a>
<a class="dropdown-item" href="api/python/index.html">Python</a>
<a class="dropdown-item" href="api/R/index.html">R</a>
<a class="dropdown-item" href="api/sql/index.html">SQL, Built-in Functions</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarDeploying" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Deploying</a>
<div class="dropdown-menu" aria-labelledby="navbarDeploying">
<a class="dropdown-item" href="cluster-overview.html">Overview</a>
<a class="dropdown-item" href="submitting-applications.html">Submitting Applications</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="spark-standalone.html">Spark Standalone</a>
<a class="dropdown-item" href="running-on-mesos.html">Mesos</a>
<a class="dropdown-item" href="running-on-yarn.html">YARN</a>
<a class="dropdown-item" href="running-on-kubernetes.html">Kubernetes</a>
</div>
</li>
<li class="nav-item dropdown">
<a href="#" class="nav-link dropdown-toggle" id="navbarMore" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
<div class="dropdown-menu" aria-labelledby="navbarMore">
<a class="dropdown-item" href="configuration.html">Configuration</a>
<a class="dropdown-item" href="monitoring.html">Monitoring</a>
<a class="dropdown-item" href="tuning.html">Tuning Guide</a>
<a class="dropdown-item" href="job-scheduling.html">Job Scheduling</a>
<a class="dropdown-item" href="security.html">Security</a>
<a class="dropdown-item" href="hardware-provisioning.html">Hardware Provisioning</a>
<a class="dropdown-item" href="migration-guide.html">Migration Guide</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="building-spark.html">Building Spark</a>
<a class="dropdown-item" href="https://spark.apache.org/contributing.html">Contributing to Spark</a>
<a class="dropdown-item" href="https://spark.apache.org/third-party-projects.html">Third Party Projects</a>
</div>
</li>
<li class="nav-item">
<input type="text" id="docsearch-input" placeholder="Search the docs…">
</li>
</ul>
<!--<span class="navbar-text navbar-right"><span class="version-text">v3.5.0</span></span>-->
</div>
</nav>
<div class="container">
<div class="content mr-3" id="content">
<h1 class="title">Building Spark</h1>
<ul id="markdown-toc">
<li><a href="#building-apache-spark" id="markdown-toc-building-apache-spark">Building Apache Spark</a> <ul>
<li><a href="#apache-maven" id="markdown-toc-apache-maven">Apache Maven</a> <ul>
<li><a href="#setting-up-mavens-memory-usage" id="markdown-toc-setting-up-mavens-memory-usage">Setting up Maven&#8217;s Memory Usage</a></li>
<li><a href="#buildmvn" id="markdown-toc-buildmvn">build/mvn</a></li>
</ul>
</li>
<li><a href="#building-a-runnable-distribution" id="markdown-toc-building-a-runnable-distribution">Building a Runnable Distribution</a></li>
<li><a href="#specifying-the-hadoop-version-and-enabling-yarn" id="markdown-toc-specifying-the-hadoop-version-and-enabling-yarn">Specifying the Hadoop Version and Enabling YARN</a></li>
<li><a href="#building-with-hive-and-jdbc-support" id="markdown-toc-building-with-hive-and-jdbc-support">Building With Hive and JDBC Support</a></li>
<li><a href="#packaging-without-hadoop-dependencies-for-yarn" id="markdown-toc-packaging-without-hadoop-dependencies-for-yarn">Packaging without Hadoop Dependencies for YARN</a></li>
<li><a href="#building-with-mesos-support" id="markdown-toc-building-with-mesos-support">Building with Mesos support</a></li>
<li><a href="#building-with-kubernetes-support" id="markdown-toc-building-with-kubernetes-support">Building with Kubernetes support</a></li>
<li><a href="#building-submodules-individually" id="markdown-toc-building-submodules-individually">Building submodules individually</a></li>
<li><a href="#building-with-spark-connect-support" id="markdown-toc-building-with-spark-connect-support">Building with Spark Connect support</a></li>
<li><a href="#continuous-compilation" id="markdown-toc-continuous-compilation">Continuous Compilation</a></li>
<li><a href="#building-with-sbt" id="markdown-toc-building-with-sbt">Building with SBT</a> <ul>
<li><a href="#setting-up-sbts-memory-usage" id="markdown-toc-setting-up-sbts-memory-usage">Setting up SBT&#8217;s Memory Usage</a></li>
</ul>
</li>
<li><a href="#speeding-up-compilation" id="markdown-toc-speeding-up-compilation">Speeding up Compilation</a></li>
<li><a href="#encrypted-filesystems" id="markdown-toc-encrypted-filesystems">Encrypted Filesystems</a></li>
<li><a href="#intellij-idea-or-eclipse" id="markdown-toc-intellij-idea-or-eclipse">IntelliJ IDEA or Eclipse</a></li>
</ul>
</li>
<li><a href="#running-tests" id="markdown-toc-running-tests">Running Tests</a> <ul>
<li><a href="#testing-with-sbt" id="markdown-toc-testing-with-sbt">Testing with SBT</a></li>
<li><a href="#running-individual-tests" id="markdown-toc-running-individual-tests">Running Individual Tests</a></li>
<li><a href="#pyspark-pip-installable" id="markdown-toc-pyspark-pip-installable">PySpark pip installable</a></li>
<li><a href="#pyspark-tests-with-maven-or-sbt" id="markdown-toc-pyspark-tests-with-maven-or-sbt">PySpark Tests with Maven or SBT</a></li>
<li><a href="#running-r-tests" id="markdown-toc-running-r-tests">Running R Tests</a></li>
<li><a href="#running-docker-based-integration-test-suites" id="markdown-toc-running-docker-based-integration-test-suites">Running Docker-based Integration Test Suites</a></li>
<li><a href="#change-scala-version" id="markdown-toc-change-scala-version">Change Scala Version</a></li>
<li><a href="#running-jenkins-tests-with-github-enterprise" id="markdown-toc-running-jenkins-tests-with-github-enterprise">Running Jenkins tests with GitHub Enterprise</a> <ul>
<li><a href="#related-environment-variables" id="markdown-toc-related-environment-variables">Related environment variables</a></li>
<li><a href="#building-and-testing-on-ipv6-only-environment" id="markdown-toc-building-and-testing-on-ipv6-only-environment">Building and testing on IPv6-only environment</a></li>
<li><a href="#building-with-user-defined-protoc" id="markdown-toc-building-with-user-defined-protoc">Building with user-defined <code class="language-plaintext highlighter-rouge">protoc</code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="building-apache-spark">Building Apache Spark</h1>
<h2 id="apache-maven">Apache Maven</h2>
<p>The Maven-based build is the build of reference for Apache Spark.
Building Spark using Maven requires Maven 3.8.8 and Java 8/11/17.
Spark requires Scala 2.12/2.13; support for Scala 2.11 was removed in Spark 3.0.0.</p>
<h3 id="setting-up-mavens-memory-usage">Setting up Maven&#8217;s Memory Usage</h3>
<p>You&#8217;ll need to configure Maven to use more memory than usual by setting <code class="language-plaintext highlighter-rouge">MAVEN_OPTS</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>export MAVEN_OPTS="-Xss64m -Xmx2g -XX:ReservedCodeCacheSize=1g"
</code></pre></div></div>
<p>(The <code class="language-plaintext highlighter-rouge">ReservedCodeCacheSize</code> setting is optional but recommended.)
If you don&#8217;t add these parameters to <code class="language-plaintext highlighter-rouge">MAVEN_OPTS</code>, you may see errors and warnings like the following:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[INFO] Compiling 203 Scala sources and 9 Java sources to /Users/me/Development/spark/core/target/scala-2.12/classes...
[ERROR] Java heap space -&gt; [Help 1]
</code></pre></div></div>
<p>You can fix these problems by setting the <code class="language-plaintext highlighter-rouge">MAVEN_OPTS</code> variable as discussed before.</p>
<p><strong>Note:</strong></p>
<ul>
<li>If using <code class="language-plaintext highlighter-rouge">build/mvn</code> with no <code class="language-plaintext highlighter-rouge">MAVEN_OPTS</code> set, the script will automatically add the above options to the <code class="language-plaintext highlighter-rouge">MAVEN_OPTS</code> environment variable.</li>
<li>The <code class="language-plaintext highlighter-rouge">test</code> phase of the Spark build will automatically add these options to <code class="language-plaintext highlighter-rouge">MAVEN_OPTS</code>, even when not using <code class="language-plaintext highlighter-rouge">build/mvn</code>.</li>
</ul>
<h3 id="buildmvn">build/mvn</h3>
<p>Spark now comes packaged with a self-contained Maven installation to ease building and deployment of Spark from source located under the <code class="language-plaintext highlighter-rouge">build/</code> directory. This script will automatically download and setup all necessary build requirements (<a href="https://maven.apache.org/">Maven</a>, <a href="https://www.scala-lang.org/">Scala</a>) locally within the <code class="language-plaintext highlighter-rouge">build/</code> directory itself. It honors any <code class="language-plaintext highlighter-rouge">mvn</code> binary if present already, however, will pull down its own copy of Scala regardless to ensure proper version requirements are met. <code class="language-plaintext highlighter-rouge">build/mvn</code> execution acts as a pass through to the <code class="language-plaintext highlighter-rouge">mvn</code> call allowing easy transition from previous build methods. As an example, one can build a version of Spark as follows:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -DskipTests clean package
</code></pre></div></div>
<p>Other build examples can be found below.</p>
<h2 id="building-a-runnable-distribution">Building a Runnable Distribution</h2>
<p>To create a Spark distribution like those distributed by the
<a href="https://spark.apache.org/downloads.html">Spark Downloads</a> page, and that is laid out so as
to be runnable, use <code class="language-plaintext highlighter-rouge">./dev/make-distribution.sh</code> in the project root directory. It can be configured
with Maven profile settings and so on like the direct Maven build. Example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./dev/make-distribution.sh --name custom-spark --pip --r --tgz -Psparkr -Phive -Phive-thriftserver -Pmesos -Pyarn -Pkubernetes
</code></pre></div></div>
<p>This will build Spark distribution along with Python pip and R packages. For more information on usage, run <code class="language-plaintext highlighter-rouge">./dev/make-distribution.sh --help</code></p>
<h2 id="specifying-the-hadoop-version-and-enabling-yarn">Specifying the Hadoop Version and Enabling YARN</h2>
<p>You can specify the exact version of Hadoop to compile against through the <code class="language-plaintext highlighter-rouge">hadoop.version</code> property.</p>
<p>You can enable the <code class="language-plaintext highlighter-rouge">yarn</code> profile and optionally set the <code class="language-plaintext highlighter-rouge">yarn.version</code> property if it is different
from <code class="language-plaintext highlighter-rouge">hadoop.version</code>.</p>
<p>Example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -Pyarn -Dhadoop.version=3.3.0 -DskipTests clean package
</code></pre></div></div>
<h2 id="building-with-hive-and-jdbc-support">Building With Hive and JDBC Support</h2>
<p>To enable Hive integration for Spark SQL along with its JDBC server and CLI,
add the <code class="language-plaintext highlighter-rouge">-Phive</code> and <code class="language-plaintext highlighter-rouge">-Phive-thriftserver</code> profiles to your existing build options.
By default Spark will build with Hive 2.3.9.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># With Hive 2.3.9 support
./build/mvn -Pyarn -Phive -Phive-thriftserver -DskipTests clean package
</code></pre></div></div>
<h2 id="packaging-without-hadoop-dependencies-for-yarn">Packaging without Hadoop Dependencies for YARN</h2>
<p>The assembly directory produced by <code class="language-plaintext highlighter-rouge">mvn package</code> will, by default, include all of Spark&#8217;s
dependencies, including Hadoop and some of its ecosystem projects. On YARN deployments, this
causes multiple versions of these to appear on executor classpaths: the version packaged in
the Spark assembly and the version on each node, included with <code class="language-plaintext highlighter-rouge">yarn.application.classpath</code>.
The <code class="language-plaintext highlighter-rouge">hadoop-provided</code> profile builds the assembly without including Hadoop-ecosystem projects,
like ZooKeeper and Hadoop itself.</p>
<h2 id="building-with-mesos-support">Building with Mesos support</h2>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -Pmesos -DskipTests clean package
</code></pre></div></div>
<h2 id="building-with-kubernetes-support">Building with Kubernetes support</h2>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -Pkubernetes -DskipTests clean package
</code></pre></div></div>
<h2 id="building-submodules-individually">Building submodules individually</h2>
<p>It&#8217;s possible to build Spark submodules using the <code class="language-plaintext highlighter-rouge">mvn -pl</code> option.</p>
<p>For instance, you can build the Spark Streaming module using:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -pl :spark-streaming_2.12 clean install
</code></pre></div></div>
<p>where <code class="language-plaintext highlighter-rouge">spark-streaming_2.12</code> is the <code class="language-plaintext highlighter-rouge">artifactId</code> as defined in <code class="language-plaintext highlighter-rouge">streaming/pom.xml</code> file.</p>
<h2 id="building-with-spark-connect-support">Building with Spark Connect support</h2>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -Pconnect -DskipTests clean package
</code></pre></div></div>
<h2 id="continuous-compilation">Continuous Compilation</h2>
<p>We use the scala-maven-plugin which supports incremental and continuous compilation. E.g.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn scala:cc
</code></pre></div></div>
<p>should run continuous compilation (i.e. wait for changes). However, this has not been tested
extensively. A couple of gotchas to note:</p>
<ul>
<li>
<p>it only scans the paths <code class="language-plaintext highlighter-rouge">src/main</code> and <code class="language-plaintext highlighter-rouge">src/test</code> (see
<a href="https://davidb.github.io/scala-maven-plugin/example_cc.html">docs</a>), so it will only work
from within certain submodules that have that structure.</p>
</li>
<li>
<p>you&#8217;ll typically need to run <code class="language-plaintext highlighter-rouge">mvn install</code> from the project root for compilation within
specific submodules to work; this is because submodules that depend on other submodules do so via
the <code class="language-plaintext highlighter-rouge">spark-parent</code> module).</p>
</li>
</ul>
<p>Thus, the full flow for running continuous-compilation of the <code class="language-plaintext highlighter-rouge">core</code> submodule may look more like:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ./build/mvn install
$ cd core
$ ../build/mvn scala:cc
</code></pre></div></div>
<h2 id="building-with-sbt">Building with SBT</h2>
<p>Maven is the official build tool recommended for packaging Spark, and is the <em>build of reference</em>.
But SBT is supported for day-to-day development since it can provide much faster iterative
compilation. More advanced developers may wish to use SBT.</p>
<p>The SBT build is derived from the Maven POM files, and so the same Maven profiles and variables
can be set to control the SBT build. For example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/sbt package
</code></pre></div></div>
<p>To avoid the overhead of launching sbt each time you need to re-compile, you can launch sbt
in interactive mode by running <code class="language-plaintext highlighter-rouge">build/sbt</code>, and then run all build commands at the command
prompt.</p>
<h3 id="setting-up-sbts-memory-usage">Setting up SBT&#8217;s Memory Usage</h3>
<p>Configure the JVM options for SBT in <code class="language-plaintext highlighter-rouge">.jvmopts</code> at the project root, for example:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>-Xmx2g
-XX:ReservedCodeCacheSize=1g
</code></pre></div></div>
<p>For the meanings of these two options, please carefully read the <a href="https://spark.apache.org/docs/latest/building-spark.html#setting-up-mavens-memory-usage">Setting up Maven&#8217;s Memory Usage section</a>.</p>
<h2 id="speeding-up-compilation">Speeding up Compilation</h2>
<p>Developers who compile Spark frequently may want to speed up compilation; e.g., by avoiding re-compilation of the
assembly JAR (for developers who build with SBT). For more information about how to do this, refer to the
<a href="https://spark.apache.org/developer-tools.html#reducing-build-times">Useful Developer Tools page</a>.</p>
<h2 id="encrypted-filesystems">Encrypted Filesystems</h2>
<p>When building on an encrypted filesystem (if your home directory is encrypted, for example), then the Spark build might fail with a &#8220;Filename too long&#8221; error. As a workaround, add the following in the configuration args of the <code class="language-plaintext highlighter-rouge">scala-maven-plugin</code> in the project <code class="language-plaintext highlighter-rouge">pom.xml</code>:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;arg&gt;-Xmax-classfile-name&lt;/arg&gt;
&lt;arg&gt;128&lt;/arg&gt;
</code></pre></div></div>
<p>and in <code class="language-plaintext highlighter-rouge">project/SparkBuild.scala</code> add:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>scalacOptions in Compile ++= Seq("-Xmax-classfile-name", "128"),
</code></pre></div></div>
<p>to the <code class="language-plaintext highlighter-rouge">sharedSettings</code> val. See also <a href="https://github.com/apache/spark/pull/2883/files">this PR</a> if you are unsure of where to add these lines.</p>
<h2 id="intellij-idea-or-eclipse">IntelliJ IDEA or Eclipse</h2>
<p>For help in setting up IntelliJ IDEA or Eclipse for Spark development, and troubleshooting, refer to the
<a href="https://spark.apache.org/developer-tools.html">Useful Developer Tools page</a>.</p>
<h1 id="running-tests">Running Tests</h1>
<p>Tests are run by default via the <a href="http://www.scalatest.org/user_guide/using_the_scalatest_maven_plugin">ScalaTest Maven plugin</a>.
Note that tests should not be run as root or an admin user.</p>
<p>The following is an example of a command to run the tests:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn test
</code></pre></div></div>
<h2 id="testing-with-sbt">Testing with SBT</h2>
<p>The following is an example of a command to run the tests:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/sbt test
</code></pre></div></div>
<h2 id="running-individual-tests">Running Individual Tests</h2>
<p>For information about how to run individual tests, refer to the
<a href="https://spark.apache.org/developer-tools.html#running-individual-tests">Useful Developer Tools page</a>.</p>
<h2 id="pyspark-pip-installable">PySpark pip installable</h2>
<p>If you are building Spark for use in a Python environment and you wish to pip install it, you will first need to build the Spark JARs as described above. Then you can construct an sdist package suitable for setup.py and pip installable package.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd python; python setup.py sdist
</code></pre></div></div>
<p><strong>Note:</strong> Due to packaging requirements you can not directly pip install from the Python directory, rather you must first build the sdist package as described above.</p>
<p>Alternatively, you can also run make-distribution with the &#8211;pip option.</p>
<h2 id="pyspark-tests-with-maven-or-sbt">PySpark Tests with Maven or SBT</h2>
<p>If you are building PySpark and wish to run the PySpark tests you will need to build Spark with Hive support.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn -DskipTests clean package -Phive
./python/run-tests
</code></pre></div></div>
<p>If you are building PySpark with SBT and wish to run the PySpark tests, you will need to build Spark with Hive support and also build the test components:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/sbt -Phive clean package
./build/sbt test:compile
./python/run-tests
</code></pre></div></div>
<p>The run-tests script also can be limited to a specific Python version or a specific module</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./python/run-tests --python-executables=python --modules=pyspark-sql
</code></pre></div></div>
<h2 id="running-r-tests">Running R Tests</h2>
<p>To run the SparkR tests you will need to install the <a href="https://cran.r-project.org/package=knitr">knitr</a>, <a href="https://cran.r-project.org/package=rmarkdown">rmarkdown</a>, <a href="https://cran.r-project.org/package=testthat">testthat</a>, <a href="https://cran.r-project.org/package=e1071">e1071</a> and <a href="https://cran.r-project.org/package=survival">survival</a> packages first:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Rscript -e "install.packages(c('knitr', 'rmarkdown', 'devtools', 'testthat', 'e1071', 'survival'), repos='https://cloud.r-project.org/')"
</code></pre></div></div>
<p>You can run just the SparkR tests using the command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./R/run-tests.sh
</code></pre></div></div>
<h2 id="running-docker-based-integration-test-suites">Running Docker-based Integration Test Suites</h2>
<p>In order to run Docker integration tests, you have to install the <code class="language-plaintext highlighter-rouge">docker</code> engine on your box.
The instructions for installation can be found at <a href="https://docs.docker.com/engine/installation/">the Docker site</a>.
Once installed, the <code class="language-plaintext highlighter-rouge">docker</code> service needs to be started, if not already running.
On Linux, this can be done by <code class="language-plaintext highlighter-rouge">sudo service docker start</code>.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/mvn install -DskipTests
./build/mvn test -Pdocker-integration-tests -pl :spark-docker-integration-tests_2.12
</code></pre></div></div>
<p>or</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./build/sbt docker-integration-tests/test
</code></pre></div></div>
<h2 id="change-scala-version">Change Scala Version</h2>
<p>When other versions of Scala like 2.13 are supported, it will be possible to build for that version.
Change the major Scala version using (e.g. 2.13):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./dev/change-scala-version.sh 2.13
</code></pre></div></div>
<p>Enable the profile (e.g. 2.13):</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># For Maven
./build/mvn -Pscala-2.13 compile
# For sbt
./build/sbt -Pscala-2.13 compile
</code></pre></div></div>
<h2 id="running-jenkins-tests-with-github-enterprise">Running Jenkins tests with GitHub Enterprise</h2>
<p>To run tests with Jenkins:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./dev/run-tests-jenkins
</code></pre></div></div>
<p>If use an individual repository or a repository on GitHub Enterprise, export below environment variables before running above command.</p>
<h3 id="related-environment-variables">Related environment variables</h3>
<table class="table table-striped">
<thead><tr><th>Variable Name</th><th>Default</th><th>Meaning</th></tr></thead>
<tr>
<td><code>SPARK_PROJECT_URL</code></td>
<td>https://github.com/apache/spark</td>
<td>
The Spark project URL of GitHub Enterprise.
</td>
</tr>
<tr>
<td><code>GITHUB_API_BASE</code></td>
<td>https://api.github.com/repos/apache/spark</td>
<td>
The Spark project API server URL of GitHub Enterprise.
</td>
</tr>
</table>
<h3 id="building-and-testing-on-ipv6-only-environment">Building and testing on IPv6-only environment</h3>
<p>Use Apache Spark GitBox URL because GitHub doesn&#8217;t support IPv6 yet.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://gitbox.apache.org/repos/asf/spark.git
</code></pre></div></div>
<p>To build and run tests on IPv6-only environment, the following configurations are required.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>export SPARK_LOCAL_HOSTNAME="your-IPv6-address" # e.g. '[2600:1700:232e:3de0:...]'
export DEFAULT_ARTIFACT_REPOSITORY=https://ipv6.repo1.maven.org/maven2/
export MAVEN_OPTS="-Djava.net.preferIPv6Addresses=true"
export SBT_OPTS="-Djava.net.preferIPv6Addresses=true"
export SERIAL_SBT_TESTS=1
</code></pre></div></div>
<h3 id="building-with-user-defined-protoc">Building with user-defined <code class="language-plaintext highlighter-rouge">protoc</code></h3>
<p>When the user cannot use the official <code class="language-plaintext highlighter-rouge">protoc</code> binary files to build the <code class="language-plaintext highlighter-rouge">core</code> module in the compilation environment, for example, compiling <code class="language-plaintext highlighter-rouge">core</code> module on CentOS 6 or CentOS 7 which the default <code class="language-plaintext highlighter-rouge">glibc</code> version is less than 2.14, we can try to compile and test by specifying the user-defined <code class="language-plaintext highlighter-rouge">protoc</code> binary files as follows:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">SPARK_PROTOC_EXEC_PATH</span><span class="o">=</span>/path-to-protoc-exe
./build/mvn <span class="nt">-Puser-defined-protoc</span> <span class="nt">-DskipDefaultProtoc</span> clean package
</code></pre></div></div>
<p>or</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">SPARK_PROTOC_EXEC_PATH</span><span class="o">=</span>/path-to-protoc-exe
./build/sbt <span class="nt">-Puser-defined-protoc</span> clean package
</code></pre></div></div>
<p>The user-defined <code class="language-plaintext highlighter-rouge">protoc</code> binary files can be produced in the user&#8217;s compilation environment by source code compilation, for compilation steps, please refer to <a href="https://github.com/protocolbuffers/protobuf">protobuf</a>.</p>
</div>
<!-- /container -->
</div>
<script src="js/vendor/jquery-3.5.1.min.js"></script>
<script src="js/vendor/bootstrap.bundle.min.js"></script>
<script src="js/vendor/anchor.min.js"></script>
<script src="js/main.js"></script>
<script type="text/javascript" src="js/vendor/docsearch.min.js"></script>
<script type="text/javascript">
// DocSearch is entirely free and automated. DocSearch is built in two parts:
// 1. a crawler which we run on our own infrastructure every 24 hours. It follows every link
// in your website and extract content from every page it traverses. It then pushes this
// content to an Algolia index.
// 2. a JavaScript snippet to be inserted in your website that will bind this Algolia index
// to your search input and display its results in a dropdown UI. If you want to find more
// details on how works DocSearch, check the docs of DocSearch.
docsearch({
apiKey: 'd62f962a82bc9abb53471cb7b89da35e',
appId: 'RAI69RXRSK',
indexName: 'apache_spark',
inputSelector: '#docsearch-input',
enhancedSearchInput: true,
algoliaOptions: {
'facetFilters': ["version:3.5.0"]
},
debug: false // Set debug to true if you want to inspect the dropdown
});
</script>
<!-- MathJax Section -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>
<script>
// Note that we load MathJax this way to work with local file (file://), HTTP and HTTPS.
// We could use "//cdn.mathjax...", but that won't support "file://".
(function(d, script) {
script = d.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.onload = function(){
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ],
displayMath: [ ["$$","$$"], ["\\[", "\\]"] ],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
});
};
script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') +
'cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js' +
'?config=TeX-AMS-MML_HTMLorMML';
d.getElementsByTagName('head')[0].appendChild(script);
}(document));
</script>
</body>
</html>