blob: 90152ee60212d13618ec2b388d4f03e61a651be5 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Error classes in PySpark &#8212; PySpark 3.5.4 documentation</title>
<link href="../_static/styles/theme.css?digest=1999514e3f237ded88cf" rel="stylesheet">
<link href="../_static/styles/pydata-sphinx-theme.css?digest=1999514e3f237ded88cf" rel="stylesheet">
<link rel="stylesheet"
href="../_static/vendor/fontawesome/5.13.0/css/all.min.css">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
<link rel="stylesheet" href="../_static/styles/pydata-sphinx-theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../_static/css/pyspark.css" />
<link rel="preload" as="script" href="../_static/scripts/pydata-sphinx-theme.js?digest=1999514e3f237ded88cf">
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script src="../_static/clipboard.min.js"></script>
<script src="../_static/copybutton.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
<link rel="canonical" href="https://spark.apache.org/docs/latest/api/python/development/errors.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Migration Guides" href="../migration_guide/index.html" />
<link rel="prev" title="Setting up IDEs" href="setting_ide.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="None">
<!-- Google Analytics -->
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
<div class="container-fluid" id="banner"></div>
<nav class="navbar navbar-light navbar-expand-lg bg-light fixed-top bd-navbar" id="navbar-main"><div class="container-xl">
<div id="navbar-start">
<a class="navbar-brand" href="../index.html">
<img src="../_static/spark-logo-reverse.png" class="logo" alt="logo">
</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-collapsible" aria-controls="navbar-collapsible" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbar-collapsible" class="col-lg-9 collapse navbar-collapse">
<div id="navbar-center" class="mr-auto">
<div class="navbar-center-item">
<ul id="navbar-main-elements" class="navbar-nav">
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="../index.html">
Overview
</a>
</li>
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="../getting_started/index.html">
Getting Started
</a>
</li>
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="../user_guide/index.html">
User Guides
</a>
</li>
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="../reference/index.html">
API Reference
</a>
</li>
<li class="toctree-l1 current active nav-item">
<a class="reference internal nav-link" href="index.html">
Development
</a>
</li>
<li class="toctree-l1 nav-item">
<a class="reference internal nav-link" href="../migration_guide/index.html">
Migration Guides
</a>
</li>
</ul>
</div>
</div>
<div id="navbar-end">
<div class="navbar-end-item">
<!--
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.
-->
<div id="version-button" class="dropdown">
<button type="button" class="btn btn-secondary btn-sm navbar-btn dropdown-toggle" id="version_switcher_button" data-toggle="dropdown">
3.5.4
<span class="caret"></span>
</button>
<div id="version_switcher" class="dropdown-menu list-group-flush py-0" aria-labelledby="version_switcher_button">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
<script type="text/javascript">
// Function to construct the target URL from the JSON components
function buildURL(entry) {
var template = "https://spark.apache.org/docs/{version}/api/python/index.html"; // supplied by jinja
template = template.replace("{version}", entry.version);
return template;
}
// Function to check if corresponding page path exists in other version of docs
// and, if so, go there instead of the homepage of the other docs version
function checkPageExistsAndRedirect(event) {
const currentFilePath = "development/errors.html",
otherDocsHomepage = event.target.getAttribute("href");
let tryUrl = `${otherDocsHomepage}${currentFilePath}`;
$.ajax({
type: 'HEAD',
url: tryUrl,
// if the page exists, go there
success: function() {
location.href = tryUrl;
}
}).fail(function() {
location.href = otherDocsHomepage;
});
return false;
}
// Function to populate the version switcher
(function () {
// get JSON config
$.getJSON("https://spark.apache.org/static/versions.json", function(data, textStatus, jqXHR) {
// create the nodes first (before AJAX calls) to ensure the order is
// correct (for now, links will go to doc version homepage)
$.each(data, function(index, entry) {
// if no custom name specified (e.g., "latest"), use version string
if (!("name" in entry)) {
entry.name = entry.version;
}
// construct the appropriate URL, and add it to the dropdown
entry.url = buildURL(entry);
const node = document.createElement("a");
node.setAttribute("class", "list-group-item list-group-item-action py-1");
node.setAttribute("href", `${entry.url}`);
node.textContent = `${entry.name}`;
node.onclick = checkPageExistsAndRedirect;
$("#version_switcher").append(node);
});
});
})();
</script>
</div>
</div>
</div>
</div>
</nav>
<div class="container-xl">
<div class="row">
<!-- Only show if we have sidebars configured, else just a small margin -->
<div class="col-12 col-md-3 bd-sidebar">
<div class="sidebar-start-items"><form class="bd-search d-flex align-items-center" action="../search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" >
</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<div class="bd-toc-item active">
<ul class="current nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="contributing.html">
Contributing to PySpark
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="testing.html">
Testing PySpark
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="debugging.html">
Debugging PySpark
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="setting_ide.html">
Setting up IDEs
</a>
</li>
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
Error classes in PySpark
</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="sidebar-end-items">
</div>
</div>
<div class="d-none d-xl-block col-xl-2 bd-toc">
<div class="toc-item">
<nav id="bd-toc-nav">
</nav>
</div>
<div class="toc-item">
</div>
</div>
<main class="col-12 col-md-9 col-xl-7 py-md-5 pl-md-5 pr-md-4 bd-content" role="main">
<div>
<div class="section" id="error-classes-in-pyspark">
<h1>Error classes in PySpark<a class="headerlink" href="#error-classes-in-pyspark" title="Permalink to this headline"></a></h1>
<p>This is a list of common, named error classes returned by PySpark which are defined at <a class="reference external" href="https://github.com/apache/spark/blob/master/python/pyspark/errors/error_classes.py">error_classes.py</a>.</p>
<p>When writing PySpark errors, developers must use an error class from the list. If an appropriate error class is not available, add a new one into the list. For more information, please refer to <a class="reference external" href="https://spark.apache.org/docs/latest/api/python/development/contributing.html#contributing-error-and-exception">Contributing Error and Exception</a>.</p>
<table class="table">
<colgroup>
<col style="width: 35%" />
<col style="width: 65%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Error class</p></th>
<th class="head"><p>Error message</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ARGUMENT_REQUIRED</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> is required when &lt;condition&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>COLUMN_IN_LIST</p></td>
<td><p><cite>&lt;func_name&gt;</cite> does not allow a Column in a list.</p></td>
</tr>
<tr class="row-even"><td><p>DISALLOWED_TYPE_FOR_CONTAINER</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;`(`type</cite>: &lt;arg_type&gt;) should only contain a type in [&lt;allowed_types&gt;], got &lt;return_type&gt;</p></td>
</tr>
<tr class="row-odd"><td><p>HIGHER_ORDER_FUNCTION_SHOULD_RETURN_COLUMN</p></td>
<td><p>Function <cite>&lt;func_name&gt;</cite> should return Column, got &lt;return_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_BOOL</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a bool, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_LIST_OR_STR_OR_TUPLE</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a bool, dict, float, int, str or tuple, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a bool, dict, float, int or str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_BOOL_OR_LIST</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a bool or list, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_BOOL_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a bool or str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_COLUMN</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a Column, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_COLUMN_OR_DATATYPE_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a Column, str or DataType, but got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_COLUMN_OR_FLOAT_OR_INT_OR_LIST_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a column, float, integer, list or string, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_COLUMN_OR_INT</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a Column or int, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_COLUMN_OR_INT_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a Column, int or str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_COLUMN_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a Column or str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_DATAFRAME</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a DataFrame, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_DATATYPE_OR_STR</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a DataType or str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_DICT</p></td>
<td><p>Argument <cite>&lt;arg_name&gt;</cite> should be a dict, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_EXPRESSION</p></td>
<td><p>Argument &lt;arg_name&gt; should be a Expression, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_FLOAT_OR_INT</p></td>
<td><p>Argument &lt;arg_name&gt; should be a float or int, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_FLOAT_OR_INT_OR_LIST_OR_STR</p></td>
<td><p>Argument &lt;arg_name&gt; should be a float, int, list or str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_INT</p></td>
<td><p>Argument &lt;arg_name&gt; should be an int, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_ITERABLE</p></td>
<td><p>&lt;objectName&gt; is not iterable.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_LIST_OR_STR_OR_TUPLE</p></td>
<td><p>Argument &lt;arg_name&gt; should be a list, str or tuple, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_LIST_OR_TUPLE</p></td>
<td><p>Argument &lt;arg_name&gt; should be a list or tuple, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_SAME_TYPE</p></td>
<td><p>Argument &lt;arg_name1&gt; and &lt;arg_name2&gt; should be the same type, got &lt;arg_type1&gt; and &lt;arg_type2&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>NOT_STR</p></td>
<td><p>Argument &lt;arg_name&gt; should be a str, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>NOT_WINDOWSPEC</p></td>
<td><p>Argument &lt;arg_name&gt; should be a WindowSpec, got &lt;arg_type&gt;.</p></td>
</tr>
<tr class="row-even"><td><p>UNSUPPORTED_NUMPY_ARRAY_SCALAR</p></td>
<td><p>The type of array scalar ‘&lt;dtype&gt;’ is not supported.</p></td>
</tr>
<tr class="row-odd"><td><p>UNSUPPORTED_PARAM_TYPE_FOR_HIGHER_ORDER_FUNCTION</p></td>
<td><p>Function &lt;func_name&gt; should use only POSITIONAL or POSITIONAL OR KEYWORD arguments.</p></td>
</tr>
<tr class="row-even"><td><p>WRONG_NUM_ARGS_FOR_HIGHER_ORDER_FUNCTION</p></td>
<td><p>Function &lt;func_name&gt; should take between 1 and 3 arguments, but provided function takes &lt;num_args&gt;.</p></td>
</tr>
<tr class="row-odd"><td><p>WRONG_NUM_COLUMNS</p></td>
<td><p>Function &lt;func_name&gt; should take at least &lt;num_cols&gt; columns.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Previous / next buttons -->
<div class='prev-next-area'>
<a class='left-prev' id="prev-link" href="setting_ide.html" title="previous page">
<i class="fas fa-angle-left"></i>
<div class="prev-next-info">
<p class="prev-next-subtitle">previous</p>
<p class="prev-next-title">Setting up IDEs</p>
</div>
</a>
<a class='right-next' id="next-link" href="../migration_guide/index.html" title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Migration Guides</p>
</div>
<i class="fas fa-angle-right"></i>
</a>
</div>
</main>
</div>
</div>
<script src="../_static/scripts/pydata-sphinx-theme.js?digest=1999514e3f237ded88cf"></script>
<footer class="footer mt-5 mt-md-0">
<div class="container">
<div class="footer-item">
<p class="copyright">
&copy; Copyright .<br>
</p>
</div>
<div class="footer-item">
<p class="sphinx-version">
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 3.0.4.<br>
</p>
</div>
</div>
</footer>
</body>
</html>