| <!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 2025"><meta name="DC.rights.owner" content="(C) Copyright 2025"><meta name="DC.Type" content="concept"><meta name="DC.Relation" scheme="URI" content="../topics/impala_langref.html"><meta name="prodname" content="Impala"><meta name="prodname" content="Impala"><meta name="version" content="Impala 3.4.x"><meta name="version" content="Impala 3.4.x"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="literals"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>Literals</title></head><body id="literals"><header role="banner"><!-- |
| The DITA Open Toolkit is licensed for use under the the Apache |
| Software Foundation License v2.0. |
| |
| A copy of the Apache Software Foundation License 2.0 is |
| available at http://opensource.org/licenses/apache2.0.php |
| |
| This statement must be included in any copies of DITA Open |
| Toolkit code. |
| --><div class="header"> |
| <p>Apache Impala</p> |
| <hr> |
| </div></header><nav role="toc"><ul><li><a href="../topics/impala_intro.html">Introducing Apache Impala</a></li><li><a href="../topics/impala_concepts.html">Concepts and Architecture</a></li><li><a href="../topics/impala_planning.html">Deployment Planning</a></li><li><a href="../topics/impala_install.html">Installing Impala</a></li><li><a href="../topics/impala_config.html">Managing Impala</a></li><li><a href="../topics/impala_upgrading.html">Upgrading Impala</a></li><li><a href="../topics/impala_processes.html">Starting Impala</a></li><li><a href="../topics/impala_tutorial.html">Tutorials</a></li><li><a href="../topics/impala_admin.html">Administration</a></li><li><a href="../topics/impala_security.html">Impala Security</a></li><li><a href="../topics/impala_langref.html">SQL Reference</a><ul><li><a href="../topics/impala_comments.html">Comments</a></li><li><a href="../topics/impala_datatypes.html">Data Types</a></li><li class="active"><a href="../topics/impala_literals.html">Literals</a></li><li><a href="../topics/impala_operators.html">SQL Operators</a></li><li><a href="../topics/impala_schema_objects.html">Schema Objects and Object Names</a></li><li><a href="../topics/impala_transactions.html">Transactions</a></li><li><a href="../topics/impala_langref_sql.html">SQL Statements</a></li><li><a href="../topics/impala_functions.html">Built-In Functions</a></li><li><a href="../topics/impala_udf.html">User-Defined Functions (UDFs)</a></li><li><a href="../topics/impala_langref_unsupported.html">SQL Differences Between Impala and Hive</a></li><li><a href="../topics/impala_porting.html">Porting SQL</a></li><li><a href="../topics/impala_utf_8.html">UTF-8 Support</a></li></ul></li><li><a href="../topics/impala_performance.html">Performance Tuning</a></li><li><a href="../topics/impala_scalability.html">Scalability Considerations</a></li><li><a href="../topics/impala_resource_management.html">Resource Management</a></li><li><a href="../topics/impala_partitioning.html">Partitioning</a></li><li><a href="../topics/impala_file_formats.html">File Formats</a></li><li><a href="../topics/impala_jdbc_external_table.html">Using Impala to Query External JDBC Data Sources</a></li><li><a href="../topics/impala_kudu.html">Using Impala to Query Kudu Tables</a></li><li><a href="../topics/impala_hbase.html">HBase Tables</a></li><li><a href="../topics/impala_iceberg.html">Iceberg Tables</a></li><li><a href="../topics/impala_s3.html">S3 Tables</a></li><li><a href="../topics/impala_adls.html">ADLS Tables</a></li><li><a href="../topics/impala_isilon.html">Isilon Storage</a></li><li><a href="../topics/impala_ozone.html">Ozone Storage</a></li><li><a href="../topics/impala_logging.html">Logging</a></li><li><a href="../topics/impala_client.html">Client Access</a></li><li><a href="../topics/impala_fault_tolerance.html">Fault Tolerance</a></li><li><a href="../topics/impala_troubleshooting.html">Troubleshooting Impala</a></li><li><a href="../topics/impala_ports.html">Ports Used by Impala</a></li><li><a href="../topics/impala_reserved_words.html">Impala Reserved Words</a></li><li><a href="../topics/impala_faq.html">Impala Frequently Asked Questions</a></li><li><a href="../topics/impala_release_notes.html">Impala Release Notes</a></li></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1"> |
| |
| <h1 class="title topictitle1" id="ariaid-title1">Literals</h1> |
| |
| |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| Each of the Impala data types has corresponding notation for literal values of that type. |
| You specify literal values in SQL statements, such as in the <code class="ph codeph">SELECT</code> list |
| or <code class="ph codeph">WHERE</code> clause of a query, or as an argument to a function call. See |
| <a class="xref" href="impala_datatypes.html#datatypes">Data Types</a> for a complete list of types, |
| ranges, and conversion rules. |
| </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_langref.html">Impala SQL Language Reference</a></div></div></nav><article class="topic concept nested1" aria-labelledby="ariaid-title2" id="literals__numeric_literals"> |
| |
| <h2 class="title topictitle2" id="ariaid-title2">Numeric Literals</h2> |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| To write literals for the integer types (<code class="ph codeph">TINYINT</code>, |
| <code class="ph codeph">SMALLINT</code>, <code class="ph codeph">INT</code>, and <code class="ph codeph">BIGINT</code>), use a |
| sequence of digits with optional leading zeros. |
| </p> |
| |
| <p class="p"> |
| To write literals for the floating-point types (<code class="ph codeph">DECIMAL</code>, |
| <code class="ph codeph">FLOAT</code>, and <code class="ph codeph">DOUBLE</code>), use a sequence of digits with an |
| optional decimal point (<code class="ph codeph">.</code> character). To preserve accuracy during |
| arithmetic expressions, Impala interprets floating-point literals as the |
| <code class="ph codeph">DECIMAL</code> type with the smallest appropriate precision and scale, until |
| required by the context to convert the result to <code class="ph codeph">FLOAT</code> or |
| <code class="ph codeph">DOUBLE</code>. |
| </p> |
| |
| <p class="p"> |
| Integer values are promoted to floating-point when necessary, based on the context. |
| </p> |
| |
| <p class="p"> |
| You can also use exponential notation by including an <code class="ph codeph">e</code> character. For |
| example, <code class="ph codeph">1e6</code> is 1 times 10 to the power of 6 (1 million). A number in |
| exponential notation is always interpreted as floating-point. |
| </p> |
| |
| <p class="p"> |
| When Impala encounters a numeric literal, it considers the type to be the |
| <span class="q">"smallest"</span> that can accurately represent the value. The type is promoted to larger |
| or more accurate types if necessary, based on subsequent parts of an expression. |
| </p> |
| |
| <p class="p"> |
| For example, you can see by the types Impala defines for the following table columns how |
| it interprets the corresponding numeric literals: |
| </p> |
| |
| <pre class="pre codeblock"><code>[localhost:21000] > create table ten as select 10 as x; |
| +-------------------+ |
| | summary | |
| +-------------------+ |
| | Inserted 1 row(s) | |
| +-------------------+ |
| [localhost:21000] > desc ten; |
| +------+---------+---------+ |
| | name | type | comment | |
| +------+---------+---------+ |
| | x | tinyint | | |
| +------+---------+---------+ |
| |
| [localhost:21000] > create table four_k as select 4096 as x; |
| +-------------------+ |
| | summary | |
| +-------------------+ |
| | Inserted 1 row(s) | |
| +-------------------+ |
| [localhost:21000] > desc four_k; |
| +------+----------+---------+ |
| | name | type | comment | |
| +------+----------+---------+ |
| | x | smallint | | |
| +------+----------+---------+ |
| |
| [localhost:21000] > create table one_point_five as select 1.5 as x; |
| +-------------------+ |
| | summary | |
| +-------------------+ |
| | Inserted 1 row(s) | |
| +-------------------+ |
| [localhost:21000] > desc one_point_five; |
| +------+--------------+---------+ |
| | name | type | comment | |
| +------+--------------+---------+ |
| | x | decimal(2,1) | | |
| +------+--------------+---------+ |
| |
| [localhost:21000] > create table one_point_three_three_three as select 1.333 as x; |
| +-------------------+ |
| | summary | |
| +-------------------+ |
| | Inserted 1 row(s) | |
| +-------------------+ |
| [localhost:21000] > desc one_point_three_three_three; |
| +------+--------------+---------+ |
| | name | type | comment | |
| +------+--------------+---------+ |
| | x | decimal(4,3) | | |
| +------+--------------+---------+ |
| </code></pre> |
| |
| </div> |
| |
| </article> |
| |
| <article class="topic concept nested1" aria-labelledby="ariaid-title3" id="literals__string_literals"> |
| |
| <h2 class="title topictitle2" id="ariaid-title3">String Literals</h2> |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| String literals are quoted using either single or double quotation marks. You can use |
| either kind of quotes for string literals, even both kinds for different literals within |
| the same statement. |
| </p> |
| |
| <p class="p"> |
| Quoted literals are considered to be of type <code class="ph codeph">STRING</code>. To use quoted |
| literals in contexts requiring a <code class="ph codeph">CHAR</code> or <code class="ph codeph">VARCHAR</code> |
| value, <code class="ph codeph">CAST()</code> the literal to a <code class="ph codeph">CHAR</code> or |
| <code class="ph codeph">VARCHAR</code> of the appropriate length. |
| </p> |
| |
| <p class="p"> |
| <strong class="ph b">Escaping special characters:</strong> |
| </p> |
| |
| <p class="p"> |
| To encode special characters within a string literal, precede them with the backslash |
| (<code class="ph codeph">\</code>) escape character: |
| </p> |
| |
| <ul class="ul"> |
| <li class="li"> |
| <code class="ph codeph">\t</code> represents a tab. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\n</code> represents a newline or linefeed. This might cause extra line |
| breaks in <span class="keyword cmdname">impala-shell</span> output. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\r</code> represents a carriage return. This might cause unusual formatting |
| (making it appear that some content is overwritten) in <span class="keyword cmdname">impala-shell</span> |
| output. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\b</code> represents a backspace. This might cause unusual formatting |
| (making it appear that some content is overwritten) in <span class="keyword cmdname">impala-shell</span> |
| output. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\0</code> represents an ASCII <code class="ph codeph">nul</code> character (not the same |
| as a SQL <code class="ph codeph">NULL</code>). This might not be visible in |
| <span class="keyword cmdname">impala-shell</span> output. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\Z</code> represents a DOS end-of-file character. This might not be visible |
| in <span class="keyword cmdname">impala-shell</span> output. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\%</code> and <code class="ph codeph">\_</code> can be used to escape wildcard characters |
| within the string passed to the <code class="ph codeph">LIKE</code> operator. |
| </li> |
| |
| <li class="li"> |
| <code class="ph codeph">\</code> followed by 3 octal digits represents the ASCII code of a single |
| character; for example, <code class="ph codeph">\101</code> is ASCII 65, the character |
| <code class="ph codeph">A</code>. |
| </li> |
| |
| <li class="li"> |
| Use two consecutive backslashes (<code class="ph codeph">\\</code>) to prevent the backslash from |
| being interpreted as an escape character. |
| </li> |
| |
| <li class="li"> |
| Use the backslash to escape single or double quotation mark characters within a string |
| literal, if the literal is enclosed by the same type of quotation mark. |
| </li> |
| |
| <li class="li"> |
| If the character following the <code class="ph codeph">\</code> does not represent the start of a |
| recognized escape sequence, the character is passed through unchanged. |
| </li> |
| </ul> |
| |
| <p class="p"> |
| <strong class="ph b">Quotes within quotes:</strong> |
| </p> |
| |
| <p class="p"> |
| To include a single quotation character within a string value, enclose the literal with |
| either single or double quotation marks, and optionally escape the single quote as a |
| <code class="ph codeph">\'</code> sequence. Earlier releases required escaping a single quote inside |
| double quotes. Continue using escape sequences in this case if you also need to run your |
| SQL code on older versions of Impala. |
| </p> |
| |
| <p class="p"> |
| To include a double quotation character within a string value, enclose the literal with |
| single quotation marks, no escaping is necessary in this case. Or, enclose the literal |
| with double quotation marks and escape the double quote as a <code class="ph codeph">\"</code> |
| sequence. |
| </p> |
| |
| <pre class="pre codeblock"><code>[localhost:21000] > select "What\'s happening?" as single_within_double, |
| > 'I\'m not sure.' as single_within_single, |
| > "Homer wrote \"The Iliad\"." as double_within_double, |
| > 'Homer also wrote "The Odyssey".' as double_within_single; |
| +----------------------+----------------------+--------------------------+---------------------------------+ |
| | single_within_double | single_within_single | double_within_double | double_within_single | |
| +----------------------+----------------------+--------------------------+---------------------------------+ |
| | What's happening? | I'm not sure. | Homer wrote "The Iliad". | Homer also wrote "The Odyssey". | |
| +----------------------+----------------------+--------------------------+---------------------------------+ |
| </code></pre> |
| |
| <p class="p"> |
| <strong class="ph b">Field terminator character in CREATE TABLE:</strong> |
| </p> |
| |
| <div class="note note note_note"><span class="note__title notetitle">Note:</span> |
| The <code class="ph codeph">CREATE TABLE</code> clauses <code class="ph codeph">FIELDS TERMINATED BY</code>, |
| <code class="ph codeph">ESCAPED BY</code>, and <code class="ph codeph">LINES TERMINATED BY</code> have special rules |
| for the string literal used for their argument, because they all require a single |
| character. You can use a regular character surrounded by single or double quotation |
| marks, an octal sequence such as <code class="ph codeph">'\054'</code> (representing a comma), or an |
| integer in the range '-127'..'128' (with quotation marks but no backslash), which is |
| interpreted as a single-byte ASCII character. Negative values are subtracted from 256; |
| for example, <code class="ph codeph">FIELDS TERMINATED BY '-2'</code> sets the field delimiter to |
| ASCII code 254, the <span class="q">"Icelandic Thorn"</span> character used as a delimiter by some data |
| formats. |
| </div> |
| |
| <p class="p"> |
| <strong class="ph b">impala-shell considerations:</strong> |
| </p> |
| |
| <p class="p"> |
| When dealing with output that includes non-ASCII or non-printable characters such as |
| linefeeds and backspaces, use the <span class="keyword cmdname">impala-shell</span> options to save to a |
| file, turn off pretty printing, or both rather than relying on how the output appears |
| visually. See <a class="xref" href="impala_shell_options.html#shell_options">impala-shell Configuration Options</a> for a list of |
| <span class="keyword cmdname">impala-shell</span> options. |
| </p> |
| |
| </div> |
| |
| </article> |
| |
| <article class="topic concept nested1" aria-labelledby="ariaid-title4" id="literals__boolean_literals"> |
| |
| <h2 class="title topictitle2" id="ariaid-title4">Boolean Literals</h2> |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| For <code class="ph codeph">BOOLEAN</code> values, the literals are <code class="ph codeph">TRUE</code> and |
| <code class="ph codeph">FALSE</code>, with no quotation marks and case-insensitive. |
| </p> |
| |
| <p class="p"> |
| <strong class="ph b">Examples:</strong> |
| </p> |
| |
| <pre class="pre codeblock"><code>select true; |
| select * from t1 where assertion = false; |
| select case bool_col when true then 'yes' when false 'no' else 'null' end from t1;</code></pre> |
| |
| </div> |
| |
| </article> |
| |
| <article class="topic concept nested1" aria-labelledby="ariaid-title5" id="literals__timestamp_literals"> |
| |
| <h2 class="title topictitle2" id="ariaid-title5">Timestamp Literals</h2> |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| Impala automatically converts <code class="ph codeph">STRING</code> literals of the correct format |
| into <code class="ph codeph">TIMESTAMP</code> values. Timestamp values are accepted in the format |
| <code class="ph codeph">'yyyy‑MM‑dd HH:mm:ss.SSSSSS'</code>, and can consist of just the date, or |
| just the time, with or without the fractional second portion. For example, you can |
| specify <code class="ph codeph">TIMESTAMP</code> values such as <code class="ph codeph">'1966‑07‑30'</code>, |
| <code class="ph codeph">'08:30:00'</code>, or <code class="ph codeph">'1985‑09‑25 17:45:30.005'</code>. |
| </p><p class="p"> |
| Leading zeroes are not required in the numbers representing the date component, such as |
| month and date, or the time component, such as hour, minute, and second. For example, |
| Impala accepts both <code class="ph codeph">'2018‑1‑1 01:02:03'</code> and |
| <code class="ph codeph">'2018‑01‑01 1:2:3'</code> as valid. |
| </p><p class="p"> |
| In <code class="ph codeph">STRING</code> to <code class="ph codeph">TIMESTAMP</code> conversions, leading and |
| trailing white spaces, such as a space, a tab, a newline, or a carriage return, are |
| ignored. For example, Impala treats the following as equivalent: |
| '1999‑12‑01 01:02:03 ', ' 1999‑12‑01 01:02:03', |
| '1999‑12‑01 01:02:03\r\n\t'. |
| </p><div class="p"> |
| When you convert or cast a <code class="ph codeph">STRING</code> literal to |
| <code class="ph codeph">TIMESTAMP</code>, you can use the following separators between the date part |
| and the time part: |
| <ul class="ul"> |
| <li class="li"> |
| <p class="p"> |
| One or more space characters |
| </p> |
| |
| <p class="p"> |
| Example: <code class="ph codeph">CAST('2001-01-09 01:05:01' AS TIMESTAMP)</code> |
| </p> |
| </li> |
| |
| <li class="li"> |
| <p class="p"> |
| The character “T” |
| </p> |
| |
| <p class="p"> |
| Example: <code class="ph codeph">CAST('2001-01-09T01:05:01' AS TIMESTAMP)</code> |
| </p> |
| </li> |
| </ul> |
| </div> |
| |
| <p class="p"> |
| You can also use <code class="ph codeph">INTERVAL</code> expressions to add or subtract from timestamp |
| literal values, such as <code class="ph codeph">CAST('1966‑07‑30' AS |
| TIMESTAMP) + INTERVAL 5 YEARS + INTERVAL 3 DAYS</code>. See |
| <a class="xref" href="impala_timestamp.html#timestamp">TIMESTAMP Data Type</a> for details. |
| </p> |
| |
| <p class="p"> |
| Depending on your data pipeline, you might receive date and time data as text, in |
| notation that does not exactly match the format for Impala <code class="ph codeph">TIMESTAMP</code> |
| literals. See <a class="xref" href="impala_datetime_functions.html#datetime_functions">Impala Date and Time Functions</a> for |
| functions that can convert between a variety of string literals (including different |
| field order, separators, and timezone notation) and equivalent |
| <code class="ph codeph">TIMESTAMP</code> or numeric values. |
| </p> |
| |
| </div> |
| |
| </article> |
| |
| <article class="topic concept nested1" aria-labelledby="ariaid-title6" id="literals__date_literals"> |
| |
| <h2 class="title topictitle2" id="ariaid-title6">Date Literals</h2> |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| The <code class="ph codeph">DATE</code> literals are in the form of <code class="ph codeph">DATE'YYYY-MM-DD'</code>. |
| For example, <code class="ph codeph">DATE '2013-01-01'</code> |
| </p> |
| |
| </div> |
| |
| </article> |
| |
| <article class="topic concept nested1" aria-labelledby="ariaid-title7" id="literals__null"> |
| |
| <h2 class="title topictitle2" id="ariaid-title7">NULL</h2> |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| The notion of <code class="ph codeph">NULL</code> values is familiar from all kinds of database |
| systems, but each SQL dialect can have its own behavior and restrictions on |
| <code class="ph codeph">NULL</code> values. For Big Data processing, the precise semantics of |
| <code class="ph codeph">NULL</code> values are significant: any misunderstanding could lead to |
| inaccurate results or misformatted data, that could be time-consuming to correct for |
| large data sets. |
| </p> |
| |
| <ul class="ul"> |
| <li class="li"> |
| <code class="ph codeph">NULL</code> is a different value than an empty string. The empty string is |
| represented by a string literal with nothing inside, <code class="ph codeph">""</code> or |
| <code class="ph codeph">''</code>. |
| </li> |
| |
| <li class="li"> |
| In a delimited text file, the <code class="ph codeph">NULL</code> value is represented by the |
| special token <code class="ph codeph">\N</code>. |
| </li> |
| |
| <li class="li"> |
| When Impala inserts data into a partitioned table, and the value of one of the |
| partitioning columns is <code class="ph codeph">NULL</code> or the empty string, the data is placed |
| in a special partition that holds only these two kinds of values. When these values |
| are returned in a query, the result is <code class="ph codeph">NULL</code> whether the value was |
| originally <code class="ph codeph">NULL</code> or an empty string. This behavior is compatible with |
| the way Hive treats <code class="ph codeph">NULL</code> values in partitioned tables. Hive does not |
| allow empty strings as partition keys, and it returns a string value such as |
| <code class="ph codeph">__HIVE_DEFAULT_PARTITION__</code> instead of <code class="ph codeph">NULL</code> when such |
| values are returned from a query. For example: |
| <pre class="pre codeblock"><code>create table t1 (i int) partitioned by (x int, y string); |
| -- Select an INT column from another table, with all rows going into a special HDFS subdirectory |
| -- named __HIVE_DEFAULT_PARTITION__. Depending on whether one or both of the partitioning keys |
| -- are null, this special directory name occurs at different levels of the physical data directory |
| -- for the table. |
| insert into t1 partition(x=NULL, y=NULL) select c1 from some_other_table; |
| insert into t1 partition(x, y=NULL) select c1, c2 from some_other_table; |
| insert into t1 partition(x=NULL, y) select c1, c3 from some_other_table;</code></pre> |
| </li> |
| |
| <li class="li"> |
| There is no <code class="ph codeph">NOT NULL</code> clause when defining a column to prevent |
| <code class="ph codeph">NULL</code> values in that column. |
| </li> |
| |
| <li class="li"> |
| There is no <code class="ph codeph">DEFAULT</code> clause to specify a non-<code class="ph codeph">NULL</code> |
| default value. |
| </li> |
| |
| <li class="li"> |
| If an <code class="ph codeph">INSERT</code> operation mentions some columns but not others, the |
| unmentioned columns contain <code class="ph codeph">NULL</code> for all inserted rows. |
| </li> |
| |
| <li class="li"> |
| <p class="p"> |
| In Impala 1.2.1 and higher, all <code class="ph codeph">NULL</code> values come at the end of the |
| result set for <code class="ph codeph">ORDER BY ... ASC</code> queries, and at the beginning of the |
| result set for <code class="ph codeph">ORDER BY ... DESC</code> queries. In effect, |
| <code class="ph codeph">NULL</code> is considered greater than all other values for sorting purposes. |
| The original Impala behavior always put <code class="ph codeph">NULL</code> values at the end, even |
| for <code class="ph codeph">ORDER BY ... DESC</code> queries. The new behavior in Impala 1.2.1 makes |
| Impala more compatible with other popular database systems. In Impala 1.2.1 and higher, |
| you can override or specify the sorting behavior for <code class="ph codeph">NULL</code> by adding the |
| clause <code class="ph codeph">NULLS FIRST</code> or <code class="ph codeph">NULLS LAST</code> at the end of the |
| <code class="ph codeph">ORDER BY</code> clause. |
| </p> |
| |
| <div class="note note note_note"><span class="note__title notetitle">Note:</span> |
| |
| Because the <code class="ph codeph">NULLS FIRST</code> and <code class="ph codeph">NULLS LAST</code> keywords |
| are not currently available in Hive queries, any views you create using those |
| keywords will not be available through Hive. |
| </div> |
| </li> |
| |
| <li class="li"> |
| In all other contexts besides sorting with <code class="ph codeph">ORDER BY</code>, comparing a |
| <code class="ph codeph">NULL</code> to anything else returns <code class="ph codeph">NULL</code>, making the |
| comparison meaningless. For example, <code class="ph codeph">10 > NULL</code> produces |
| <code class="ph codeph">NULL</code>, <code class="ph codeph">10 < NULL</code> also produces |
| <code class="ph codeph">NULL</code>, <code class="ph codeph">5 BETWEEN 1 AND NULL</code> produces |
| <code class="ph codeph">NULL</code>, and so on. |
| </li> |
| </ul> |
| |
| <p class="p"> |
| Several built-in functions serve as shorthand for evaluating expressions and returning |
| <code class="ph codeph">NULL</code>, 0, or some other substitution value depending on the expression |
| result: <code class="ph codeph">ifnull()</code>, <code class="ph codeph">isnull()</code>, <code class="ph codeph">nvl()</code>, |
| <code class="ph codeph">nullif()</code>, <code class="ph codeph">nullifzero()</code>, and |
| <code class="ph codeph">zeroifnull()</code>. See |
| <a class="xref" href="impala_conditional_functions.html#conditional_functions">Impala Conditional Functions</a> for details. |
| </p> |
| |
| <p class="p"> |
| <strong class="ph b">Kudu considerations:</strong> |
| </p> |
| |
| <p class="p"> |
| Columns in Kudu tables have an attribute that specifies whether or not they can contain |
| <code class="ph codeph">NULL</code> values. A column with a <code class="ph codeph">NULL</code> attribute can |
| contain nulls. A column with a <code class="ph codeph">NOT NULL</code> attribute cannot contain any |
| nulls, and an <code class="ph codeph">INSERT</code>, <code class="ph codeph">UPDATE</code>, or |
| <code class="ph codeph">UPSERT</code> statement will skip any row that attempts to store a null in a |
| column designated as <code class="ph codeph">NOT NULL</code>. Kudu tables default to the |
| <code class="ph codeph">NULL</code> setting for each column, except columns that are part of the |
| primary key. |
| </p> |
| |
| <p class="p"> |
| In addition to columns with the <code class="ph codeph">NOT NULL</code> attribute, Kudu tables also |
| have restrictions on <code class="ph codeph">NULL</code> values in columns that are part of the |
| primary key for a table. No column that is part of the primary key in a Kudu table can |
| contain any <code class="ph codeph">NULL</code> values. |
| </p> |
| |
| </div> |
| |
| </article> |
| |
| </article></main></body></html> |