blob: d260e8a91c030d2387ac5164c25756778a51f95c [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">
<title>Migration Guide: SparkR (R on Spark) - Spark 3.0.0-preview2 Documentation</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.6.1-respond-1.1.0.min.js"></script>
<link rel="stylesheet" href="css/pygments-default.css">
<!-- Google analytics script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32518208-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!--[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 -->
<div class="navbar navbar-fixed-top" id="topbar">
<div class="navbar-inner">
<div class="container">
<div class="brand"><a href="index.html">
<img src="img/spark-logo-hd.png" style="height:50px;"/></a><span class="version">3.0.0-preview2</span>
</div>
<ul class="nav">
<!--TODO(andyk): Add class="active" attribute to li some how.-->
<li><a href="index.html">Overview</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Programming Guides<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="quick-start.html">Quick Start</a></li>
<li><a href="rdd-programming-guide.html">RDDs, Accumulators, Broadcasts Vars</a></li>
<li><a href="sql-programming-guide.html">SQL, DataFrames, and Datasets</a></li>
<li><a href="structured-streaming-programming-guide.html">Structured Streaming</a></li>
<li><a href="streaming-programming-guide.html">Spark Streaming (DStreams)</a></li>
<li><a href="ml-guide.html">MLlib (Machine Learning)</a></li>
<li><a href="graphx-programming-guide.html">GraphX (Graph Processing)</a></li>
<li><a href="sparkr.html">SparkR (R on Spark)</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">API Docs<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="api/scala/index.html#org.apache.spark.package">Scala</a></li>
<li><a href="api/java/index.html">Java</a></li>
<li><a href="api/python/index.html">Python</a></li>
<li><a href="api/R/index.html">R</a></li>
<li><a href="api/sql/index.html">SQL, Built-in Functions</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Deploying<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="cluster-overview.html">Overview</a></li>
<li><a href="submitting-applications.html">Submitting Applications</a></li>
<li class="divider"></li>
<li><a href="spark-standalone.html">Spark Standalone</a></li>
<li><a href="running-on-mesos.html">Mesos</a></li>
<li><a href="running-on-yarn.html">YARN</a></li>
<li><a href="running-on-kubernetes.html">Kubernetes</a></li>
</ul>
</li>
<li class="dropdown">
<a href="api.html" class="dropdown-toggle" data-toggle="dropdown">More<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="configuration.html">Configuration</a></li>
<li><a href="monitoring.html">Monitoring</a></li>
<li><a href="tuning.html">Tuning Guide</a></li>
<li><a href="job-scheduling.html">Job Scheduling</a></li>
<li><a href="security.html">Security</a></li>
<li><a href="hardware-provisioning.html">Hardware Provisioning</a></li>
<li><a href="migration-guide.html">Migration Guide</a></li>
<li class="divider"></li>
<li><a href="building-spark.html">Building Spark</a></li>
<li><a href="https://spark.apache.org/contributing.html">Contributing to Spark</a></li>
<li><a href="https://spark.apache.org/third-party-projects.html">Third Party Projects</a></li>
</ul>
</li>
</ul>
<!--<p class="navbar-text pull-right"><span class="version-text">v3.0.0-preview2</span></p>-->
</div>
</div>
</div>
<div class="container-wrapper">
<div class="left-menu-wrapper">
<div class="left-menu">
<h3><a href="migration-guide.html">Migration Guide</a></h3>
<ul>
<li>
<a href="core-migration-guide.html">
Spark Core
</a>
</li>
<li>
<a href="sql-migration-guide.html">
SQL, Datasets and DataFrame
</a>
</li>
<li>
<a href="ss-migration-guide.html">
Structured Streaming
</a>
</li>
<li>
<a href="ml-migration-guide.html">
MLlib (Machine Learning)
</a>
</li>
<li>
<a href="pyspark-migration-guide.html">
PySpark (Python on Spark)
</a>
</li>
<li>
<a href="sparkr-migration-guide.html">
<b>SparkR (R on Spark)</b>
</a>
</li>
</ul>
</div>
</div>
<input id="nav-trigger" class="nav-trigger" checked type="checkbox">
<label for="nav-trigger"></label>
<div class="content-with-sidebar" id="content">
<h1 class="title">Migration Guide: SparkR (R on Spark)</h1>
<ul id="markdown-toc">
<li><a href="#upgrading-from-sparkr-24-to-30" id="markdown-toc-upgrading-from-sparkr-24-to-30">Upgrading from SparkR 2.4 to 3.0</a></li>
<li><a href="#upgrading-from-sparkr-23-to-24" id="markdown-toc-upgrading-from-sparkr-23-to-24">Upgrading from SparkR 2.3 to 2.4</a></li>
<li><a href="#upgrading-from-sparkr-23-to-231-and-above" id="markdown-toc-upgrading-from-sparkr-23-to-231-and-above">Upgrading from SparkR 2.3 to 2.3.1 and above</a></li>
<li><a href="#upgrading-from-sparkr-22-to-23" id="markdown-toc-upgrading-from-sparkr-22-to-23">Upgrading from SparkR 2.2 to 2.3</a></li>
<li><a href="#upgrading-from-sparkr-21-to-22" id="markdown-toc-upgrading-from-sparkr-21-to-22">Upgrading from SparkR 2.1 to 2.2</a></li>
<li><a href="#upgrading-from-sparkr-20-to-31" id="markdown-toc-upgrading-from-sparkr-20-to-31">Upgrading from SparkR 2.0 to 3.1</a></li>
<li><a href="#upgrading-from-sparkr-16-to-20" id="markdown-toc-upgrading-from-sparkr-16-to-20">Upgrading from SparkR 1.6 to 2.0</a></li>
<li><a href="#upgrading-from-sparkr-15-to-16" id="markdown-toc-upgrading-from-sparkr-15-to-16">Upgrading from SparkR 1.5 to 1.6</a></li>
</ul>
<p>Note that this migration guide describes the items specific to SparkR.
Many items of SQL migration can be applied when migrating SparkR to higher versions.
Please refer <a href="sql-migration-guide.html">Migration Guide: SQL, Datasets and DataFrame</a>.</p>
<h2 id="upgrading-from-sparkr-24-to-30">Upgrading from SparkR 2.4 to 3.0</h2>
<ul>
<li>The deprecated methods <code class="highlighter-rouge">sparkR.init</code>, <code class="highlighter-rouge">sparkRSQL.init</code>, <code class="highlighter-rouge">sparkRHive.init</code> have been removed. Use <code class="highlighter-rouge">sparkR.session</code> instead.</li>
<li>The deprecated methods <code class="highlighter-rouge">parquetFile</code>, <code class="highlighter-rouge">saveAsParquetFile</code>, <code class="highlighter-rouge">jsonFile</code>, <code class="highlighter-rouge">registerTempTable</code>, <code class="highlighter-rouge">createExternalTable</code>, and <code class="highlighter-rouge">dropTempTable</code> have been removed. Use <code class="highlighter-rouge">read.parquet</code>, <code class="highlighter-rouge">write.parquet</code>, <code class="highlighter-rouge">read.json</code>, <code class="highlighter-rouge">createOrReplaceTempView</code>, <code class="highlighter-rouge">createTable</code>, <code class="highlighter-rouge">dropTempView</code>, <code class="highlighter-rouge">union</code> instead.</li>
</ul>
<h2 id="upgrading-from-sparkr-23-to-24">Upgrading from SparkR 2.3 to 2.4</h2>
<ul>
<li>Previously, we don&#8217;t check the validity of the size of the last layer in <code class="highlighter-rouge">spark.mlp</code>. For example, if the training data only has two labels, a <code class="highlighter-rouge">layers</code> param like <code class="highlighter-rouge">c(1, 3)</code> doesn&#8217;t cause an error previously, now it does.</li>
</ul>
<h2 id="upgrading-from-sparkr-23-to-231-and-above">Upgrading from SparkR 2.3 to 2.3.1 and above</h2>
<ul>
<li>In SparkR 2.3.0 and earlier, the <code class="highlighter-rouge">start</code> parameter of <code class="highlighter-rouge">substr</code> method was wrongly subtracted by one and considered as 0-based. This can lead to inconsistent substring results and also does not match with the behaviour with <code class="highlighter-rouge">substr</code> in R. In version 2.3.1 and later, it has been fixed so the <code class="highlighter-rouge">start</code> parameter of <code class="highlighter-rouge">substr</code> method is now 1-based. As an example, <code class="highlighter-rouge">substr(lit('abcdef'), 2, 4))</code> would result to <code class="highlighter-rouge">abc</code> in SparkR 2.3.0, and the result would be <code class="highlighter-rouge">bcd</code> in SparkR 2.3.1.</li>
</ul>
<h2 id="upgrading-from-sparkr-22-to-23">Upgrading from SparkR 2.2 to 2.3</h2>
<ul>
<li>The <code class="highlighter-rouge">stringsAsFactors</code> parameter was previously ignored with <code class="highlighter-rouge">collect</code>, for example, in <code class="highlighter-rouge">collect(createDataFrame(iris), stringsAsFactors = TRUE))</code>. It has been corrected.</li>
<li>For <code class="highlighter-rouge">summary</code>, option for statistics to compute has been added. Its output is changed from that from <code class="highlighter-rouge">describe</code>.</li>
<li>A warning can be raised if versions of SparkR package and the Spark JVM do not match.</li>
</ul>
<h2 id="upgrading-from-sparkr-21-to-22">Upgrading from SparkR 2.1 to 2.2</h2>
<ul>
<li>A <code class="highlighter-rouge">numPartitions</code> parameter has been added to <code class="highlighter-rouge">createDataFrame</code> and <code class="highlighter-rouge">as.DataFrame</code>. When splitting the data, the partition position calculation has been made to match the one in Scala.</li>
<li>The method <code class="highlighter-rouge">createExternalTable</code> has been deprecated to be replaced by <code class="highlighter-rouge">createTable</code>. Either methods can be called to create external or managed table. Additional catalog methods have also been added.</li>
<li>By default, derby.log is now saved to <code class="highlighter-rouge">tempdir()</code>. This will be created when instantiating the SparkSession with <code class="highlighter-rouge">enableHiveSupport</code> set to <code class="highlighter-rouge">TRUE</code>.</li>
<li><code class="highlighter-rouge">spark.lda</code> was not setting the optimizer correctly. It has been corrected.</li>
<li>Several model summary outputs are updated to have <code class="highlighter-rouge">coefficients</code> as <code class="highlighter-rouge">matrix</code>. This includes <code class="highlighter-rouge">spark.logit</code>, <code class="highlighter-rouge">spark.kmeans</code>, <code class="highlighter-rouge">spark.glm</code>. Model summary outputs for <code class="highlighter-rouge">spark.gaussianMixture</code> have added log-likelihood as <code class="highlighter-rouge">loglik</code>.</li>
</ul>
<h2 id="upgrading-from-sparkr-20-to-31">Upgrading from SparkR 2.0 to 3.1</h2>
<ul>
<li><code class="highlighter-rouge">join</code> no longer performs Cartesian Product by default, use <code class="highlighter-rouge">crossJoin</code> instead.</li>
</ul>
<h2 id="upgrading-from-sparkr-16-to-20">Upgrading from SparkR 1.6 to 2.0</h2>
<ul>
<li>The method <code class="highlighter-rouge">table</code> has been removed and replaced by <code class="highlighter-rouge">tableToDF</code>.</li>
<li>The class <code class="highlighter-rouge">DataFrame</code> has been renamed to <code class="highlighter-rouge">SparkDataFrame</code> to avoid name conflicts.</li>
<li>Spark&#8217;s <code class="highlighter-rouge">SQLContext</code> and <code class="highlighter-rouge">HiveContext</code> have been deprecated to be replaced by <code class="highlighter-rouge">SparkSession</code>. Instead of <code class="highlighter-rouge">sparkR.init()</code>, call <code class="highlighter-rouge">sparkR.session()</code> in its place to instantiate the SparkSession. Once that is done, that currently active SparkSession will be used for SparkDataFrame operations.</li>
<li>The parameter <code class="highlighter-rouge">sparkExecutorEnv</code> is not supported by <code class="highlighter-rouge">sparkR.session</code>. To set environment for the executors, set Spark config properties with the prefix &#8220;spark.executorEnv.VAR_NAME&#8221;, for example, &#8220;spark.executorEnv.PATH&#8221;</li>
<li>The <code class="highlighter-rouge">sqlContext</code> parameter is no longer required for these functions: <code class="highlighter-rouge">createDataFrame</code>, <code class="highlighter-rouge">as.DataFrame</code>, <code class="highlighter-rouge">read.json</code>, <code class="highlighter-rouge">jsonFile</code>, <code class="highlighter-rouge">read.parquet</code>, <code class="highlighter-rouge">parquetFile</code>, <code class="highlighter-rouge">read.text</code>, <code class="highlighter-rouge">sql</code>, <code class="highlighter-rouge">tables</code>, <code class="highlighter-rouge">tableNames</code>, <code class="highlighter-rouge">cacheTable</code>, <code class="highlighter-rouge">uncacheTable</code>, <code class="highlighter-rouge">clearCache</code>, <code class="highlighter-rouge">dropTempTable</code>, <code class="highlighter-rouge">read.df</code>, <code class="highlighter-rouge">loadDF</code>, <code class="highlighter-rouge">createExternalTable</code>.</li>
<li>The method <code class="highlighter-rouge">registerTempTable</code> has been deprecated to be replaced by <code class="highlighter-rouge">createOrReplaceTempView</code>.</li>
<li>The method <code class="highlighter-rouge">dropTempTable</code> has been deprecated to be replaced by <code class="highlighter-rouge">dropTempView</code>.</li>
<li>The <code class="highlighter-rouge">sc</code> SparkContext parameter is no longer required for these functions: <code class="highlighter-rouge">setJobGroup</code>, <code class="highlighter-rouge">clearJobGroup</code>, <code class="highlighter-rouge">cancelJobGroup</code></li>
</ul>
<h2 id="upgrading-from-sparkr-15-to-16">Upgrading from SparkR 1.5 to 1.6</h2>
<ul>
<li>Before Spark 1.6.0, the default mode for writes was <code class="highlighter-rouge">append</code>. It was changed in Spark 1.6.0 to <code class="highlighter-rouge">error</code> to match the Scala API.</li>
<li>SparkSQL converts <code class="highlighter-rouge">NA</code> in R to <code class="highlighter-rouge">null</code> and vice-versa.</li>
<li>Since 1.6.1, withColumn method in SparkR supports adding a new column to or replacing existing columns
of the same name of a DataFrame.</li>
</ul>
</div>
<!-- /container -->
</div>
<script src="js/vendor/jquery-3.4.1.min.js"></script>
<script src="js/vendor/bootstrap.min.js"></script>
<script src="js/vendor/anchor.min.js"></script>
<script src="js/main.js"></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>