You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by mi...@apache.org on 2018/05/09 21:10:50 UTC
[41/51] [partial] impala git commit: [DOCS] Impala doc site update
for 3.0
http://git-wip-us.apache.org/repos/asf/impala/blob/fae51ec2/docs/build3x/html/topics/impala_conditional_functions.html
----------------------------------------------------------------------
diff --git a/docs/build3x/html/topics/impala_conditional_functions.html b/docs/build3x/html/topics/impala_conditional_functions.html
new file mode 100644
index 0000000..476fb82
--- /dev/null
+++ b/docs/build3x/html/topics/impala_conditional_functions.html
@@ -0,0 +1,611 @@
+<!DOCTYPE html
+ SYSTEM "about:legacy-compat">
+<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_functions.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.0.x"><meta name="version" content="Impala 3.0.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="conditional_functions"><link rel="stylesheet" type="text/css" href="../commonltr.css"><title>Impala Conditional Functions</title></head><body id="conditional_functions"><main role="main"><article role="article" aria-labelledby="ariaid-title1">
+
+ <h1 class="title topictitle1" id="ariaid-title1">Impala Conditional Functions</h1>
+
+
+
+ <div class="body conbody">
+
+ <p class="p">
+ Impala supports the following conditional functions for testing equality, comparison operators, and nullity:
+ </p>
+
+ <dl class="dl">
+
+
+ <dt class="dt dlterm" id="conditional_functions__case">
+ <code class="ph codeph">CASE a WHEN b THEN c [WHEN d THEN e]... [ELSE f] END</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Compares an expression to one or more possible values, and returns a corresponding result
+ when a match is found.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ In this form of the <code class="ph codeph">CASE</code> expression, the initial value <code class="ph codeph">A</code>
+ being evaluated for each row it typically a column reference, or an expression involving
+ a column. This form can only compare against a set of specified values, not ranges,
+ multi-value comparisons such as <code class="ph codeph">BETWEEN</code> or <code class="ph codeph">IN</code>,
+ regular expressions, or <code class="ph codeph">NULL</code>.
+ </p>
+ <p class="p">
+ <strong class="ph b">Examples:</strong>
+ </p>
+ <p class="p">
+ Although this example is split across multiple lines, you can put any or all parts of a <code class="ph codeph">CASE</code> expression
+ on a single line, with no punctuation or other separators between the <code class="ph codeph">WHEN</code>,
+ <code class="ph codeph">ELSE</code>, and <code class="ph codeph">END</code> clauses.
+ </p>
+<pre class="pre codeblock"><code>select case x
+ when 1 then 'one'
+ when 2 then 'two'
+ when 0 then 'zero'
+ else 'out of range'
+ end
+ from t1;
+</code></pre>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__case2">
+ <code class="ph codeph">CASE WHEN a THEN b [WHEN c THEN d]... [ELSE e] END</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests whether any of a sequence of expressions is true, and returns a corresponding
+ result for the first true expression.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ <code class="ph codeph">CASE</code> expressions without an initial test value have more flexibility.
+ For example, they can test different columns in different <code class="ph codeph">WHEN</code> clauses,
+ or use comparison operators such as <code class="ph codeph">BETWEEN</code>, <code class="ph codeph">IN</code> and <code class="ph codeph">IS NULL</code>
+ rather than comparing against discrete values.
+ </p>
+ <p class="p">
+ <code class="ph codeph">CASE</code> expressions are often the foundation of long queries that
+ summarize and format results for easy-to-read reports. For example, you might
+ use a <code class="ph codeph">CASE</code> function call to turn values from a numeric column
+ into category strings corresponding to integer values, or labels such as <span class="q">"Small"</span>,
+ <span class="q">"Medium"</span> and <span class="q">"Large"</span> based on ranges. Then subsequent parts of the
+ query might aggregate based on the transformed values, such as how many
+ values are classified as small, medium, or large. You can also use <code class="ph codeph">CASE</code>
+ to signal problems with out-of-bounds values, <code class="ph codeph">NULL</code> values,
+ and so on.
+ </p>
+ <p class="p">
+ By using operators such as <code class="ph codeph">OR</code>, <code class="ph codeph">IN</code>,
+ <code class="ph codeph">REGEXP</code>, and so on in <code class="ph codeph">CASE</code> expressions,
+ you can build extensive tests and transformations into a single query.
+ Therefore, applications that construct SQL statements often rely heavily on <code class="ph codeph">CASE</code>
+ calls in the generated SQL code.
+ </p>
+ <p class="p">
+ Because this flexible form of the <code class="ph codeph">CASE</code> expressions allows you to perform
+ many comparisons and call multiple functions when evaluating each row, be careful applying
+ elaborate <code class="ph codeph">CASE</code> expressions to queries that process large amounts of data.
+ For example, when practical, evaluate and transform values through <code class="ph codeph">CASE</code>
+ after applying operations such as aggregations that reduce the size of the result set;
+ transform numbers to strings after performing joins with the original numeric values.
+ </p>
+ <p class="p">
+ <strong class="ph b">Examples:</strong>
+ </p>
+ <p class="p">
+ Although this example is split across multiple lines, you can put any or all parts of a <code class="ph codeph">CASE</code> expression
+ on a single line, with no punctuation or other separators between the <code class="ph codeph">WHEN</code>,
+ <code class="ph codeph">ELSE</code>, and <code class="ph codeph">END</code> clauses.
+ </p>
+<pre class="pre codeblock"><code>select case
+ when dayname(now()) in ('Saturday','Sunday') then 'result undefined on weekends'
+ when x > y then 'x greater than y'
+ when x = y then 'x and y are equal'
+ when x is null or y is null then 'one of the columns is null'
+ else null
+ end
+ from t1;
+</code></pre>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__coalesce">
+ <code class="ph codeph">coalesce(type v1, type v2, ...)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Returns the first specified argument that is not <code class="ph codeph">NULL</code>, or
+ <code class="ph codeph">NULL</code> if all arguments are <code class="ph codeph">NULL</code>.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__decode">
+ <code class="ph codeph">decode(type expression, type search1, type result1 [, type search2, type result2 ...] [, type
+ default] )</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Compares an expression to one or more possible values, and returns a corresponding result
+ when a match is found.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ Can be used as shorthand for a <code class="ph codeph">CASE</code> expression.
+ </p>
+ <p class="p">
+ The original expression and the search expressions must of the same type or convertible types. The
+ result expression can be a different type, but all result expressions must be of the same type.
+ </p>
+ <p class="p">
+ Returns a successful match If the original expression is <code class="ph codeph">NULL</code> and a search expression
+ is also <code class="ph codeph">NULL</code>. the
+ </p>
+ <p class="p">
+ Returns <code class="ph codeph">NULL</code> if the final <code class="ph codeph">default</code> value is omitted and none of the
+ search expressions match the original expression.
+ </p>
+ <p class="p">
+ <strong class="ph b">Examples:</strong>
+ </p>
+ <p class="p">
+ The following example translates numeric day values into descriptive names:
+ </p>
+<pre class="pre codeblock"><code>SELECT event, decode(day_of_week, 1, "Monday", 2, "Tuesday", 3, "Wednesday",
+ 4, "Thursday", 5, "Friday", 6, "Saturday", 7, "Sunday", "Unknown day")
+ FROM calendar;
+</code></pre>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__if">
+ <code class="ph codeph">if(boolean condition, type ifTrue, type ifFalseOrNull)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests an expression and returns a corresponding result depending on whether the result is
+ true, false, or <code class="ph codeph">NULL</code>.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> Same as the <code class="ph codeph">ifTrue</code> argument value
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__ifnull">
+ <code class="ph codeph">ifnull(type a, type ifNull)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Alias for the <code class="ph codeph">isnull()</code> function, with the same behavior. To simplify
+ porting SQL with vendor extensions to Impala.
+ <p class="p">
+ <strong class="ph b">Added in:</strong> Impala 1.3.0
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__isfalse">
+ <code class="ph codeph">isfalse(<var class="keyword varname">boolean</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if a Boolean expression is <code class="ph codeph">false</code> or not.
+ Returns <code class="ph codeph">true</code> if so.
+ If the argument is <code class="ph codeph">NULL</code>, returns <code class="ph codeph">false</code>.
+ Identical to <code class="ph codeph">isnottrue()</code>, except it returns the opposite value for a <code class="ph codeph">NULL</code> argument.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> <code class="ph codeph">BOOLEAN</code>
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.2.0</span>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ In <span class="keyword">Impala 2.11</span> and higher, you can use
+ the operators <code class="ph codeph">IS [NOT] TRUE</code> and
+ <code class="ph codeph">IS [NOT] FALSE</code> as equivalents for the built-in
+ functions <code class="ph codeph">istrue()</code>, <code class="ph codeph">isnottrue()</code>,
+ <code class="ph codeph">isfalse()</code>, and <code class="ph codeph">isnotfalse()</code>.
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__isnotfalse">
+ <code class="ph codeph">isnotfalse(<var class="keyword varname">boolean</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if a Boolean expression is not <code class="ph codeph">false</code> (that is, either <code class="ph codeph">true</code> or <code class="ph codeph">NULL</code>).
+ Returns <code class="ph codeph">true</code> if so.
+ If the argument is <code class="ph codeph">NULL</code>, returns <code class="ph codeph">true</code>.
+ Identical to <code class="ph codeph">istrue()</code>, except it returns the opposite value for a <code class="ph codeph">NULL</code> argument.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> <code class="ph codeph">BOOLEAN</code>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> Primarily for compatibility with code containing industry extensions to SQL.
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.2.0</span>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ In <span class="keyword">Impala 2.11</span> and higher, you can use
+ the operators <code class="ph codeph">IS [NOT] TRUE</code> and
+ <code class="ph codeph">IS [NOT] FALSE</code> as equivalents for the built-in
+ functions <code class="ph codeph">istrue()</code>, <code class="ph codeph">isnottrue()</code>,
+ <code class="ph codeph">isfalse()</code>, and <code class="ph codeph">isnotfalse()</code>.
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__isnottrue">
+ <code class="ph codeph">isnottrue(<var class="keyword varname">boolean</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if a Boolean expression is not <code class="ph codeph">true</code> (that is, either <code class="ph codeph">false</code> or <code class="ph codeph">NULL</code>).
+ Returns <code class="ph codeph">true</code> if so.
+ If the argument is <code class="ph codeph">NULL</code>, returns <code class="ph codeph">true</code>.
+ Identical to <code class="ph codeph">isfalse()</code>, except it returns the opposite value for a <code class="ph codeph">NULL</code> argument.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> <code class="ph codeph">BOOLEAN</code>
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.2.0</span>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ In <span class="keyword">Impala 2.11</span> and higher, you can use
+ the operators <code class="ph codeph">IS [NOT] TRUE</code> and
+ <code class="ph codeph">IS [NOT] FALSE</code> as equivalents for the built-in
+ functions <code class="ph codeph">istrue()</code>, <code class="ph codeph">isnottrue()</code>,
+ <code class="ph codeph">isfalse()</code>, and <code class="ph codeph">isnotfalse()</code>.
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__isnull">
+ <code class="ph codeph">isnull(type a, type ifNull)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if an expression is <code class="ph codeph">NULL</code>, and returns the expression result value
+ if not. If the first argument is <code class="ph codeph">NULL</code>, returns the second argument.
+ <p class="p">
+ <strong class="ph b">Compatibility notes:</strong> Equivalent to the <code class="ph codeph">nvl()</code> function from Oracle Database or
+ <code class="ph codeph">ifnull()</code> from MySQL. The <code class="ph codeph">nvl()</code> and <code class="ph codeph">ifnull()</code>
+ functions are also available in Impala.
+ </p>
+ <p class="p">
+ <strong class="ph b">Return type:</strong> Same as the first argument value
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__istrue">
+ <code class="ph codeph">istrue(<var class="keyword varname">boolean</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if a Boolean expression is <code class="ph codeph">true</code> or not.
+ Returns <code class="ph codeph">true</code> if so.
+ If the argument is <code class="ph codeph">NULL</code>, returns <code class="ph codeph">false</code>.
+ Identical to <code class="ph codeph">isnotfalse()</code>, except it returns the opposite value for a <code class="ph codeph">NULL</code> argument.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> <code class="ph codeph">BOOLEAN</code>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> Primarily for compatibility with code containing industry extensions to SQL.
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.2.0</span>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong>
+ </p>
+ <p class="p">
+ In <span class="keyword">Impala 2.11</span> and higher, you can use
+ the operators <code class="ph codeph">IS [NOT] TRUE</code> and
+ <code class="ph codeph">IS [NOT] FALSE</code> as equivalents for the built-in
+ functions <code class="ph codeph">istrue()</code>, <code class="ph codeph">isnottrue()</code>,
+ <code class="ph codeph">isfalse()</code>, and <code class="ph codeph">isnotfalse()</code>.
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__nonnullvalue">
+ <code class="ph codeph">nonnullvalue(<var class="keyword varname">expression</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if an expression (of any type) is <code class="ph codeph">NULL</code> or not.
+ Returns <code class="ph codeph">false</code> if so.
+ The converse of <code class="ph codeph">nullvalue()</code>.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> <code class="ph codeph">BOOLEAN</code>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> Primarily for compatibility with code containing industry extensions to SQL.
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.2.0</span>
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__nullif">
+ <code class="ph codeph">nullif(<var class="keyword varname">expr1</var>,<var class="keyword varname">expr2</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Returns <code class="ph codeph">NULL</code> if the two specified arguments are equal. If the specified
+ arguments are not equal, returns the value of <var class="keyword varname">expr1</var>. The data types of the expressions
+ must be compatible, according to the conversion rules from <a class="xref" href="impala_datatypes.html#datatypes">Data Types</a>.
+ You cannot use an expression that evaluates to <code class="ph codeph">NULL</code> for <var class="keyword varname">expr1</var>; that
+ way, you can distinguish a return value of <code class="ph codeph">NULL</code> from an argument value of
+ <code class="ph codeph">NULL</code>, which would never match <var class="keyword varname">expr2</var>.
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> This function is effectively shorthand for a <code class="ph codeph">CASE</code> expression of
+ the form:
+ </p>
+<pre class="pre codeblock"><code>CASE
+ WHEN <var class="keyword varname">expr1</var> = <var class="keyword varname">expr2</var> THEN NULL
+ ELSE <var class="keyword varname">expr1</var>
+END</code></pre>
+ <p class="p">
+ It is commonly used in division expressions, to produce a <code class="ph codeph">NULL</code> result instead of a
+ divide-by-zero error when the divisor is equal to zero:
+ </p>
+<pre class="pre codeblock"><code>select 1.0 / nullif(c1,0) as reciprocal from t1;</code></pre>
+ <p class="p">
+ You might also use it for compatibility with other database systems that support the same
+ <code class="ph codeph">NULLIF()</code> function.
+ </p>
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> Impala 1.3.0
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__nullifzero">
+ <code class="ph codeph">nullifzero(<var class="keyword varname">numeric_expr</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Returns <code class="ph codeph">NULL</code> if the numeric expression evaluates to 0, otherwise returns
+ the result of the expression.
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> Used to avoid error conditions such as divide-by-zero in numeric calculations.
+ Serves as shorthand for a more elaborate <code class="ph codeph">CASE</code> expression, to simplify porting SQL with
+ vendor extensions to Impala.
+ </p>
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> Impala 1.3.0
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__nullvalue">
+ <code class="ph codeph">nullvalue(<var class="keyword varname">expression</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Tests if an expression (of any type) is <code class="ph codeph">NULL</code> or not.
+ Returns <code class="ph codeph">true</code> if so.
+ The converse of <code class="ph codeph">nonnullvalue()</code>.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> <code class="ph codeph">BOOLEAN</code>
+ </p>
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> Primarily for compatibility with code containing industry extensions to SQL.
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.2.0</span>
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__nvl">
+ <code class="ph codeph">nvl(type a, type ifNull)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Alias for the <code class="ph codeph">isnull()</code> function. Tests if an expression is
+ <code class="ph codeph">NULL</code>, and returns the expression result value if not. If the first argument is
+ <code class="ph codeph">NULL</code>, returns the second argument. Equivalent to the <code class="ph codeph">nvl()</code> function
+ from Oracle Database or <code class="ph codeph">ifnull()</code> from MySQL.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> Same as the first argument value
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> Impala 1.1
+ </p>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__nvl2">
+ <code class="ph codeph">nvl2(type a, type ifNull, type ifNotNull)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Enhanced variant of the <code class="ph codeph">nvl()</code> function. Tests an expression
+ and returns different result values depending on whether it is <code class="ph codeph">NULL</code> or not.
+ If the first argument is <code class="ph codeph">NULL</code>, returns the second argument.
+ If the first argument is not <code class="ph codeph">NULL</code>, returns the third argument.
+ Equivalent to the <code class="ph codeph">nvl2()</code> function from Oracle Database.
+ <p class="p">
+ <strong class="ph b">Return type:</strong> Same as the first argument value
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.9.0</span>
+ </p>
+ <p class="p">
+ <strong class="ph b">Examples:</strong>
+ </p>
+ <p class="p">
+ The following examples show how a query can use special indicator values
+ to represent null and not-null expression values. The first example tests
+ an <code class="ph codeph">INT</code> column and so uses special integer values.
+ The second example tests a <code class="ph codeph">STRING</code> column and so uses
+ special string values.
+ </p>
+<pre class="pre codeblock"><code>
+select x, nvl2(x, 999, 0) from nvl2_demo;
++------+---------------------------+
+| x | if(x is not null, 999, 0) |
++------+---------------------------+
+| NULL | 0 |
+| 1 | 999 |
+| NULL | 0 |
+| 2 | 999 |
++------+---------------------------+
+
+select s, nvl2(s, 'is not null', 'is null') from nvl2_demo;
++------+---------------------------------------------+
+| s | if(s is not null, 'is not null', 'is null') |
++------+---------------------------------------------+
+| NULL | is null |
+| one | is not null |
+| NULL | is null |
+| two | is not null |
++------+---------------------------------------------+
+</code></pre>
+ </dd>
+
+
+
+
+
+ <dt class="dt dlterm" id="conditional_functions__zeroifnull">
+ <code class="ph codeph">zeroifnull(<var class="keyword varname">numeric_expr</var>)</code>
+ </dt>
+
+ <dd class="dd">
+
+ <strong class="ph b">Purpose:</strong> Returns 0 if the numeric expression evaluates to <code class="ph codeph">NULL</code>, otherwise returns
+ the result of the expression.
+ <p class="p">
+ <strong class="ph b">Usage notes:</strong> Used to avoid unexpected results due to unexpected propagation of
+ <code class="ph codeph">NULL</code> values in numeric calculations. Serves as shorthand for a more elaborate
+ <code class="ph codeph">CASE</code> expression, to simplify porting SQL with vendor extensions to Impala.
+ </p>
+ <p class="p">
+ <strong class="ph b">Return type:</strong> same as the initial argument value, except that integer values are promoted to
+ <code class="ph codeph">BIGINT</code> and floating-point values are promoted to <code class="ph codeph">DOUBLE</code>; use
+ <code class="ph codeph">CAST()</code> when inserting into a smaller numeric column
+ </p>
+ <p class="p">
+ <strong class="ph b">Added in:</strong> Impala 1.3.0
+ </p>
+ </dd>
+
+
+ </dl>
+ </div>
+<nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_functions.html">Impala Built-In Functions</a></div></div></nav></article></main></body></html>
http://git-wip-us.apache.org/repos/asf/impala/blob/fae51ec2/docs/build3x/html/topics/impala_config.html
----------------------------------------------------------------------
diff --git a/docs/build3x/html/topics/impala_config.html b/docs/build3x/html/topics/impala_config.html
new file mode 100644
index 0000000..c2686d8
--- /dev/null
+++ b/docs/build3x/html/topics/impala_config.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html
+ SYSTEM "about:legacy-compat">
+<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_config_performance.html"><meta name="DC.Relation" scheme="URI" content="../topics/impala_odbc.html"><meta name="DC.Relation" scheme="URI" content="../topics/impala_jdbc.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.0.x"><meta name="version" content="Impala 3.0.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="config"><link rel="stylesheet" type="text/css" href="../commonltr.css"><title>Managing Impala</title></head><body id="config"><main role="main"><article role="article" aria-labelledby="ariaid-title1">
+
+ <h1 class="title topictitle1" id="ariaid-title1">Managing Impala</h1>
+
+
+ <div class="body conbody">
+
+ <p class="p">
+ This section explains how to configure Impala to accept connections from applications that use popular
+ programming APIs:
+ </p>
+
+ <ul class="ul">
+ <li class="li">
+ <a class="xref" href="impala_config_performance.html#config_performance">Post-Installation Configuration for Impala</a>
+ </li>
+
+ <li class="li">
+ <a class="xref" href="impala_odbc.html#impala_odbc">Configuring Impala to Work with ODBC</a>
+ </li>
+
+ <li class="li">
+ <a class="xref" href="impala_jdbc.html#impala_jdbc">Configuring Impala to Work with JDBC</a>
+ </li>
+ </ul>
+
+ <p class="p">
+ This type of configuration is especially useful when using Impala in combination with Business Intelligence
+ tools, which use these standard interfaces to query different kinds of database and Big Data systems.
+ </p>
+
+ <p class="p">
+ You can also configure these other aspects of Impala:
+ </p>
+
+ <ul class="ul">
+ <li class="li">
+ <a class="xref" href="impala_security.html#security">Impala Security</a>
+ </li>
+
+ <li class="li">
+ <a class="xref" href="impala_config_options.html#config_options">Modifying Impala Startup Options</a>
+ </li>
+ </ul>
+ </div>
+<nav role="navigation" class="related-links"><ul class="ullinks"><li class="link ulchildlink"><strong><a href="../topics/impala_config_performance.html">Post-Installation Configuration for Impala</a></strong><br></li><li class="link ulchildlink"><strong><a href="../topics/impala_odbc.html">Configuring Impala to Work with ODBC</a></strong><br></li><li class="link ulchildlink"><strong><a href="../topics/impala_jdbc.html">Configuring Impala to Work with JDBC</a></strong><br></li></ul></nav></article></main></body></html>
http://git-wip-us.apache.org/repos/asf/impala/blob/fae51ec2/docs/build3x/html/topics/impala_config_options.html
----------------------------------------------------------------------
diff --git a/docs/build3x/html/topics/impala_config_options.html b/docs/build3x/html/topics/impala_config_options.html
new file mode 100644
index 0000000..12af2bc
--- /dev/null
+++ b/docs/build3x/html/topics/impala_config_options.html
@@ -0,0 +1,389 @@
+<!DOCTYPE html
+ SYSTEM "about:legacy-compat">
+<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_processes.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.0.x"><meta name="version" content="Impala 3.0.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="config_options"><link rel="stylesheet" type="text/css" href="../commonltr.css"><title>Modifying Impala Startup Options</title></head><body id="config_options"><main role="main"><article role="article" aria-labelledby="ariaid-title1">
+
+ <h1 class="title topictitle1" id="ariaid-title1">Modifying Impala Startup Options</h1>
+
+
+
+ <div class="body conbody">
+
+ <p class="p">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The configuration options for the Impala-related daemons let you choose which hosts and
+ ports to use for the services that run on a single host, specify directories for logging,
+ control resource usage and security, and specify other aspects of the Impala software.
+ </p>
+
+ <p class="p toc inpage"></p>
+
+ </div>
+
+ <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_processes.html">Starting Impala</a></div></div></nav><article class="topic concept nested1" aria-labelledby="ariaid-title2" id="config_options__config_options_noncm">
+
+ <h2 class="title topictitle2" id="ariaid-title2">Configuring Impala Startup Options through the Command Line</h2>
+
+ <div class="body conbody">
+
+ <p class="p"> The Impala server, statestore, and catalog services start up using values provided in a
+ defaults file, <span class="ph filepath">/etc/default/impala</span>. </p>
+
+ <p class="p">
+ This file includes information about many resources used by Impala. Most of the defaults
+ included in this file should be effective in most cases. For example, typically you
+ would not change the definition of the <code class="ph codeph">CLASSPATH</code> variable, but you
+ would always set the address used by the statestore server. Some of the content you
+ might modify includes:
+ </p>
+
+
+
+<pre class="pre codeblock"><code>IMPALA_STATE_STORE_HOST=127.0.0.1
+IMPALA_STATE_STORE_PORT=24000
+IMPALA_BACKEND_PORT=22000
+IMPALA_LOG_DIR=/var/log/impala
+IMPALA_CATALOG_SERVICE_HOST=...
+IMPALA_STATE_STORE_HOST=...
+
+export IMPALA_STATE_STORE_ARGS=${IMPALA_STATE_STORE_ARGS:- \
+ -log_dir=${IMPALA_LOG_DIR} -state_store_port=${IMPALA_STATE_STORE_PORT}}
+IMPALA_SERVER_ARGS=" \
+-log_dir=${IMPALA_LOG_DIR} \
+-catalog_service_host=${IMPALA_CATALOG_SERVICE_HOST} \
+-state_store_port=${IMPALA_STATE_STORE_PORT} \
+-state_store_host=${IMPALA_STATE_STORE_HOST} \
+-be_port=${IMPALA_BACKEND_PORT}"
+export ENABLE_CORE_DUMPS=${ENABLE_COREDUMPS:-false}</code></pre>
+
+ <p class="p">
+ To use alternate values, edit the defaults file, then restart all the Impala-related
+ services so that the changes take effect. Restart the Impala server using the following
+ commands:
+ </p>
+
+<pre class="pre codeblock"><code>$ sudo service impala-server restart
+Stopping Impala Server: [ OK ]
+Starting Impala Server: [ OK ]</code></pre>
+
+ <p class="p">
+ Restart the Impala statestore using the following commands:
+ </p>
+
+<pre class="pre codeblock"><code>$ sudo service impala-state-store restart
+Stopping Impala State Store Server: [ OK ]
+Starting Impala State Store Server: [ OK ]</code></pre>
+
+ <p class="p">
+ Restart the Impala catalog service using the following commands:
+ </p>
+
+<pre class="pre codeblock"><code>$ sudo service impala-catalog restart
+Stopping Impala Catalog Server: [ OK ]
+Starting Impala Catalog Server: [ OK ]</code></pre>
+
+ <p class="p">
+ Some common settings to change include:
+ </p>
+
+ <ul class="ul">
+ <li class="li">
+ <p class="p">
+ Statestore address. Where practical, put the statestore on a separate host not
+ running the <span class="keyword cmdname">impalad</span> daemon. In that recommended configuration,
+ the <span class="keyword cmdname">impalad</span> daemon cannot refer to the statestore server using
+ the loopback address. If the statestore is hosted on a machine with an IP address of
+ 192.168.0.27, change:
+ </p>
+<pre class="pre codeblock"><code>IMPALA_STATE_STORE_HOST=127.0.0.1</code></pre>
+ <p class="p">
+ to:
+ </p>
+<pre class="pre codeblock"><code>IMPALA_STATE_STORE_HOST=192.168.0.27</code></pre>
+ </li>
+
+ <li class="li">
+ <p class="p">
+ Catalog server address (including both the hostname and the port number). Update the
+ value of the <code class="ph codeph">IMPALA_CATALOG_SERVICE_HOST</code> variable. Where
+ practical, run the catalog server on the same host as the statestore. In that
+ recommended configuration, the <span class="keyword cmdname">impalad</span> daemon cannot refer to the
+ catalog server using the loopback address. If the catalog service is hosted on a
+ machine with an IP address of 192.168.0.27, add the following line:
+ </p>
+<pre class="pre codeblock"><code>IMPALA_CATALOG_SERVICE_HOST=192.168.0.27:26000</code></pre>
+ <p class="p">
+ The <span class="ph filepath">/etc/default/impala</span> defaults file currently does not define
+ an <code class="ph codeph">IMPALA_CATALOG_ARGS</code> environment variable, but if you add one it
+ will be recognized by the service startup/shutdown script. Add a definition for this
+ variable to <span class="ph filepath">/etc/default/impala</span> and add the option
+ <code class="ph codeph">-catalog_service_host=<var class="keyword varname">hostname</var></code>. If the port is
+ different than the default 26000, also add the option
+ <code class="ph codeph">-catalog_service_port=<var class="keyword varname">port</var></code>.
+ </p>
+ </li>
+
+ <li class="li" id="config_options_noncm__mem_limit">
+ <p class="p">
+ Memory limits. You can limit the amount of memory available to Impala. For example,
+ to allow Impala to use no more than 70% of system memory, change:
+ </p>
+
+<pre class="pre codeblock"><code>export IMPALA_SERVER_ARGS=${IMPALA_SERVER_ARGS:- \
+ -log_dir=${IMPALA_LOG_DIR} \
+ -state_store_port=${IMPALA_STATE_STORE_PORT} \
+ -state_store_host=${IMPALA_STATE_STORE_HOST} \
+ -be_port=${IMPALA_BACKEND_PORT}}</code></pre>
+ <p class="p">
+ to:
+ </p>
+<pre class="pre codeblock"><code>export IMPALA_SERVER_ARGS=${IMPALA_SERVER_ARGS:- \
+ -log_dir=${IMPALA_LOG_DIR} -state_store_port=${IMPALA_STATE_STORE_PORT} \
+ -state_store_host=${IMPALA_STATE_STORE_HOST} \
+ -be_port=${IMPALA_BACKEND_PORT} -mem_limit=70%}</code></pre>
+ <p class="p">
+ You can specify the memory limit using absolute notation such as
+ <code class="ph codeph">500m</code> or <code class="ph codeph">2G</code>, or as a percentage of physical memory
+ such as <code class="ph codeph">60%</code>.
+ </p>
+
+ <div class="note note note_note"><span class="note__title notetitle">Note:</span>
+ Queries that exceed the specified memory limit are aborted. Percentage limits are
+ based on the physical memory of the machine and do not consider cgroups.
+ </div>
+ </li>
+
+ <li class="li">
+ <p class="p"> Core dump enablement. To enable core dumps, change: </p>
+<pre class="pre codeblock"><code>export ENABLE_CORE_DUMPS=${ENABLE_COREDUMPS:-false}</code></pre>
+ <p class="p">
+ to:
+ </p>
+<pre class="pre codeblock"><code>export ENABLE_CORE_DUMPS=${ENABLE_COREDUMPS:-true}</code></pre>
+
+ <div class="note note note_note"><span class="note__title notetitle">Note:</span>
+ <ul class="ul">
+ <li class="li">
+ <p class="p">
+ The location of core dump files may vary according to your operating system configuration.
+ </p>
+ </li>
+ <li class="li">
+ <p class="p">
+ Other security settings may prevent Impala from writing core dumps even when this option is enabled.
+ </p>
+ </li>
+ </ul>
+ </div>
+ </li>
+
+ <li class="li">
+ <p class="p">
+ Authorization using the open source Sentry plugin. Specify the
+ <code class="ph codeph">-server_name</code> and <code class="ph codeph">-authorization_policy_file</code>
+ options as part of the <code class="ph codeph">IMPALA_SERVER_ARGS</code> and
+ <code class="ph codeph">IMPALA_STATE_STORE_ARGS</code> settings to enable the core Impala support
+ for authentication. See <a class="xref" href="impala_authorization.html#secure_startup">Starting the impalad Daemon with Sentry Authorization Enabled</a> for
+ details.
+ </p>
+ </li>
+
+ <li class="li">
+ <p class="p">
+ Auditing for successful or blocked Impala queries, another aspect of security.
+ Specify the <code class="ph codeph">-audit_event_log_dir=<var class="keyword varname">directory_path</var></code>
+ option and optionally the
+ <code class="ph codeph">-max_audit_event_log_file_size=<var class="keyword varname">number_of_queries</var></code>
+ and <code class="ph codeph">-abort_on_failed_audit_event</code> options as part of the
+ <code class="ph codeph">IMPALA_SERVER_ARGS</code> settings, for each Impala node, to enable and
+ customize auditing. See <a class="xref" href="impala_auditing.html#auditing">Auditing Impala Operations</a> for details.
+ </p>
+ </li>
+
+ <li class="li">
+ <p class="p">
+ Password protection for the Impala web UI, which listens on port 25000 by default.
+ This feature involves adding some or all of the
+ <code class="ph codeph">--webserver_password_file</code>,
+ <code class="ph codeph">--webserver_authentication_domain</code>, and
+ <code class="ph codeph">--webserver_certificate_file</code> options to the
+ <code class="ph codeph">IMPALA_SERVER_ARGS</code> and <code class="ph codeph">IMPALA_STATE_STORE_ARGS</code>
+ settings. See <a class="xref" href="impala_security_guidelines.html#security_guidelines">Security Guidelines for Impala</a> for
+ details.
+ </p>
+ </li>
+
+ <li class="li" id="config_options_noncm__default_query_options">
+ <div class="p">
+ Another setting you might add to <code class="ph codeph">IMPALA_SERVER_ARGS</code> is a
+ comma-separated list of query options and values:
+<pre class="pre codeblock"><code>-default_query_options='<var class="keyword varname">option</var>=<var class="keyword varname">value</var>,<var class="keyword varname">option</var>=<var class="keyword varname">value</var>,...'
+</code></pre>
+ These options control the behavior of queries performed by this
+ <span class="keyword cmdname">impalad</span> instance. The option values you specify here override the
+ default values for <a class="xref" href="impala_query_options.html#query_options">Impala query
+ options</a>, as shown by the <code class="ph codeph">SET</code> statement in
+ <span class="keyword cmdname">impala-shell</span>.
+ </div>
+ </li>
+
+
+
+ <li class="li">
+ <p class="p">
+ During troubleshooting, <span class="keyword">the appropriate support channel</span> might direct you to change other values,
+ particularly for <code class="ph codeph">IMPALA_SERVER_ARGS</code>, to work around issues or
+ gather debugging information.
+ </p>
+ </li>
+ </ul>
+
+
+
+ <div class="note note note_note"><span class="note__title notetitle">Note:</span>
+ <p class="p">
+ These startup options for the <span class="keyword cmdname">impalad</span> daemon are different from the
+ command-line options for the <span class="keyword cmdname">impala-shell</span> command. For the
+ <span class="keyword cmdname">impala-shell</span> options, see
+ <a class="xref" href="impala_shell_options.html#shell_options">impala-shell Configuration Options</a>.
+ </p>
+ </div>
+
+
+
+ </div>
+
+
+
+
+
+
+
+ </article>
+
+ <article class="topic concept nested1" aria-labelledby="ariaid-title3" id="config_options__config_options_checking">
+
+ <h2 class="title topictitle2" id="ariaid-title3">Checking the Values of Impala Configuration Options</h2>
+
+ <div class="body conbody">
+
+ <p class="p">
+ You can check the current runtime value of all these settings through the Impala web
+ interface, available by default at
+ <code class="ph codeph">http://<var class="keyword varname">impala_hostname</var>:25000/varz</code> for the
+ <span class="keyword cmdname">impalad</span> daemon,
+ <code class="ph codeph">http://<var class="keyword varname">impala_hostname</var>:25010/varz</code> for the
+ <span class="keyword cmdname">statestored</span> daemon, or
+ <code class="ph codeph">http://<var class="keyword varname">impala_hostname</var>:25020/varz</code> for the
+ <span class="keyword cmdname">catalogd</span> daemon.
+ </p>
+
+ </div>
+
+ </article>
+
+ <article class="topic concept nested1" aria-labelledby="ariaid-title4" id="config_options__config_options_impalad">
+
+ <h2 class="title topictitle2" id="ariaid-title4">Startup Options for impalad Daemon</h2>
+
+ <div class="body conbody">
+
+ <p class="p">
+ The <code class="ph codeph">impalad</code> daemon implements the main Impala service, which performs
+ query processing and reads and writes the data files.
+ </p>
+
+ </div>
+
+ </article>
+
+ <article class="topic concept nested1" aria-labelledby="ariaid-title5" id="config_options__config_options_statestored">
+
+ <h2 class="title topictitle2" id="ariaid-title5">Startup Options for statestored Daemon</h2>
+
+ <div class="body conbody">
+
+ <p class="p">
+ The <span class="keyword cmdname">statestored</span> daemon implements the Impala statestore service,
+ which monitors the availability of Impala services across the cluster, and handles
+ situations such as nodes becoming unavailable or becoming available again.
+ </p>
+
+ </div>
+
+ </article>
+
+ <article class="topic concept nested1" aria-labelledby="ariaid-title6" id="config_options__config_options_catalogd">
+
+ <h2 class="title topictitle2" id="ariaid-title6">Startup Options for catalogd Daemon</h2>
+
+ <div class="body conbody">
+
+ <p class="p">
+ The <span class="keyword cmdname">catalogd</span> daemon implements the Impala catalog service, which
+ broadcasts metadata changes to all the Impala nodes when Impala creates a table, inserts
+ data, or performs other kinds of DDL and DML operations.
+ </p>
+
+ <div class="p">
+ Use <code class="ph codeph">--load_catalog_in_background</code> option to control when
+ the metadata of a table is loaded.
+ <ul class="ul">
+ <li class="li">
+ If set to <code class="ph codeph">false</code>, the metadata of a table is
+ loaded when it is referenced for the first time. This means that the
+ first run of a particular query can be slower than subsequent runs.
+ Starting in Impala 2.2, the default for
+ <code class="ph codeph">load_catalog_in_background</code> is
+ <code class="ph codeph">false</code>.
+ </li>
+ <li class="li">
+ If set to <code class="ph codeph">true</code>, the catalog service attempts to
+ load metadata for a table even if no query needed that metadata. So
+ metadata will possibly be already loaded when the first query that
+ would need it is run. However, for the following reasons, we
+ recommend not to set the option to <code class="ph codeph">true</code>.
+ <ul class="ul">
+ <li class="li">
+ Background load can interfere with query-specific metadata
+ loading. This can happen on startup or after invalidating
+ metadata, with a duration depending on the amount of metadata,
+ and can lead to a seemingly random long running queries that are
+ difficult to diagnose.
+ </li>
+ <li class="li">
+ Impala may load metadata for tables that are possibly never
+ used, potentially increasing catalog size and consequently memory
+ usage for both catalog service and Impala Daemon.
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+ </div>
+
+ </article>
+
+</article></main></body></html>
http://git-wip-us.apache.org/repos/asf/impala/blob/fae51ec2/docs/build3x/html/topics/impala_config_performance.html
----------------------------------------------------------------------
diff --git a/docs/build3x/html/topics/impala_config_performance.html b/docs/build3x/html/topics/impala_config_performance.html
new file mode 100644
index 0000000..ad91a39
--- /dev/null
+++ b/docs/build3x/html/topics/impala_config_performance.html
@@ -0,0 +1,149 @@
+<!DOCTYPE html
+ SYSTEM "about:legacy-compat">
+<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_config.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.0.x"><meta name="version" content="Impala 3.0.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="config_performance"><link rel="stylesheet" type="text/css" href="../commonltr.css"><title>Post-Installation Configuration for Impala</title></head><body id="config_performance"><main role="main"><article role="article" aria-labelledby="ariaid-title1">
+
+ <h1 class="title topictitle1" id="ariaid-title1">Post-Installation Configuration for Impala</h1>
+
+
+ <div class="body conbody">
+
+ <p class="p" id="config_performance__p_24">
+ This section describes the mandatory and recommended configuration settings for Impala. If Impala is
+ installed using cluster management software, some of these configurations might be completed automatically; you must still
+ configure short-circuit reads manually. If you want to customize your environment, consider making the changes described in this topic.
+ </p>
+
+ <ul class="ul">
+ <li class="li">
+ You must enable short-circuit reads, whether or not Impala was installed with cluster
+ management software. This setting goes in the Impala configuration settings, not the Hadoop-wide settings.
+ </li>
+
+ <li class="li">
+ You must enable block location tracking, and you can optionally enable native checksumming for optimal performance.
+ </li>
+ </ul>
+
+ <section class="section" id="config_performance__section_fhq_wyv_ls"><h2 class="title sectiontitle">Mandatory: Short-Circuit Reads</h2>
+
+ <p class="p"> Enabling short-circuit reads allows Impala to read local data directly
+ from the file system. This removes the need to communicate through the
+ DataNodes, improving performance. This setting also minimizes the number
+ of additional copies of data. Short-circuit reads requires
+ <code class="ph codeph">libhadoop.so</code>
+ (the Hadoop Native Library) to be accessible to both the server and the
+ client. <code class="ph codeph">libhadoop.so</code> is not available if you have
+ installed from a tarball. You must install from an
+ <code class="ph codeph">.rpm</code>, <code class="ph codeph">.deb</code>, or parcel to use
+ short-circuit local reads.
+ </p>
+ <p class="p">
+ <strong class="ph b">To configure DataNodes for short-circuit reads:</strong>
+ </p>
+ <ol class="ol" id="config_performance__ol_qlq_wyv_ls">
+ <li class="li" id="config_performance__copy_config_files"> Copy the client
+ <code class="ph codeph">core-site.xml</code> and <code class="ph codeph">hdfs-site.xml</code>
+ configuration files from the Hadoop configuration directory to the
+ Impala configuration directory. The default Impala configuration
+ location is <code class="ph codeph">/etc/impala/conf</code>. </li>
+ <li class="li">
+
+
+
+ On all Impala nodes, configure the following properties in
+
+ Impala's copy of <code class="ph codeph">hdfs-site.xml</code> as shown: <pre class="pre codeblock"><code><property>
+ <name>dfs.client.read.shortcircuit</name>
+ <value>true</value>
+</property>
+
+<property>
+ <name>dfs.domain.socket.path</name>
+ <value>/var/run/hdfs-sockets/dn</value>
+</property>
+
+<property>
+ <name>dfs.client.file-block-storage-locations.timeout.millis</name>
+ <value>10000</value>
+</property></code></pre>
+
+
+ </li>
+ <li class="li">
+ <p class="p"> If <code class="ph codeph">/var/run/hadoop-hdfs/</code> is group-writable, make
+ sure its group is <code class="ph codeph">root</code>. </p>
+ <div class="note note note_note"><span class="note__title notetitle">Note:</span> If you are also going to enable block location tracking, you
+ can skip copying configuration files and restarting DataNodes and go
+ straight to <a class="xref" href="#config_performance__block_location_tracking">Optional: Block Location Tracking</a>.
+ Configuring short-circuit reads and block location tracking require
+ the same process of copying files and restarting services, so you
+ can complete that process once when you have completed all
+ configuration changes. Whether you copy files and restart services
+ now or during configuring block location tracking, short-circuit
+ reads are not enabled until you complete those final steps. </div>
+ </li>
+ <li class="li" id="config_performance__restart_all_datanodes"> After applying these changes, restart
+ all DataNodes. </li>
+ </ol>
+ </section>
+
+ <section class="section" id="config_performance__block_location_tracking"><h2 class="title sectiontitle">Mandatory: Block Location Tracking</h2>
+
+
+
+ <p class="p">
+ Enabling block location metadata allows Impala to know which disk data blocks are located on, allowing
+ better utilization of the underlying disks. Impala will not start unless this setting is enabled.
+ </p>
+
+ <p class="p">
+ <strong class="ph b">To enable block location tracking:</strong>
+ </p>
+
+ <ol class="ol">
+ <li class="li">
+ For each DataNode, adding the following to the <code class="ph codeph">hdfs-site.xml</code> file:
+<pre class="pre codeblock"><code><property>
+ <name>dfs.datanode.hdfs-blocks-metadata.enabled</name>
+ <value>true</value>
+</property> </code></pre>
+ </li>
+
+ <li class="li"> Copy the client
+ <code class="ph codeph">core-site.xml</code> and <code class="ph codeph">hdfs-site.xml</code>
+ configuration files from the Hadoop configuration directory to the
+ Impala configuration directory. The default Impala configuration
+ location is <code class="ph codeph">/etc/impala/conf</code>. </li>
+
+ <li class="li"> After applying these changes, restart
+ all DataNodes. </li>
+ </ol>
+ </section>
+
+ <section class="section" id="config_performance__native_checksumming"><h2 class="title sectiontitle">Optional: Native Checksumming</h2>
+
+
+
+ <p class="p">
+ Enabling native checksumming causes Impala to use an optimized native library for computing checksums, if
+ that library is available.
+ </p>
+
+ <p class="p" id="config_performance__p_29">
+ <strong class="ph b">To enable native checksumming:</strong>
+ </p>
+
+ <p class="p">
+ If you installed <span class="keyword"></span> from packages, the native checksumming library is installed and setup correctly. In
+ such a case, no additional steps are required. Conversely, if you installed by other means, such as with
+ tarballs, native checksumming may not be available due to missing shared objects. Finding the message
+ "<code class="ph codeph">Unable to load native-hadoop library for your platform... using builtin-java classes where
+ applicable</code>" in the Impala logs indicates native checksumming may be unavailable. To enable native
+ checksumming, you must build and install <code class="ph codeph">libhadoop.so</code> (the
+
+
+ Hadoop Native Library).
+ </p>
+ </section>
+ </div>
+<nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_config.html">Managing Impala</a></div></div></nav></article></main></body></html>
http://git-wip-us.apache.org/repos/asf/impala/blob/fae51ec2/docs/build3x/html/topics/impala_connecting.html
----------------------------------------------------------------------
diff --git a/docs/build3x/html/topics/impala_connecting.html b/docs/build3x/html/topics/impala_connecting.html
new file mode 100644
index 0000000..1411525
--- /dev/null
+++ b/docs/build3x/html/topics/impala_connecting.html
@@ -0,0 +1,187 @@
+<!DOCTYPE html
+ SYSTEM "about:legacy-compat">
+<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_impala_shell.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.0.x"><meta name="version" content="Impala 3.0.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="connecting"><link rel="stylesheet" type="text/css" href="../commonltr.css"><title>Connecting to impalad through impala-shell</title></head><body id="connecting"><main role="main"><article role="article" aria-labelledby="ariaid-title1">
+
+ <h1 class="title topictitle1" id="ariaid-title1">Connecting to impalad through impala-shell</h1>
+
+
+
+ <div class="body conbody">
+
+
+
+ <div class="p">
+ Within an <span class="keyword cmdname">impala-shell</span> session, you can only issue queries while connected to an instance
+ of the <span class="keyword cmdname">impalad</span> daemon. You can specify the connection information:
+ <ul class="ul">
+ <li class="li">
+ Through command-line options when you run the <span class="keyword cmdname">impala-shell</span> command.
+ </li>
+ <li class="li">
+ Through a configuration file that is read when you run the <span class="keyword cmdname">impala-shell</span> command.
+ </li>
+ <li class="li">
+ During an <span class="keyword cmdname">impala-shell</span> session, by issuing a <code class="ph codeph">CONNECT</code> command.
+ </li>
+ </ul>
+ See <a class="xref" href="impala_shell_options.html">impala-shell Configuration Options</a> for the command-line and configuration file options you can use.
+ </div>
+
+ <p class="p">
+ You can connect to any DataNode where an instance of <span class="keyword cmdname">impalad</span> is running,
+ and that host coordinates the execution of all queries sent to it.
+ </p>
+
+ <p class="p">
+ For simplicity during development, you might always connect to the same host, perhaps running <span class="keyword cmdname">impala-shell</span> on
+ the same host as <span class="keyword cmdname">impalad</span> and specifying the hostname as <code class="ph codeph">localhost</code>.
+ </p>
+
+ <p class="p">
+ In a production environment, you might enable load balancing, in which you connect to specific host/port combination
+ but queries are forwarded to arbitrary hosts. This technique spreads the overhead of acting as the coordinator
+ node among all the DataNodes in the cluster. See <a class="xref" href="impala_proxy.html">Using Impala through a Proxy for High Availability</a> for details.
+ </p>
+
+ <p class="p">
+ <strong class="ph b">To connect the Impala shell during shell startup:</strong>
+ </p>
+
+ <ol class="ol">
+ <li class="li">
+ Locate the hostname of a DataNode within the cluster that is running an instance of the
+ <span class="keyword cmdname">impalad</span> daemon. If that DataNode uses a non-default port (something
+ other than port 21000) for <span class="keyword cmdname">impala-shell</span> connections, find out the
+ port number also.
+ </li>
+
+ <li class="li">
+ Use the <code class="ph codeph">-i</code> option to the
+ <span class="keyword cmdname">impala-shell</span> interpreter to specify the connection information for
+ that instance of <span class="keyword cmdname">impalad</span>:
+<pre class="pre codeblock"><code># When you are logged into the same machine running impalad.
+# The prompt will reflect the current hostname.
+$ impala-shell
+
+# When you are logged into the same machine running impalad.
+# The host will reflect the hostname 'localhost'.
+$ impala-shell -i localhost
+
+# When you are logged onto a different host, perhaps a client machine
+# outside the Hadoop cluster.
+$ impala-shell -i <var class="keyword varname">some.other.hostname</var>
+
+# When you are logged onto a different host, and impalad is listening
+# on a non-default port. Perhaps a load balancer is forwarding requests
+# to a different host/port combination behind the scenes.
+$ impala-shell -i <var class="keyword varname">some.other.hostname</var>:<var class="keyword varname">port_number</var>
+</code></pre>
+ </li>
+ </ol>
+
+ <p class="p">
+ <strong class="ph b">To connect the Impala shell after shell startup:</strong>
+ </p>
+
+ <ol class="ol">
+ <li class="li">
+ Start the Impala shell with no connection:
+<pre class="pre codeblock"><code>$ impala-shell</code></pre>
+ <p class="p">
+ You should see a prompt like the following:
+ </p>
+<pre class="pre codeblock"><code>Welcome to the Impala shell. Press TAB twice to see a list of available commands.
+...
+<span class="ph">(Shell
+ build version: Impala Shell v3.0.x (<var class="keyword varname">hash</var>) built on
+ <var class="keyword varname">date</var>)</span>
+[Not connected] > </code></pre>
+ </li>
+
+ <li class="li">
+ Locate the hostname of a DataNode within the cluster that is running an instance of the
+ <span class="keyword cmdname">impalad</span> daemon. If that DataNode uses a non-default port (something
+ other than port 21000) for <span class="keyword cmdname">impala-shell</span> connections, find out the
+ port number also.
+ </li>
+
+ <li class="li">
+ Use the <code class="ph codeph">connect</code> command to connect to an Impala instance. Enter a command of the form:
+<pre class="pre codeblock"><code>[Not connected] > connect <var class="keyword varname">impalad-host</var>
+[<var class="keyword varname">impalad-host</var>:21000] ></code></pre>
+ <div class="note note note_note"><span class="note__title notetitle">Note:</span>
+ Replace <var class="keyword varname">impalad-host</var> with the hostname you have configured for any DataNode running
+ Impala in your environment. The changed prompt indicates a successful connection.
+ </div>
+ </li>
+ </ol>
+
+ <p class="p">
+ <strong class="ph b">To start <span class="keyword cmdname">impala-shell</span> in a specific database:</strong>
+ </p>
+
+ <p class="p">
+ You can use all the same connection options as in previous examples.
+ For simplicity, these examples assume that you are logged into one of
+ the DataNodes that is running the <span class="keyword cmdname">impalad</span> daemon.
+ </p>
+
+ <ol class="ol">
+ <li class="li">
+ Find the name of the database containing the relevant tables, views, and so
+ on that you want to operate on.
+ </li>
+
+ <li class="li">
+ Use the <code class="ph codeph">-d</code> option to the
+ <span class="keyword cmdname">impala-shell</span> interpreter to connect and immediately
+ switch to the specified database, without the need for a <code class="ph codeph">USE</code>
+ statement or fully qualified names:
+<pre class="pre codeblock"><code># Subsequent queries with unqualified names operate on
+# tables, views, and so on inside the database named 'staging'.
+$ impala-shell -i localhost -d staging
+
+# It is common during development, ETL, benchmarking, and so on
+# to have different databases containing the same table names
+# but with different contents or layouts.
+$ impala-shell -i localhost -d parquet_snappy_compression
+$ impala-shell -i localhost -d parquet_gzip_compression
+</code></pre>
+ </li>
+ </ol>
+
+ <p class="p">
+ <strong class="ph b">To run one or several statements in non-interactive mode:</strong>
+ </p>
+
+ <p class="p">
+ You can use all the same connection options as in previous examples.
+ For simplicity, these examples assume that you are logged into one of
+ the DataNodes that is running the <span class="keyword cmdname">impalad</span> daemon.
+ </p>
+
+ <ol class="ol">
+ <li class="li">
+ Construct a statement, or a file containing a sequence of statements,
+ that you want to run in an automated way, without typing or copying
+ and pasting each time.
+ </li>
+
+ <li class="li">
+ Invoke <span class="keyword cmdname">impala-shell</span> with the <code class="ph codeph">-q</code> option to run a single statement, or
+ the <code class="ph codeph">-f</code> option to run a sequence of statements from a file.
+ The <span class="keyword cmdname">impala-shell</span> command returns immediately, without going into
+ the interactive interpreter.
+<pre class="pre codeblock"><code># A utility command that you might run while developing shell scripts
+# to manipulate HDFS files.
+$ impala-shell -i localhost -d database_of_interest -q 'show tables'
+
+# A sequence of CREATE TABLE, CREATE VIEW, and similar DDL statements
+# can go into a file to make the setup process repeatable.
+$ impala-shell -i localhost -d database_of_interest -f recreate_tables.sql
+</code></pre>
+ </li>
+ </ol>
+
+ </div>
+<nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_impala_shell.html">Using the Impala Shell (impala-shell Command)</a></div></div></nav></article></main></body></html>
http://git-wip-us.apache.org/repos/asf/impala/blob/fae51ec2/docs/build3x/html/topics/impala_conversion_functions.html
----------------------------------------------------------------------
diff --git a/docs/build3x/html/topics/impala_conversion_functions.html b/docs/build3x/html/topics/impala_conversion_functions.html
new file mode 100644
index 0000000..5532c8e
--- /dev/null
+++ b/docs/build3x/html/topics/impala_conversion_functions.html
@@ -0,0 +1,288 @@
+<!DOCTYPE html
+ SYSTEM "about:legacy-compat">
+<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_functions.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.0.x"><meta name="version" content="Impala 3.0.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="conversion_functions"><link rel="stylesheet" type="text/css" href="../commonltr.css"><title>Impala Type Conversion Functions</title></head><body id="conversion_functions"><main role="main"><article role="article" aria-labelledby="ariaid-title1">
+
+ <h1 class="title topictitle1" id="ariaid-title1">Impala Type Conversion Functions</h1>
+
+
+
+ <div class="body conbody">
+
+ <p class="p">
+ Conversion functions are usually used in combination with other functions, to explicitly pass the expected
+ data types. Impala has strict rules regarding data types for function parameters. For example, Impala does
+ not automatically convert a <code class="ph codeph">DOUBLE</code> value to <code class="ph codeph">FLOAT</code>, a
+ <code class="ph codeph">BIGINT</code> value to <code class="ph codeph">INT</code>, or other conversion where precision could be lost or
+ overflow could occur. Also, for reporting or dealing with loosely defined schemas in big data contexts,
+ you might frequently need to convert values to or from the <code class="ph codeph">STRING</code> type.
+ </p>
+
+ <div class="note note note_note"><span class="note__title notetitle">Note:</span>
+ Although in <span class="keyword">Impala 2.3</span>, the <code class="ph codeph">SHOW FUNCTIONS</code> output for
+ database <code class="ph codeph">_IMPALA_BUILTINS</code> contains some function signatures
+ matching the pattern <code class="ph codeph">castto*</code>, these functions are not intended
+ for public use and are expected to be hidden in future.
+ </div>
+
+ <p class="p">
+ <strong class="ph b">Function reference:</strong>
+ </p>
+
+ <p class="p">
+ Impala supports the following type conversion functions:
+ </p>
+
+<dl class="dl">
+
+
+<dt class="dt dlterm" id="conversion_functions__cast">
+<code class="ph codeph">cast(<var class="keyword varname">expr</var> AS <var class="keyword varname">type</var>)</code>
+</dt>
+
+<dd class="dd">
+
+<strong class="ph b">Purpose:</strong> Converts the value of an expression to any other type.
+If the expression value is of a type that cannot be converted to the target type, the result is <code class="ph codeph">NULL</code>.
+<p class="p"><strong class="ph b">Usage notes:</strong>
+Use <code class="ph codeph">CAST</code> when passing a column value or literal to a function that
+expects a parameter with a different type.
+Frequently used in SQL operations such as <code class="ph codeph">CREATE TABLE AS SELECT</code>
+and <code class="ph codeph">INSERT ... VALUES</code> to ensure that values from various sources
+are of the appropriate type for the destination columns.
+Where practical, do a one-time <code class="ph codeph">CAST()</code> operation during the ingestion process
+to make each column into the appropriate type, rather than using many <code class="ph codeph">CAST()</code>
+operations in each query; doing type conversions for each row during each query can be expensive
+for tables with millions or billions of rows.
+</p>
+ <p class="p">
+ The way this function deals with time zones when converting to or from <code class="ph codeph">TIMESTAMP</code>
+ values is affected by the <code class="ph codeph">--use_local_tz_for_unix_timestamp_conversions</code> startup flag for the
+ <span class="keyword cmdname">impalad</span> daemon. See <a class="xref" href="../shared/../topics/impala_timestamp.html#timestamp">TIMESTAMP Data Type</a> for details about
+ how Impala handles time zone considerations for the <code class="ph codeph">TIMESTAMP</code> data type.
+ </p>
+
+<p class="p">
+ <strong class="ph b">Examples:</strong>
+ </p>
+<pre class="pre codeblock"><code>select concat('Here are the first ',10,' results.'); -- Fails
+select concat('Here are the first ',cast(10 as string),' results.'); -- Succeeds
+</code></pre>
+<p class="p">
+The following example starts with a text table where every column has a type of <code class="ph codeph">STRING</code>,
+which might be how you ingest data of unknown schema until you can verify the cleanliness of the underly values.
+Then it uses <code class="ph codeph">CAST()</code> to create a new Parquet table with the same data, but using specific
+numeric data types for the columns with numeric data. Using numeric types of appropriate sizes can result in
+substantial space savings on disk and in memory, and performance improvements in queries,
+over using strings or larger-than-necessary numeric types.
+</p>
+<pre class="pre codeblock"><code>create table t1 (name string, x string, y string, z string);
+
+create table t2 stored as parquet
+as select
+ name,
+ cast(x as bigint) x,
+ cast(y as timestamp) y,
+ cast(z as smallint) z
+from t1;
+
+describe t2;
++------+----------+---------+
+| name | type | comment |
++------+----------+---------+
+| name | string | |
+| x | bigint | |
+| y | smallint | |
+| z | tinyint | |
++------+----------+---------+
+</code></pre>
+<p class="p">
+ <strong class="ph b">Related information:</strong>
+ </p>
+<p class="p">
+
+ For details of casts from each kind of data type, see the description of
+ the appropriate type:
+ <a class="xref" href="impala_tinyint.html#tinyint">TINYINT Data Type</a>,
+ <a class="xref" href="impala_smallint.html#smallint">SMALLINT Data Type</a>,
+ <a class="xref" href="impala_int.html#int">INT Data Type</a>,
+ <a class="xref" href="impala_bigint.html#bigint">BIGINT Data Type</a>,
+ <a class="xref" href="impala_float.html#float">FLOAT Data Type</a>,
+ <a class="xref" href="impala_double.html#double">DOUBLE Data Type</a>,
+ <a class="xref" href="impala_decimal.html#decimal">DECIMAL Data Type (Impala 3.0 or higher only)</a>,
+ <a class="xref" href="impala_string.html#string">STRING Data Type</a>,
+ <a class="xref" href="impala_char.html#char">CHAR Data Type (Impala 2.0 or higher only)</a>,
+ <a class="xref" href="impala_varchar.html#varchar">VARCHAR Data Type (Impala 2.0 or higher only)</a>,
+ <a class="xref" href="impala_timestamp.html#timestamp">TIMESTAMP Data Type</a>,
+ <a class="xref" href="impala_boolean.html#boolean">BOOLEAN Data Type</a>
+</p>
+</dd>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<dt class="dt dlterm" id="conversion_functions__typeof">
+<code class="ph codeph">typeof(type value)</code>
+</dt>
+<dd class="dd">
+
+<strong class="ph b">Purpose:</strong> Returns the name of the data type corresponding to an expression. For types with
+extra attributes, such as length for <code class="ph codeph">CHAR</code> and <code class="ph codeph">VARCHAR</code>,
+or precision and scale for <code class="ph codeph">DECIMAL</code>, includes the full specification of the type.
+
+<p class="p"><strong class="ph b">Return type:</strong> <code class="ph codeph">string</code></p>
+<p class="p"><strong class="ph b">Usage notes:</strong> Typically used in interactive exploration of a schema, or in application code that programmatically generates schema definitions such as <code class="ph codeph">CREATE TABLE</code> statements.
+For example, previously, to understand the type of an expression such as
+<code class="ph codeph">col1 / col2</code> or <code class="ph codeph">concat(col1, col2, col3)</code>,
+you might have created a dummy table with a single row, using syntax such as <code class="ph codeph">CREATE TABLE foo AS SELECT 5 / 3.0</code>,
+and then doing a <code class="ph codeph">DESCRIBE</code> to see the type of the row.
+Or you might have done a <code class="ph codeph">CREATE TABLE AS SELECT</code> operation to create a table and
+copy data into it, only learning the types of the columns by doing a <code class="ph codeph">DESCRIBE</code> afterward.
+This technique is especially useful for arithmetic expressions involving <code class="ph codeph">DECIMAL</code> types,
+because the precision and scale of the result is typically different than that of the operands.
+</p>
+<p class="p">
+ <strong class="ph b">Added in:</strong> <span class="keyword">Impala 2.3.0</span>
+ </p>
+<p class="p">
+ <strong class="ph b">Examples:</strong>
+ </p>
+<p class="p">
+These examples show how to check the type of a simple literal or function value.
+Notice how adding even tiny integers together changes the data type of the result to
+avoid overflow, and how the results of arithmetic operations on <code class="ph codeph">DECIMAL</code> values
+have specific precision and scale attributes.
+</p>
+<pre class="pre codeblock"><code>select typeof(2)
++-----------+
+| typeof(2) |
++-----------+
+| TINYINT |
++-----------+
+
+select typeof(2+2)
++---------------+
+| typeof(2 + 2) |
++---------------+
+| SMALLINT |
++---------------+
+
+select typeof('xyz')
++---------------+
+| typeof('xyz') |
++---------------+
+| STRING |
++---------------+
+
+select typeof(now())
++---------------+
+| typeof(now()) |
++---------------+
+| TIMESTAMP |
++---------------+
+
+select typeof(5.3 / 2.1)
++-------------------+
+| typeof(5.3 / 2.1) |
++-------------------+
+| DECIMAL(6,4) |
++-------------------+
+
+select typeof(5.30001 / 2342.1);
++--------------------------+
+| typeof(5.30001 / 2342.1) |
++--------------------------+
+| DECIMAL(13,11) |
++--------------------------+
+
+select typeof(typeof(2+2))
++-----------------------+
+| typeof(typeof(2 + 2)) |
++-----------------------+
+| STRING |
++-----------------------+
+</code></pre>
+
+<p class="p">
+This example shows how even if you do not have a record of the type of a column,
+for example because the type was changed by <code class="ph codeph">ALTER TABLE</code> after the
+original <code class="ph codeph">CREATE TABLE</code>, you can still find out the type in a
+more compact form than examining the full <code class="ph codeph">DESCRIBE</code> output.
+Remember to use <code class="ph codeph">LIMIT 1</code> in such cases, to avoid an identical
+result value for every row in the table.
+</p>
+<pre class="pre codeblock"><code>create table typeof_example (a int, b tinyint, c smallint, d bigint);
+
+/* Empty result set if there is no data in the table. */
+select typeof(a) from typeof_example;
+
+/* OK, now we have some data but the type of column A is being changed. */
+insert into typeof_example values (1, 2, 3, 4);
+alter table typeof_example change a a bigint;
+
+/* We can always find out the current type of that column without doing a full DESCRIBE. */
+select typeof(a) from typeof_example limit 1;
++-----------+
+| typeof(a) |
++-----------+
+| BIGINT |
++-----------+
+</code></pre>
+<p class="p">
+This example shows how you might programmatically generate a <code class="ph codeph">CREATE TABLE</code> statement
+with the appropriate column definitions to hold the result values of arbitrary expressions.
+The <code class="ph codeph">typeof()</code> function lets you construct a detailed <code class="ph codeph">CREATE TABLE</code> statement
+without actually creating the table, as opposed to <code class="ph codeph">CREATE TABLE AS SELECT</code> operations
+where you create the destination table but only learn the column data types afterward through <code class="ph codeph">DESCRIBE</code>.
+</p>
+<pre class="pre codeblock"><code>describe typeof_example;
++------+----------+---------+
+| name | type | comment |
++------+----------+---------+
+| a | bigint | |
+| b | tinyint | |
+| c | smallint | |
+| d | bigint | |
++------+----------+---------+
+
+/* An ETL or business intelligence tool might create variations on a table with different file formats,
+ different sets of columns, and so on. TYPEOF() lets an application introspect the types of the original columns. */
+select concat('create table derived_table (a ', typeof(a), ', b ', typeof(b), ', c ',
+ typeof(c), ', d ', typeof(d), ') stored as parquet;')
+ as 'create table statement'
+from typeof_example limit 1;
++-------------------------------------------------------------------------------------------+
+| create table statement |
++-------------------------------------------------------------------------------------------+
+| create table derived_table (a BIGINT, b TINYINT, c SMALLINT, d BIGINT) stored as parquet; |
++-------------------------------------------------------------------------------------------+
+</code></pre>
+</dd>
+
+
+</dl>
+
+ </div>
+<nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_functions.html">Impala Built-In Functions</a></div></div></nav></article></main></body></html>