Added: tajo/site/docs/0.11.1/functions/python.html URL: http://svn.apache.org/viewvc/tajo/site/docs/0.11.1/functions/python.html?rev=1728394&view=auto ============================================================================== --- tajo/site/docs/0.11.1/functions/python.html (added) +++ tajo/site/docs/0.11.1/functions/python.html Thu Feb 4 00:29:05 2016 @@ -0,0 +1,418 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>Python Functions — Apache Tajo 0.11.0 documentation</title> + + + + + + + <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + + + + <link rel="top" title="Apache Tajo 0.11.0 documentation" href="../index.html"/> + <link rel="up" title="Functions" href="../functions.html"/> + <link rel="next" title="Table Management" href="../table_management.html"/> + <link rel="prev" title="Window Functions" href="window_func.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + <a href="../index.html" class="fa fa-home"> Apache Tajo</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"> + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li> +<li class="toctree-l1"><a class="reference internal" href="../getting_started.html">Getting Started</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#prerequisites">Prerequisites</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#dowload-and-unpack-the-source-code">Dowload and unpack the source code</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#build-source-code">Build source code</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#setting-up-a-local-tajo-cluster">Setting up a local Tajo cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#first-query-execution">First query execution</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../configuration.html">Configuration</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../configuration/preliminary.html">Preliminary</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/cluster_setup.html">Cluster Setup</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/tajo_master_configuration.html">Tajo Master Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/worker_configuration.html">Worker Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/catalog_configuration.html">Catalog Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/ha_configuration.html">High Availability for TajoMaster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/service_config_defaults.html">Cluster Service Configuration Defaults</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/tajo-site-xml.html">The tajo-site.xml File</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/catalog-site-xml.html">The catalog-site.xml File</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/storage-site-json.html">The storage-site.json File</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../tsql.html">Tajo Shell (TSQL)</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tsql/meta_command.html">Meta Commands</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/dfs_command.html">Executing HDFS commands</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/variables.html">Session Variables</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/admin_command.html">Administration Commands</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/intro.html">Introducing to TSQL</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/single_command.html">Executing a single command</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/execute_file.html">Executing Queries from Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/background_command.html">Executing as background process</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../sql_language.html">SQL Language</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/data_model.html">Data Model</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/ddl.html">Data Definition Language</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/insert.html">INSERT (OVERWRITE) INTO</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/alter_table.html">ALTER TABLE</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/queries.html">Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/joins.html">Joins</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/sql_expression.html">SQL Expressions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/predicates.html">Predicates</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/explain.html">EXPLAIN</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../time_zone.html">Time Zone</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#server-cluster-time-zone">Server Cluster Time Zone</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#table-time-zone">Table Time Zone</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#client-time-zone">Client Time Zone</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#time-zone-id">Time Zone ID</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#examples-of-time-zone">Examples of Time Zone</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="../functions.html">Functions</a><ul class="current"> +<li class="toctree-l2"><a class="reference internal" href="../functions.html#built-in-scalar-functions">Built-in Scalar Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html#built-in-aggregation-functions">Built-in Aggregation Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html#built-in-window-functions">Built-in Window Functions</a></li> +<li class="toctree-l2 current"><a class="reference internal" href="../functions.html#user-defined-functions">User-defined Functions</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../table_management.html">Table Management</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../table_management/table_overview.html">Overview of Tajo Tables</a></li> +<li class="toctree-l2"><a class="reference internal" href="../table_management/tablespaces.html">Tablespaces</a></li> +<li class="toctree-l2"><a class="reference internal" href="../table_management/data_formats.html">Data Formats</a></li> +<li class="toctree-l2"><a class="reference internal" href="../table_management/compression.html">Compression</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../table_partitioning.html">Table Partitioning</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/intro_to_partitioning.html">Introduction to Partitioning</a></li> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/column_partitioning.html">Column Partitioning</a></li> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/range_partitioning.html">Range Partitioning</a></li> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/hash_partitioning.html">Hash Partitioning</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../storage_plugins.html">Storage Plugin</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../storage_plugins/overview.html">Storage Plugin Overview</a></li> +<li class="toctree-l2"><a class="reference internal" href="../storage_plugins/postgresql.html">PostgreSQL Storage Handler</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../index_overview.html">Index (Experimental Feature)</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../index/types.html">Index Types</a></li> +<li class="toctree-l2"><a class="reference internal" href="../index/how_to_use.html">How to use index?</a></li> +<li class="toctree-l2"><a class="reference internal" href="../index/future_work.html">Future Works</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../backup_and_restore.html">Backup and Restore</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../backup_and_restore/catalog.html">Backup and Restore Catalog</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../hive_integration.html">Hive Integration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../hbase_integration.html">HBase Integration</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#create-table">CREATE TABLE</a></li> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#drop-table">DROP TABLE</a></li> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#insert-overwrite-into">INSERT (OVERWRITE) INTO</a></li> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#usage">Usage</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../swift_integration.html">OpenStack Swift Integration</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#swift-configuration">Swift configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#hadoop-configurations">Hadoop configurations</a></li> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#tajo-configuration">Tajo configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#querying-on-swift">Querying on Swift</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../jdbc_driver.html">Tajo JDBC Driver</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#how-to-get-jdbc-driver">How to get JDBC driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#setting-the-classpath">Setting the CLASSPATH</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#connecting-to-the-tajo-cluster-instance">Connecting to the Tajo cluster instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#connection-parameters">Connection Parameters</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#an-example-jdbc-client">An Example JDBC Client</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../tajo_client_api.html">Tajo Client API</a></li> +<li class="toctree-l1"><a class="reference internal" href="../faq.html">FAQ</a></li> +</ul> + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">Apache Tajo</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">Docs</a> »</li> + + <li><a href="../functions.html">Functions</a> »</li> + + <li>Python Functions</li> + <li class="wy-breadcrumbs-aside"> + + <a href="../_sources/functions/python.txt" rel="nofollow"> View page source</a> + + </li> + </ul> + <hr/> +</div> + <div role="main"> + + <div class="section" id="python-functions"> +<h1>Python Functions<a class="headerlink" href="#python-functions" title="Permalink to this headline">¶</a></h1> +<div class="section" id="user-defined-functions"> +<h2>User-defined Functions<a class="headerlink" href="#user-defined-functions" title="Permalink to this headline">¶</a></h2> +<div class="section" id="function-registration"> +<h3>Function registration<a class="headerlink" href="#function-registration" title="Permalink to this headline">¶</a></h3> +<p>To register Python UDFs, you must install script files in all cluster nodes. +After that, you can register your functions by specifying the paths to those script files in <code class="docutils literal"><span class="pre">tajo-site.xml</span></code>. Here is an example of the configuration.</p> +<div class="highlight-xml"><div class="highlight"><pre><span class="nt"><property></span> + <span class="nt"><name></span>tajo.function.python.code-dir<span class="nt"></name></span> + <span class="nt"><value></span>/path/to/script1.py,/path/to/script2.py<span class="nt"></value></span> +<span class="nt"></property></span> +</pre></div> +</div> +<p>Please note that you can specify multiple paths with <code class="docutils literal"><span class="pre">','</span></code> as a delimiter. Each file can contain multiple functions. Here is a typical example of a script file.</p> +<div class="highlight-python"><div class="highlight"><pre><span class="c1"># /path/to/udf1.py</span> + +<span class="nd">@output_type</span><span class="p">(</span><span class="s1">'int4'</span><span class="p">)</span> +<span class="k">def</span> <span class="nf">return_one</span><span class="p">():</span> + <span class="k">return</span> <span class="mi">1</span> + +<span class="nd">@output_type</span><span class="p">(</span><span class="s2">"text"</span><span class="p">)</span> +<span class="k">def</span> <span class="nf">helloworld</span><span class="p">():</span> + <span class="k">return</span> <span class="s1">'Hello, World'</span> + +<span class="c1"># No decorator - blob</span> +<span class="k">def</span> <span class="nf">concat_py</span><span class="p">(</span><span class="nb">str</span><span class="p">):</span> + <span class="k">return</span> <span class="nb">str</span><span class="o">+</span><span class="nb">str</span> + +<span class="nd">@output_type</span><span class="p">(</span><span class="s1">'int4'</span><span class="p">)</span> +<span class="k">def</span> <span class="nf">sum_py</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">):</span> + <span class="k">return</span> <span class="n">a</span><span class="o">+</span><span class="n">b</span> +</pre></div> +</div> +<p>If the configuration is set properly, every function in the script files are registered when the Tajo cluster starts up.</p> +</div> +<div class="section" id="decorators-and-types"> +<h3>Decorators and types<a class="headerlink" href="#decorators-and-types" title="Permalink to this headline">¶</a></h3> +<p>By default, every function has a return type of <code class="docutils literal"><span class="pre">BLOB</span></code>. +You can use Python decorators to define output types for the script functions. Tajo can figure out return types from the annotations of the Python script.</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">output_type</span></code>: Defines the return data type for a script UDF in a format that Tajo can understand. The defined type must be one of the types supported by Tajo. For supported types, please refer to <a class="reference internal" href="../sql_language/data_model.html"><em>Data Model</em></a>.</li> +</ul> +</div> +<div class="section" id="query-example"> +<h3>Query example<a class="headerlink" href="#query-example" title="Permalink to this headline">¶</a></h3> +<p>Once the Python UDFs are successfully registered, you can use them as other built-in functions.</p> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">default</span><span class="o">></span> <span class="k">select</span> <span class="n">concat_py</span><span class="p">(</span><span class="n">n_name</span><span class="p">)::</span><span class="nb">text</span> <span class="k">from</span> <span class="n">nation</span> <span class="k">where</span> <span class="n">sum_py</span><span class="p">(</span><span class="n">n_regionkey</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span> <span class="o">></span> <span class="mi">2</span><span class="p">;</span> +</pre></div> +</div> +</div> +</div> +<div class="section" id="user-defined-aggregation-functions"> +<h2>User-defined Aggregation Functions<a class="headerlink" href="#user-defined-aggregation-functions" title="Permalink to this headline">¶</a></h2> +<div class="section" id="id1"> +<h3>Function registration<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3> +<p>To define your Python aggregation functions, you should write Python classes for each function. +Followings are typical examples of Python UDAFs.</p> +<div class="highlight-python"><div class="highlight"><pre><span class="c1"># /path/to/udaf1.py</span> + +<span class="k">class</span> <span class="nc">AvgPy</span><span class="p">:</span> + <span class="nb">sum</span> <span class="o">=</span> <span class="mi">0</span> + <span class="n">cnt</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">sum</span> <span class="o">=</span> <span class="mi">0</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># eval at the first stage</span> + <span class="k">def</span> <span class="nf">eval</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">sum</span> <span class="o">+=</span> <span class="n">item</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> <span class="o">+=</span> <span class="mi">1</span> + + <span class="c1"># get intermediate result</span> + <span class="k">def</span> <span class="nf">get_partial_result</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sum</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span><span class="p">]</span> + + <span class="c1"># merge intermediate results</span> + <span class="k">def</span> <span class="nf">merge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">sum</span> <span class="o">+=</span> <span class="nb">list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> <span class="o">+=</span> <span class="nb">list</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> + + <span class="c1"># get final result</span> + <span class="nd">@output_type</span><span class="p">(</span><span class="s1">'float8'</span><span class="p">)</span> + <span class="k">def</span> <span class="nf">get_final_result</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sum</span> <span class="o">/</span> <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cnt</span><span class="p">)</span> + + +<span class="k">class</span> <span class="nc">CountPy</span><span class="p">:</span> + <span class="n">cnt</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span> + + <span class="k">def</span> <span class="nf">reset</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> <span class="o">=</span> <span class="mi">0</span> + + <span class="c1"># eval at the first stage</span> + <span class="k">def</span> <span class="nf">eval</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> <span class="o">+=</span> <span class="mi">1</span> + + <span class="c1"># get intermediate result</span> + <span class="k">def</span> <span class="nf">get_partial_result</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> + + <span class="c1"># merge intermediate results</span> + <span class="k">def</span> <span class="nf">merge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cnt</span><span class="p">):</span> + <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> <span class="o">+=</span> <span class="n">cnt</span> + + <span class="c1"># get final result</span> + <span class="nd">@output_type</span><span class="p">(</span><span class="s1">'int4'</span><span class="p">)</span> + <span class="k">def</span> <span class="nf">get_final_result</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> + <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cnt</span> +</pre></div> +</div> +<p>These classes must provide <code class="docutils literal"><span class="pre">reset()</span></code>, <code class="docutils literal"><span class="pre">eval()</span></code>, <code class="docutils literal"><span class="pre">merge()</span></code>, <code class="docutils literal"><span class="pre">get_partial_result()</span></code>, and <code class="docutils literal"><span class="pre">get_final_result()</span></code> functions.</p> +<ul class="simple"> +<li><code class="docutils literal"><span class="pre">reset()</span></code> resets the aggregation state.</li> +<li><code class="docutils literal"><span class="pre">eval()</span></code> evaluates input tuples in the first stage.</li> +<li><code class="docutils literal"><span class="pre">merge()</span></code> merges intermediate results of the first stage.</li> +<li><code class="docutils literal"><span class="pre">get_partial_result()</span></code> returns intermediate results of the first stage. Output type must be same with the input type of <code class="docutils literal"><span class="pre">merge()</span></code>.</li> +<li><code class="docutils literal"><span class="pre">get_final_result()</span></code> returns the final aggregation result.</li> +</ul> +</div> +<div class="section" id="id2"> +<h3>Query example<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3> +<p>Once the Python UDAFs are successfully registered, you can use them as other built-in aggregation functions.</p> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">default</span><span class="o">></span> <span class="k">select</span> <span class="n">avgpy</span><span class="p">(</span><span class="n">n_nationkey</span><span class="p">),</span> <span class="n">countpy</span><span class="p">()</span> <span class="k">from</span> <span class="n">nation</span><span class="p">;</span> +</pre></div> +</div> +<div class="admonition warning"> +<p class="first admonition-title">Warning</p> +<p class="last">Currently, Python UDAFs cannot be used as window functions.</p> +</div> +</div> +</div> +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="../table_management.html" class="btn btn-neutral float-right" title="Table Management"/>Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="window_func.html" class="btn btn-neutral" title="Window Functions"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2015, Apache Tajo Team. + </p> + </div> + + <a href="https://github.com/snide/sphinx_rtd_theme">Sphinx theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a> +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'0.11.0', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file
Added: tajo/site/docs/0.11.1/functions/string_func_and_operators.html URL: http://svn.apache.org/viewvc/tajo/site/docs/0.11.1/functions/string_func_and_operators.html?rev=1728394&view=auto ============================================================================== --- tajo/site/docs/0.11.1/functions/string_func_and_operators.html (added) +++ tajo/site/docs/0.11.1/functions/string_func_and_operators.html Thu Feb 4 00:29:05 2016 @@ -0,0 +1,1052 @@ + + +<!DOCTYPE html> +<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> +<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + + <title>String Functions and Operators — Apache Tajo 0.11.0 documentation</title> + + + + + + + <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> + + + + + + + + + + <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> + + + + <link rel="top" title="Apache Tajo 0.11.0 documentation" href="../index.html"/> + <link rel="up" title="Functions" href="../functions.html"/> + <link rel="next" title="DateTime Functions and Operators" href="datetime_func_and_operators.html"/> + <link rel="prev" title="Math Functions and Operators" href="math_func_and_operators.html"/> + + + <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> + +</head> + +<body class="wy-body-for-nav" role="document"> + + <div class="wy-grid-for-nav"> + + + <nav data-toggle="wy-nav-shift" class="wy-nav-side"> + <div class="wy-side-nav-search"> + <a href="../index.html" class="fa fa-home"> Apache Tajo</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"> + + + <ul class="current"> +<li class="toctree-l1"><a class="reference internal" href="../introduction.html">Introduction</a></li> +<li class="toctree-l1"><a class="reference internal" href="../getting_started.html">Getting Started</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#prerequisites">Prerequisites</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#dowload-and-unpack-the-source-code">Dowload and unpack the source code</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#build-source-code">Build source code</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#setting-up-a-local-tajo-cluster">Setting up a local Tajo cluster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../getting_started.html#first-query-execution">First query execution</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../configuration.html">Configuration</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../configuration/preliminary.html">Preliminary</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/cluster_setup.html">Cluster Setup</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/tajo_master_configuration.html">Tajo Master Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/worker_configuration.html">Worker Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/catalog_configuration.html">Catalog Configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/ha_configuration.html">High Availability for TajoMaster</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/service_config_defaults.html">Cluster Service Configuration Defaults</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/tajo-site-xml.html">The tajo-site.xml File</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/catalog-site-xml.html">The catalog-site.xml File</a></li> +<li class="toctree-l2"><a class="reference internal" href="../configuration/storage-site-json.html">The storage-site.json File</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../tsql.html">Tajo Shell (TSQL)</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../tsql/meta_command.html">Meta Commands</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/dfs_command.html">Executing HDFS commands</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/variables.html">Session Variables</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/admin_command.html">Administration Commands</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/intro.html">Introducing to TSQL</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/single_command.html">Executing a single command</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/execute_file.html">Executing Queries from Files</a></li> +<li class="toctree-l2"><a class="reference internal" href="../tsql/background_command.html">Executing as background process</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../sql_language.html">SQL Language</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/data_model.html">Data Model</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/ddl.html">Data Definition Language</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/insert.html">INSERT (OVERWRITE) INTO</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/alter_table.html">ALTER TABLE</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/queries.html">Queries</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/joins.html">Joins</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/sql_expression.html">SQL Expressions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/predicates.html">Predicates</a></li> +<li class="toctree-l2"><a class="reference internal" href="../sql_language/explain.html">EXPLAIN</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../time_zone.html">Time Zone</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#server-cluster-time-zone">Server Cluster Time Zone</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#table-time-zone">Table Time Zone</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#client-time-zone">Client Time Zone</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#time-zone-id">Time Zone ID</a></li> +<li class="toctree-l2"><a class="reference internal" href="../time_zone.html#examples-of-time-zone">Examples of Time Zone</a></li> +</ul> +</li> +<li class="toctree-l1 current"><a class="reference internal" href="../functions.html">Functions</a><ul class="current"> +<li class="toctree-l2 current"><a class="reference internal" href="../functions.html#built-in-scalar-functions">Built-in Scalar Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html#built-in-aggregation-functions">Built-in Aggregation Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html#built-in-window-functions">Built-in Window Functions</a></li> +<li class="toctree-l2"><a class="reference internal" href="../functions.html#user-defined-functions">User-defined Functions</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../table_management.html">Table Management</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../table_management/table_overview.html">Overview of Tajo Tables</a></li> +<li class="toctree-l2"><a class="reference internal" href="../table_management/tablespaces.html">Tablespaces</a></li> +<li class="toctree-l2"><a class="reference internal" href="../table_management/data_formats.html">Data Formats</a></li> +<li class="toctree-l2"><a class="reference internal" href="../table_management/compression.html">Compression</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../table_partitioning.html">Table Partitioning</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/intro_to_partitioning.html">Introduction to Partitioning</a></li> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/column_partitioning.html">Column Partitioning</a></li> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/range_partitioning.html">Range Partitioning</a></li> +<li class="toctree-l2"><a class="reference internal" href="../partitioning/hash_partitioning.html">Hash Partitioning</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../storage_plugins.html">Storage Plugin</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../storage_plugins/overview.html">Storage Plugin Overview</a></li> +<li class="toctree-l2"><a class="reference internal" href="../storage_plugins/postgresql.html">PostgreSQL Storage Handler</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../index_overview.html">Index (Experimental Feature)</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../index/types.html">Index Types</a></li> +<li class="toctree-l2"><a class="reference internal" href="../index/how_to_use.html">How to use index?</a></li> +<li class="toctree-l2"><a class="reference internal" href="../index/future_work.html">Future Works</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../backup_and_restore.html">Backup and Restore</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../backup_and_restore/catalog.html">Backup and Restore Catalog</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../hive_integration.html">Hive Integration</a></li> +<li class="toctree-l1"><a class="reference internal" href="../hbase_integration.html">HBase Integration</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#create-table">CREATE TABLE</a></li> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#drop-table">DROP TABLE</a></li> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#insert-overwrite-into">INSERT (OVERWRITE) INTO</a></li> +<li class="toctree-l2"><a class="reference internal" href="../hbase_integration.html#usage">Usage</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../swift_integration.html">OpenStack Swift Integration</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#swift-configuration">Swift configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#hadoop-configurations">Hadoop configurations</a></li> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#tajo-configuration">Tajo configuration</a></li> +<li class="toctree-l2"><a class="reference internal" href="../swift_integration.html#querying-on-swift">Querying on Swift</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../jdbc_driver.html">Tajo JDBC Driver</a><ul> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#how-to-get-jdbc-driver">How to get JDBC driver</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#setting-the-classpath">Setting the CLASSPATH</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#connecting-to-the-tajo-cluster-instance">Connecting to the Tajo cluster instance</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#connection-parameters">Connection Parameters</a></li> +<li class="toctree-l2"><a class="reference internal" href="../jdbc_driver.html#an-example-jdbc-client">An Example JDBC Client</a></li> +</ul> +</li> +<li class="toctree-l1"><a class="reference internal" href="../tajo_client_api.html">Tajo Client API</a></li> +<li class="toctree-l1"><a class="reference internal" href="../faq.html">FAQ</a></li> +</ul> + + + </div> + + </nav> + + <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> + + + <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> + <i data-toggle="wy-nav-top" class="fa fa-bars"></i> + <a href="../index.html">Apache Tajo</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">Docs</a> »</li> + + <li><a href="../functions.html">Functions</a> »</li> + + <li>String Functions and Operators</li> + <li class="wy-breadcrumbs-aside"> + + <a href="../_sources/functions/string_func_and_operators.txt" rel="nofollow"> View page source</a> + + </li> + </ul> + <hr/> +</div> + <div role="main"> + + <div class="section" id="string-functions-and-operators"> +<h1>String Functions and Operators<a class="headerlink" href="#string-functions-and-operators" title="Permalink to this headline">¶</a></h1> +<dl class="function"> +<dt> +<code class="descname">str1 || str2</code></dt> +<dd><p>Returns the concatnenated string of both side strings <code class="docutils literal"><span class="pre">str1</span></code> and <code class="docutils literal"><span class="pre">str2</span></code>.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>str1</strong> – first string</li> +<li><strong>str2</strong> – second string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="s1">'Ta'</span> <span class="o">||</span> <span class="s1">'jo'</span><span class="p">;</span> +<span class="o">></span> <span class="s1">'Tajo'</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="ascii"> +<code class="descname">ascii</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#ascii" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the ASCII code of the first character of the text. +For UTF-8, this function returns the Unicode code point of the character. +For other multibyte encodings, the argument must be an ASCII character.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int4</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">ascii</span><span class="p">(</span><span class="s1">'x'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">120</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="bit_length"> +<code class="descname">bit_length</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#bit_length" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the number of bits in string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int4</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">bit_length</span><span class="p">(</span><span class="s1">'jose'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">32</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="char_length"> +<code class="descname">char_length</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#char_length" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the number of characters in string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – to be counted</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int4</td> +</tr> +<tr class="field-odd field"><th class="field-name">Alias:</th><td class="field-body">character_length, length</td> +</tr> +<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">char_length</span><span class="p">(</span><span class="s1">'Tajo'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">4</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="octet_length"> +<code class="descname">octet_length</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#octet_length" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the number of bytes in string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">int4</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">octet_length</span><span class="p">(</span><span class="s1">'jose'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">4</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="chr"> +<code class="descname">chr</code><span class="sig-paren">(</span><em>code int4</em><span class="sig-paren">)</span><a class="headerlink" href="#chr" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns a character with the given code.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>code</strong> – input character code</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">char</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">chr</span><span class="p">(</span><span class="mi">65</span><span class="p">);</span> +<span class="o">></span> <span class="n">A</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="decode"> +<code class="descname">decode</code><span class="sig-paren">(</span><em>binary text</em>, <em>format text</em><span class="sig-paren">)</span><a class="headerlink" href="#decode" title="Permalink to this definition">¶</a></dt> +<dd><p>Decode binary data from textual representation in string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>binary</strong> – encoded value</li> +<li><strong>format</strong> – decode format. base64, hex, escape. escape converts zero bytes and high-bit-set bytes to octal sequences (nnn) and doubles backslashes.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre>select decode('MTIzXDAwMFwwMDE=', 'base64'); +> 123\\000\\001 +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="digest"> +<code class="descname">digest</code><span class="sig-paren">(</span><em>input text</em>, <em>method text</em><span class="sig-paren">)</span><a class="headerlink" href="#digest" title="Permalink to this definition">¶</a></dt> +<dd><p>Calculates the Digest hash of string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>input</strong> – input string</li> +<li><strong>method</strong> – hash method</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">digest</span><span class="p">(</span><span class="s1">'tajo'</span><span class="p">,</span> <span class="s1">'sha1'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">02</span><span class="n">b0e20540b89f0b735092bbac8093eb2e3804cf</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="encode"> +<code class="descname">encode</code><span class="sig-paren">(</span><em>binary text</em>, <em>format text</em><span class="sig-paren">)</span><a class="headerlink" href="#encode" title="Permalink to this definition">¶</a></dt> +<dd><p>Encode binary data into a textual representation.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>binary</strong> – decoded value</li> +<li><strong>format</strong> – encode format. base64, hex, escape. escape converts zero bytes and high-bit-set bytes to octal sequences (nnn) and doubles backslashes.</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">encode</span><span class="p">(</span><span class="s1">'123\\000\\001'</span><span class="p">,</span> <span class="s1">'base64'</span><span class="p">);</span> +<span class="o">></span> <span class="n">MTIzXDAwMFwwMDE</span><span class="o">=</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="initcap"> +<code class="descname">initcap</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#initcap" title="Permalink to this definition">¶</a></dt> +<dd><p>Convert the first letter of each word to upper case and the rest to lower case.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">text</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">initcap</span><span class="p">(</span><span class="s1">'hi THOMAS'</span><span class="p">);</span> +<span class="o">></span> <span class="n">Hi</span> <span class="n">Thomas</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="md5"> +<code class="descname">md5</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#md5" title="Permalink to this definition">¶</a></dt> +<dd><p>Calculates the MD5 hash of string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">text</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">md5</span><span class="p">(</span><span class="s1">'abc'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">900150983</span><span class="n">cd24fb0d6963f7d28e17f72</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="left"> +<code class="descname">left</code><span class="sig-paren">(</span><em>string text</em>, <em>number int4</em><span class="sig-paren">)</span><a class="headerlink" href="#left" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the first n characters in the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>number</strong> – number of characters retrieved</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">left</span><span class="p">(</span><span class="s1">'ABC'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> +<span class="o">></span> <span class="n">AB</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="right"> +<code class="descname">right</code><span class="sig-paren">(</span><em>string text</em>, <em>number int4</em><span class="sig-paren">)</span><a class="headerlink" href="#right" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the last n characters in the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>number</strong> – number of characters retrieved</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">right</span><span class="p">(</span><span class="s1">'ABC'</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> +<span class="o">></span> <span class="n">BC</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="locate"> +<code class="descname">locate</code><span class="sig-paren">(</span><em>source text</em>, <em>target text</em><span class="optional">[</span>, <em>start_index int4</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#locate" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the location of specified substring.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>source</strong> – source string</li> +<li><strong>target</strong> – target substring</li> +<li><strong>start_index</strong> – the index where the search is started</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">int4</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Alias:</th><td class="field-body"><p class="first">strpos</p> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">locate</span><span class="p">(</span><span class="s1">'high'</span><span class="p">,</span> <span class="s1">'ig'</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> +<span class="o">></span> <span class="mi">2</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="strposb"> +<code class="descname">strposb</code><span class="sig-paren">(</span><em>source text</em>, <em>target text</em><span class="sig-paren">)</span><a class="headerlink" href="#strposb" title="Permalink to this definition">¶</a></dt> +<dd><p>Returns the binary location of specified substring.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>source</strong> – source string</li> +<li><strong>target</strong> – target substring</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">int4</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">strpos</span><span class="p">(</span><span class="s1">'tajo'</span><span class="p">,</span> <span class="s1">'aj'</span><span class="p">);</span> +<span class="o">></span> <span class="mi">2</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="substr"> +<code class="descname">substr</code><span class="sig-paren">(</span><em>source text</em>, <em>start int4</em>, <em>length int4</em><span class="sig-paren">)</span><a class="headerlink" href="#substr" title="Permalink to this definition">¶</a></dt> +<dd><p>Extract substring.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>source</strong> – source string</li> +<li><strong>start</strong> – start index</li> +<li><strong>length</strong> – length of substring</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">substr</span><span class="p">(</span><span class="s1">'alphabet'</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> +<span class="o">></span> <span class="n">ph</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="trim"> +<code class="descname">trim</code><span class="sig-paren">(</span><em>string text</em><span class="optional">[</span>, <em>characters text</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#trim" title="Permalink to this definition">¶</a></dt> +<dd><p>Removes the characters (a space by default) from the start/end/both ends of the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>characters</strong> – characters which will be removed</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">trim</span><span class="p">(</span><span class="s1">'xTajoxx'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">);</span> +<span class="o">></span> <span class="n">Tajo</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt> +<code class="descname">trim</code><span class="sig-paren">(</span><em>[leading | trailing | both] [characters text] FROM string text</em><span class="sig-paren">)</span></dt> +<dd><p>Removes the characters (a space by default) from the start/end/both ends of the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>characters</strong> – characters which will be removed</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">trim</span><span class="p">(</span><span class="k">both</span> <span class="s1">'x'</span> <span class="k">from</span> <span class="s1">'xTajoxx'</span><span class="p">);</span> +<span class="o">></span> <span class="n">Tajo</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="btrim"> +<code class="descname">btrim</code><span class="sig-paren">(</span><em>string text</em><span class="optional">[</span>, <em>characters text</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#btrim" title="Permalink to this definition">¶</a></dt> +<dd><p>Removes the characters (a space by default) from the both ends of the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>characters</strong> – characters which will be removed</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Alias:</th><td class="field-body"><p class="first">trim</p> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">btrim</span><span class="p">(</span><span class="s1">'xTajoxx'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">);</span> +<span class="o">></span> <span class="n">Tajo</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="ltrim"> +<code class="descname">ltrim</code><span class="sig-paren">(</span><em>string text</em><span class="optional">[</span>, <em>characters text</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#ltrim" title="Permalink to this definition">¶</a></dt> +<dd><p>Removes the characters (a space by default) from the start ends of the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>characters</strong> – characters which will be removed</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">ltrim</span><span class="p">(</span><span class="s1">'xxTajo'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">);</span> +<span class="o">></span> <span class="n">Tajo</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="rtrim"> +<code class="descname">rtrim</code><span class="sig-paren">(</span><em>string text</em><span class="optional">[</span>, <em>characters text</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#rtrim" title="Permalink to this definition">¶</a></dt> +<dd><p>Removes the characters (a space by default) from the end ends of the string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>characters</strong> – characters which will be removed</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">rtrim</span><span class="p">(</span><span class="s1">'Tajoxx'</span><span class="p">,</span> <span class="s1">'x'</span><span class="p">);</span> +<span class="o">></span> <span class="n">Tajo</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="split_part"> +<code class="descname">split_part</code><span class="sig-paren">(</span><em>string text</em>, <em>delimiter text</em>, <em>field int</em><span class="sig-paren">)</span><a class="headerlink" href="#split_part" title="Permalink to this definition">¶</a></dt> +<dd><p>Splits a string on delimiter and return the given field (counting from one).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>delimiter</strong> – delimiter</li> +<li><strong>field</strong> – index to field</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">split_part</span><span class="p">(</span><span class="s1">'ab_bc_cd'</span><span class="p">,</span><span class="s1">'_'</span><span class="p">,</span><span class="mi">2</span><span class="p">);</span> +<span class="o">></span> <span class="n">bc</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="regexp_replace"> +<code class="descname">regexp_replace</code><span class="sig-paren">(</span><em>string text</em>, <em>pattern text</em>, <em>replacement text</em><span class="sig-paren">)</span><a class="headerlink" href="#regexp_replace" title="Permalink to this definition">¶</a></dt> +<dd><p>Replaces substrings matched to a given regular expression pattern.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>pattern</strong> – pattern</li> +<li><strong>replacement</strong> – string substituted for the matching substring</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre>select regexp_replace('abcdef', '(Ëab|ef$)', 'â'); +> âcdâ +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="upper"> +<code class="descname">upper</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#upper" title="Permalink to this definition">¶</a></dt> +<dd><p>Makes an input text to be upper case.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">text</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">upper</span><span class="p">(</span><span class="s1">'tajo'</span><span class="p">);</span> +<span class="o">></span> <span class="n">TAJO</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="lower"> +<code class="descname">lower</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#lower" title="Permalink to this definition">¶</a></dt> +<dd><p>Makes an input text to be lower case.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">text</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="k">lower</span><span class="p">(</span><span class="s1">'TAJO'</span><span class="p">);</span> +<span class="o">></span> <span class="n">tajo</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="lpad"> +<code class="descname">lpad</code><span class="sig-paren">(</span><em>source text</em>, <em>number int4</em>, <em>pad text</em><span class="sig-paren">)</span><a class="headerlink" href="#lpad" title="Permalink to this definition">¶</a></dt> +<dd><p>Fill up the string to length by prepending the characters fill (a space by default). If the string is already longer than length then it is truncated (on the right).</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>source</strong> – source string</li> +<li><strong>number</strong> – padding length</li> +<li><strong>pad</strong> – padding string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">lpad</span><span class="p">(</span><span class="s1">'hi'</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">'xy'</span><span class="p">);</span> +<span class="o">></span> <span class="n">xyxhi</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="rpad"> +<code class="descname">rpad</code><span class="sig-paren">(</span><em>source text</em>, <em>number int4</em>, <em>pad text</em><span class="sig-paren">)</span><a class="headerlink" href="#rpad" title="Permalink to this definition">¶</a></dt> +<dd><p>Fill up the string to length length by appending the characters fill (a space by default). If the string is already longer than length then it is truncated.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>source</strong> – source string</li> +<li><strong>number</strong> – padding length</li> +<li><strong>pad</strong> – padding string</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">rpad</span><span class="p">(</span><span class="s1">'hi'</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">'xy'</span><span class="p">);</span> +<span class="o">></span> <span class="n">hixyx</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="quote_ident"> +<code class="descname">quote_ident</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#quote_ident" title="Permalink to this definition">¶</a></dt> +<dd><p>Return the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">text</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">quote_ident</span><span class="p">(</span><span class="s1">'Foo bar'</span><span class="p">);</span> +<span class="o">></span> <span class="ss">"Foo bar"</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="repeat"> +<code class="descname">repeat</code><span class="sig-paren">(</span><em>string text</em>, <em>number int4</em><span class="sig-paren">)</span><a class="headerlink" href="#repeat" title="Permalink to this definition">¶</a></dt> +<dd><p>Repeat string the specified number of times.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> +<li><strong>string</strong> – input string</li> +<li><strong>number</strong> – repetition number</li> +</ul> +</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">text</p> +</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">repeat</span><span class="p">(</span><span class="s1">'Pg'</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span> +<span class="o">></span> <span class="n">PgPgPgPg</span> +</pre></div> +</div> +</dd></dl> + +<dl class="function"> +<dt id="reverse"> +<code class="descname">reverse</code><span class="sig-paren">(</span><em>string text</em><span class="sig-paren">)</span><a class="headerlink" href="#reverse" title="Permalink to this definition">¶</a></dt> +<dd><p>Reverse string.</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>string</strong> – input string</td> +</tr> +<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">text</td> +</tr> +<tr class="field-odd field"><th class="field-name">Example:</th><td class="field-body"></td> +</tr> +</tbody> +</table> +<div class="highlight-sql"><div class="highlight"><pre><span class="k">select</span> <span class="n">reverse</span><span class="p">(</span><span class="s1">'TAJO'</span><span class="p">);</span> +<span class="o">></span> <span class="n">OJAT</span> +</pre></div> +</div> +</dd></dl> + +</div> + + + </div> + <footer> + + <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> + + <a href="datetime_func_and_operators.html" class="btn btn-neutral float-right" title="DateTime Functions and Operators"/>Next <span class="fa fa-arrow-circle-right"></span></a> + + + <a href="math_func_and_operators.html" class="btn btn-neutral" title="Math Functions and Operators"><span class="fa fa-arrow-circle-left"></span> Previous</a> + + </div> + + + <hr/> + + <div role="contentinfo"> + <p> + © Copyright 2015, Apache Tajo Team. + </p> + </div> + + <a href="https://github.com/snide/sphinx_rtd_theme">Sphinx theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a> +</footer> + </div> + </div> + + </section> + + </div> + + + + + + <script type="text/javascript"> + var DOCUMENTATION_OPTIONS = { + URL_ROOT:'../', + VERSION:'0.11.0', + COLLAPSE_INDEX:false, + FILE_SUFFIX:'.html', + HAS_SOURCE: true + }; + </script> + <script type="text/javascript" src="../_static/jquery.js"></script> + <script type="text/javascript" src="../_static/underscore.js"></script> + <script type="text/javascript" src="../_static/doctools.js"></script> + + + + + + <script type="text/javascript" src="../_static/js/theme.js"></script> + + + + + <script type="text/javascript"> + jQuery(function () { + SphinxRtdTheme.StickyNav.enable(); + }); + </script> + + +</body> +</html> \ No newline at end of file
