| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head><meta http-equiv="Content-Type" content="text/html; 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.Title" content="TINYINT Data Type" /> |
| <meta name="DC.Relation" scheme="URI" content="../topics/impala_datatypes.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="tinyint" /> |
| <link rel="stylesheet" type="text/css" href="../commonltr.css" /> |
| <title>TINYINT Data Type</title> |
| </head> |
| <body id="tinyint"> |
| |
| |
| <h1 class="title topictitle1" id="ariaid-title1">TINYINT Data Type</h1> |
| |
| |
| |
| |
| <div class="body conbody"> |
| |
| <p class="p"> |
| A 1-byte integer data type used in <code class="ph codeph">CREATE TABLE</code> and <code class="ph codeph">ALTER TABLE</code> statements. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Syntax:</strong> |
| </p> |
| |
| |
| <p class="p"> |
| In the column definition of a <code class="ph codeph">CREATE TABLE</code> statement: |
| </p> |
| |
| |
| <pre class="pre codeblock"><code><var class="keyword varname">column_name</var> TINYINT</code></pre> |
| |
| <p class="p"> |
| <strong class="ph b">Range:</strong> -128 .. 127. There is no <code class="ph codeph">UNSIGNED</code> subtype. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Conversions:</strong> Impala automatically converts to a larger integer type (<code class="ph codeph">SMALLINT</code>, |
| <code class="ph codeph">INT</code>, or <code class="ph codeph">BIGINT</code>) or a floating-point type (<code class="ph codeph">FLOAT</code> or |
| <code class="ph codeph">DOUBLE</code>) automatically. Use <code class="ph codeph">CAST()</code> to convert to <code class="ph codeph">STRING</code> or |
| <code class="ph codeph">TIMESTAMP</code>. |
| <span class="ph"> Casting an integer or floating-point value |
| <code class="ph codeph">N</code> to <code class="ph codeph">TIMESTAMP</code> produces a value that is |
| <code class="ph codeph">N</code> seconds past the start of the epoch date (January 1, 1970). By |
| default, the result value represents a date and time in the UTC time zone. If the |
| setting <code class="ph codeph">‑‑use_local_tz_for_unix_timestamp_conversions=true</code> |
| is in effect, the resulting <code class="ph codeph">TIMESTAMP</code> represents a date and time in the |
| local time zone. </span> |
| </p> |
| |
| |
| <p class="p"> |
| Impala does not return column overflows as <code class="ph codeph">NULL</code>, so that customers can |
| distinguish between <code class="ph codeph">NULL</code> data and overflow conditions similar to how |
| they do so with traditional database systems. Impala returns the largest or smallest |
| value in the range for the type. For example, valid values for a |
| <code class="ph codeph">tinyint</code> range from -128 to 127. In Impala, a <code class="ph codeph">tinyint</code> |
| with a value of -200 returns -128 rather than <code class="ph codeph">NULL</code>. A |
| <code class="ph codeph">tinyint</code> with a value of 200 returns 127. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Usage notes:</strong> |
| </p> |
| |
| |
| <p class="p"> |
| For a convenient and automated way to check the bounds of the <code class="ph codeph">TINYINT</code> type, call the |
| functions <code class="ph codeph">MIN_TINYINT()</code> and <code class="ph codeph">MAX_TINYINT()</code>. |
| </p> |
| |
| |
| <p class="p"> |
| If an integer value is too large to be represented as a <code class="ph codeph">TINYINT</code>, use a |
| <code class="ph codeph">SMALLINT</code> instead. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">NULL considerations:</strong> Casting any non-numeric value to this type produces a |
| <code class="ph codeph">NULL</code> value. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Examples:</strong> |
| </p> |
| |
| |
| <pre class="pre codeblock"><code>CREATE TABLE t1 (x TINYINT); |
| SELECT CAST(100 AS TINYINT); |
| </code></pre> |
| |
| <p class="p"> |
| <strong class="ph b">Parquet considerations:</strong> |
| </p> |
| |
| |
| |
| |
| <p class="p"> |
| Physically, Parquet files represent <code class="ph codeph">TINYINT</code> and <code class="ph codeph">SMALLINT</code> values as 32-bit |
| integers. Although Impala rejects attempts to insert out-of-range values into such columns, if you create a |
| new table with the <code class="ph codeph">CREATE TABLE ... LIKE PARQUET</code> syntax, any <code class="ph codeph">TINYINT</code> or |
| <code class="ph codeph">SMALLINT</code> columns in the original table turn into <code class="ph codeph">INT</code> columns in the new |
| table. |
| </p> |
| |
| |
| |
| |
| <p class="p"> |
| <strong class="ph b">HBase considerations:</strong> This data type is fully compatible with HBase tables. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Text table considerations:</strong> Values of this type are potentially larger in text |
| tables than in tables using Parquet or other binary formats. |
| </p> |
| |
| |
| |
| |
| <p class="p"> |
| <strong class="ph b">Internal details:</strong> Represented in memory as a 1-byte value. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Added in:</strong> Available in all versions of Impala. |
| </p> |
| |
| |
| <p class="p"> |
| <strong class="ph b">Column statistics considerations:</strong> Because this type has a fixed size, the maximum |
| and average size fields are always filled in for column statistics, even before you run |
| the <code class="ph codeph">COMPUTE STATS</code> statement. |
| </p> |
| |
| |
| |
| |
| <p class="p"> |
| <strong class="ph b">Related information:</strong> |
| </p> |
| |
| |
| <p class="p"> |
| <a class="xref" href="impala_literals.html#numeric_literals">Numeric Literals</a>, <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_decimal.html#decimal">DECIMAL Data Type (Impala 3.0 or higher only)</a>, |
| <a class="xref" href="impala_math_functions.html#math_functions">Impala Mathematical Functions</a> |
| </p> |
| |
| </div> |
| |
| <div class="related-links"> |
| <div class="familylinks"> |
| <div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/impala_datatypes.html">Data Types</a></div> |
| </div> |
| </div></body> |
| </html> |