blob: 0b3ff13d003bee07e087abe2c58d46e4a1234f7a [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Scalar Functions &mdash; Apache AGE master documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script data-url_root="../" id="documentation_options" 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 type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="List Functions" href="list_functions.html" />
<link rel="prev" title="Predicate Functions" href="predicate_functions.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> Apache AGE
<img src="../_static/logo.png" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption" role="heading"><span class="caption-text">Introduction</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../intro/overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/setup.html">Setup</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/graphs.html">Graphs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/cypher.html">The AGE Cypher Query Format</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/types.html">Data Types - An Introduction to agtype</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/comparability.html">Comparability, Equality, Orderability and Equivalence</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/operators.html">Operators</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/aggregation.html">Aggregation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../intro/agload.html">Importing graph from files</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Clauses</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../clauses/match.html">MATCH</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/with.html">WITH</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/return.html">RETURN</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/order_by.html">ORDER BY</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/skip.html">SKIP</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/limit.html">LIMIT</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/create.html">CREATE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/delete.html">DELETE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/set.html">SET</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/remove.html">REMOVE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../clauses/merge.html">MERGE</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Functions</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="predicate_functions.html">Predicate Functions</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Scalar Functions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id">id</a></li>
<li class="toctree-l2"><a class="reference internal" href="#start-id">start_id</a></li>
<li class="toctree-l2"><a class="reference internal" href="#end-id">end_id</a></li>
<li class="toctree-l2"><a class="reference internal" href="#type">type</a></li>
<li class="toctree-l2"><a class="reference internal" href="#properties">properties</a></li>
<li class="toctree-l2"><a class="reference internal" href="#head">head</a></li>
<li class="toctree-l2"><a class="reference internal" href="#last">last</a></li>
<li class="toctree-l2"><a class="reference internal" href="#length">length</a></li>
<li class="toctree-l2"><a class="reference internal" href="#size">size</a></li>
<li class="toctree-l2"><a class="reference internal" href="#startnode">startNode</a></li>
<li class="toctree-l2"><a class="reference internal" href="#endnode">endNode</a></li>
<li class="toctree-l2"><a class="reference internal" href="#timestamp">timestamp</a></li>
<li class="toctree-l2"><a class="reference internal" href="#toboolean">toBoolean</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tofloat">toFloat</a></li>
<li class="toctree-l2"><a class="reference internal" href="#tointeger">toInteger</a></li>
<li class="toctree-l2"><a class="reference internal" href="#coalesce">coalesce</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="list_functions.html">List Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="numeric_functions.html">Numeric Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="logarithmic_functions.html">Logarithmic Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="trigonometric_functions.html">Trigonometric Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="string_functions.html">String Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="aggregate_functions.html">Aggregation Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="user_functions.html">User defined functions</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">AGE Beyond Cypher</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced_overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html">Using Cypher in a CTE Expression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html#using-cypher-in-a-join-expression">Using Cypher in a Join expression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/advanced.html#cypher-in-sql-expressions">Cypher in SQL expressions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/prepared_statements.html">Prepared Statements</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/plpgsql.html">PL/pgSQL Functions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../advanced/sql_in_cypher.html">SQL In Cypher</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Contributing</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../contributing/run_tests.html">Run the test suite</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Apache AGE</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li>Scalar Functions</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/apache/incubator-age-website/blob/master/docs/functions/scalar_functions.md" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="tex2jax_ignore mathjax_ignore section" id="scalar-functions">
<h1>Scalar Functions<a class="headerlink" href="#scalar-functions" title="Permalink to this headline"></a></h1>
<div class="section" id="id">
<h2>id<a class="headerlink" href="#id" title="Permalink to this headline"></a></h2>
<p>id() returns the id of a vertex or edge.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">id(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">integer</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression that returns a vertex or edge.
</td>
</tr>
</table>
<p>Considerations:</p>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH (a)
RETURN id(a)
$$) as (id agtype);
</pre></div>
</div>
<p>Results</p>
<table>
<tr>
<td>id
</td>
</tr>
<tr>
<td>0
</td>
</tr>
<tr>
<td>1
</td>
</tr>
<tr>
<td>2
</td>
</tr>
<tr>
<td>3
</td>
</tr>
<tr>
<td>4 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="start-id">
<h2>start_id<a class="headerlink" href="#start-id" title="Permalink to this headline"></a></h2>
<p>start_id() returns the id of the vertex that is the starting vertex for the edge.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">start_id(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">integer</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression that evaluates to an edge.
</td>
</tr>
</table>
<p>Considerations:</p>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH ()-[e]-&gt;()
RETURN start_id(e)
$$) as (start_id agtype);
</pre></div>
</div>
<p>Results</p>
<table>
<tr>
<td>start_id
</td>
</tr>
<tr>
<td>0
</td>
</tr>
<tr>
<td>1
</td>
</tr>
<tr>
<td>2
</td>
</tr>
<tr>
<td>3
</td>
</tr>
<tr>
<td>4 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="end-id">
<h2>end_id<a class="headerlink" href="#end-id" title="Permalink to this headline"></a></h2>
<p>end_id() returns the id of the vertex that is the ending vertex for the edge.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">end_id(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">integer</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression that evaluates to an edge.
</td>
</tr>
</table>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH ()-[e]-&gt;()
RETURN end_id(e)
$$) as (end_id agtype);
</pre></div>
</div>
<p>Results</p>
<table>
<tr>
<td>end_id
</td>
</tr>
<tr>
<td>4
</td>
</tr>
<tr>
<td>5
</td>
</tr>
<tr>
<td>6
</td>
</tr>
<tr>
<td>7
</td>
</tr>
<tr>
<td>4 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="type">
<h2>type<a class="headerlink" href="#type" title="Permalink to this headline"></a></h2>
<p>type() returns the string representation of the edge type</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">type(edge)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">string</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>edge
</td>
<td>An expression that evaluates to an edge.
</td>
</tr>
</table>
<p>Considerations:</p>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH ()-[e]-&gt;()
RETURN type(e)
$$) as (type agtype);
</pre></div>
</div>
<p>Results</p>
<table>
<tr>
<td>type
</td>
</tr>
<tr>
<td>“KNOWS”
</td>
</tr>
<tr>
<td>“KNOWS”
</td>
</tr>
<tr>
<td>2 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="properties">
<h2>properties<a class="headerlink" href="#properties" title="Permalink to this headline"></a></h2>
<p>Returns an agtype map containing all the properties of a vertex or edge. If the argument is already a map, it is returned unchanged.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">properties(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">Map</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>Expression
</td>
<td>An expression that returns a vertex, an edge, or an agtype map.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>properties(null) returns null.</p></li>
</ul>
<p>Query:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
CREATE (p:Person {name: &#39;Stefan&#39;, city: &#39;Berlin&#39;})
RETURN properties(p)
$$) as (type agtype);
</pre></div>
</div>
<p>Results:</p>
<table>
<tr>
<td><strong>properties</strong>
</td>
</tr>
<tr>
<td>{name: "Stefan"; city: "Berlin"}
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="head">
<h2>head<a class="headerlink" href="#head" title="Permalink to this headline"></a></h2>
<p>returns the first element in an agtype list.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">head(list)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">The</span> <span class="nb">type</span> <span class="n">of</span> <span class="n">the</span> <span class="n">value</span> <span class="n">returned</span> <span class="n">will</span> <span class="n">be</span> <span class="n">that</span> <span class="n">of</span> <span class="n">the</span> <span class="n">first</span> <span class="n">element</span> <span class="n">of</span> <span class="n">the</span> <span class="nb">list</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>List
</td>
<td>An expression that returns a list
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>head(null) returns null.</p></li>
<li><p>If the first element in the list is null, head(list) will return null.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH (a)
WHERE a.name = &#39;Eskil&#39;
RETURN a.array, head(a.array)
$$) as (lst agtype, lst_head agtype);
</pre></div>
</div>
<p>The first element in the list is returned.</p>
<p>Result:</p>
<table>
<tr>
<td>lst
</td>
<td>lst_head
</td>
</tr>
<tr>
<td>["one","two","three"]
</td>
<td>"one"
</td>
</tr>
<tr>
<td colspan="2" >1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="last">
<h2>last<a class="headerlink" href="#last" title="Permalink to this headline"></a></h2>
<p>returns the last element in an agtype list.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">last(list)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">The</span> <span class="nb">type</span> <span class="n">of</span> <span class="n">the</span> <span class="n">value</span> <span class="n">returned</span> <span class="n">will</span> <span class="n">be</span> <span class="n">that</span> <span class="n">of</span> <span class="n">the</span> <span class="n">last</span> <span class="n">element</span> <span class="n">of</span> <span class="n">the</span> <span class="nb">list</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>List
</td>
<td>An expression that returns a list
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>tail(null) returns null.</p></li>
<li><p>If the last element in the list is null, last(list) will return null.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH (a)
WHERE a.name = &#39;Eskil&#39;
RETURN a.array, last(a.array)
$$) as (lst agtype, lst_tail agtype);
</pre></div>
</div>
<p>The first element in the list is returned.</p>
<p>Result:</p>
<table>
<tr>
<td>lst
</td>
<td>lst_tail
</td>
</tr>
<tr>
<td>["one","two","three"]
</td>
<td>"three"
</td>
</tr>
<tr>
<td colspan="2" >1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="length">
<h2>length<a class="headerlink" href="#length" title="Permalink to this headline"></a></h2>
<p>length() returns the length of a path.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">length(path)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">Integer</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>path
</td>
<td>An expression that returns a path.
</td>
</tr>
</table>
<p>Considerations:length(null) returns null.</p>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH p = (a)-[]-&gt;(b)-[]-&gt;(c)
WHERE a.name = &#39;Alice&#39;
RETURN length(p)
$$) as (length_of_path agtype);
</pre></div>
</div>
<p>The length of the path p is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>length_of_path
</td>
</tr>
<tr>
<td>2
</td>
</tr>
<tr>
<td>2
</td>
</tr>
<tr>
<td>2
</td>
</tr>
<tr>
<td>3 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="size">
<h2>size<a class="headerlink" href="#size" title="Permalink to this headline"></a></h2>
<p>size() returns the length of a list.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">size(path)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">Integer</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>list
</td>
<td>An expression that returns a list.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>size(null) returns null.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN size([&#39;Alice&#39;, &#39;Bob&#39;])
$$) as (size_of_list agtype);
</pre></div>
</div>
<p>The length of the path p is returned.</p>
<p>Results:</p>
<table>
<tr>
<td>size_of_list
</td>
</tr>
<tr>
<td>2
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="startnode">
<h2>startNode<a class="headerlink" href="#startnode" title="Permalink to this headline"></a></h2>
<p>startNode() returns the start node of an edge.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">startNode(edge)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">vertex</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>edge
</td>
<td>An expression that returns an edge.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>startNode(null) returns null.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH (x:Developer)-[r]-()
RETURN startNode(r)
$$) as (v agtype);
</pre></div>
</div>
<p>Result</p>
<table>
<tr>
<td>v
</td>
</tr>
<tr>
<td>Node[0]{name:"Alice",age:38,eyes:"brown"}
</td>
</tr>
<tr>
<td>Node[0]{name:"Alice",age:38,eyes:"brown"}
</td>
</tr>
<tr>
<td>2 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="endnode">
<h2>endNode<a class="headerlink" href="#endnode" title="Permalink to this headline"></a></h2>
<p>endNode() returns the start node of an edge.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">endNode(edge)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">vertex</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>edge
</td>
<td>An expression that returns an edge.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>endNode(null) returns null.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH (x:Developer)-[r]-()
RETURN endNode(r)
$$) as (v agtype);
</pre></div>
</div>
<p>Result</p>
<table>
<tr>
<td>v
</td>
</tr>
<tr>
<td>Node[2]{name:"Charlie",age:53,eyes:"green"}
</td>
</tr>
<tr>
<td>Node[1]{name:"Bob",age:25,eyes:"blue"}
</td>
</tr>
<tr>
<td>2 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="timestamp">
<h2>timestamp<a class="headerlink" href="#timestamp" title="Permalink to this headline"></a></h2>
<p>timestamp() returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">timestamp()</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">Agtype</span> <span class="n">Integer</span><span class="o">.</span>
</pre></div>
</div>
<p>Considerations:</p>
<ul class="simple">
<li><p>timestamp() will return the same value during one entire query, even for long-running queries.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN timestamp()
$$) as (t agtype);
</pre></div>
</div>
<p>The time in milliseconds is returned.</p>
<p>Results:</p>
<table>
<tr>
<td><strong>t</strong>
</td>
</tr>
<tr>
<td>1613496720760
</td>
</tr>
<tr>
<td>1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="toboolean">
<h2>toBoolean<a class="headerlink" href="#toboolean" title="Permalink to this headline"></a></h2>
<p>toBoolean() converts a string value to a boolean value.</p>
<p>Syntax: <code class="docutils literal notranslate"><span class="pre">toBoolean(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">Boolean</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td><strong>Name</strong>
</td>
<td><strong>Description</strong>
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression that returns a boolean or string value.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>toBoolean(null) returns null.</p></li>
<li><p>If expression is a boolean value, it will be returned unchanged.</p></li>
<li><p>If the parsing fails, null will be returned.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN toBoolean(&#39;TRUE&#39;), toBoolean(&#39;not a boolean&#39;)
$$) as (a_bool agtype, not_a_bool agtype);
</pre></div>
</div>
<p>Result:</p>
<table>
<tr>
<td><strong>a_bool</strong>
</td>
<td><strong>not_a_bool</strong>
</td>
</tr>
<tr>
<td>true
</td>
<td>NULL
</td>
</tr>
<tr>
<td colspan="2" >1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="tofloat">
<h2>toFloat<a class="headerlink" href="#tofloat" title="Permalink to this headline"></a></h2>
<p>toFloat() converts an integer or string value to a floating point number.</p>
<p>Syntax:toFloat(expression)</p>
<p>Returns:A Float.</p>
<table>
<tr>
<td><strong>Name</strong>
</td>
<td><strong>Description</strong>
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression that returns an agtype number or agtype string value.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>toFloat(null) returns null.</p></li>
<li><p>If expression is a floating point number, it will be returned unchanged.</p></li>
<li><p>If the parsing fails, null will be returned.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN toFloat(&#39;11.5&#39;), toFloat(&#39;not a number&#39;)
$$) as (a_float agtype, not_a_float agtype);
</pre></div>
</div>
<p>Result:</p>
<table>
<tr>
<td>a_float
</td>
<td>not_a_float
</td>
</tr>
<tr>
<td>11.5
</td>
<td>NULL
</td>
</tr>
<tr>
<td colspan="2" >1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="tointeger">
<h2>toInteger<a class="headerlink" href="#tointeger" title="Permalink to this headline"></a></h2>
<p>toInteger() converts a floating point or string value to an integer value.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">toInteger(expression)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">An</span> <span class="n">agtype</span> <span class="n">Integer</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments</p>
<table>
<tr>
<td><strong>Name</strong>
</td>
<td><strong>Description</strong>
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression that returns an agtype number or agtype string value.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>toInteger(null) returns null.</p></li>
<li><p>If expression is an integer value, it will be returned unchanged.</p></li>
<li><p>If the parsing fails, null will be returned.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
RETURN toInteger(&#39;42&#39;), toInteger(&#39;not a number&#39;)
$$) as (an_integer agtype, not_an_integer agtype);
</pre></div>
</div>
<p>Result:</p>
<table>
<tr>
<td>an_integer
</td>
<td>not_an_integer
</td>
</tr>
<tr>
<td>42
</td>
<td>NULL
</td>
</tr>
<tr>
<td colspan="2" >1 row(s) returned
</td>
</tr>
</table>
</div>
<div class="section" id="coalesce">
<h2>coalesce<a class="headerlink" href="#coalesce" title="Permalink to this headline"></a></h2>
<p>coalesce() returns the first non-null value in the given list of expressions.</p>
<p>Syntax:<code class="docutils literal notranslate"><span class="pre">coalesce(expression</span> <span class="pre">[,</span> <span class="pre">expression]*)</span></code></p>
<p>Returns:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">The</span> <span class="nb">type</span> <span class="n">of</span> <span class="n">the</span> <span class="n">value</span> <span class="n">returned</span> <span class="n">will</span> <span class="n">be</span> <span class="n">that</span> <span class="n">of</span> <span class="n">the</span> <span class="n">first</span> <span class="n">non</span><span class="o">-</span><span class="n">null</span> <span class="n">expression</span><span class="o">.</span>
</pre></div>
</div>
<p>Arguments:</p>
<table>
<tr>
<td>Name
</td>
<td>Description
</td>
</tr>
<tr>
<td>expression
</td>
<td>An expression which may return null.
</td>
</tr>
</table>
<p>Considerations:</p>
<ul class="simple">
<li><p>null will be returned if all the arguments are null.</p></li>
</ul>
<p>Query</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>SELECT *
FROM cypher(&#39;graph_name&#39;, $$
MATCH (a)
WHERE a.name = &#39;Alice&#39;
RETURN coalesce(a.hairColor, a.eyes), a.hair_color, a.eyes
$$) as (color agtype, hair_color agtype, eyes agtype);
</pre></div>
</div>
<p>Result</p>
<table>
<tr>
<td>color
</td>
<td>hair_color
</td>
<td>eyes
</td>
</tr>
<tr>
<td>“brown”
</td>
<td>NULL
</td>
<td>“Brown”
</td>
</tr>
<tr>
<td colspan="3" >1 row(s) returned
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="list_functions.html" class="btn btn-neutral float-right" title="List Functions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="predicate_functions.html" class="btn btn-neutral float-left" title="Predicate Functions" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2021, Apache AGE.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Other Versions</span>
v: manual-link
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
<dl>
<dt>Versions</dt>
<dd><a href="../../documentation-staging/index.html">documentation-staging</a></dd>
<dd><a href="scalar_functions.html">manual-link</a></dd>
<dd><a href="../../master/index.html">master</a></dd>
<dd><a href="../../v0.6.0/index.html">v0.6.0</a></dd>
</dl>
</div>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>