blob: 5f4704b58e5fe89aa6e8f24961b1ff9dd4e37da0 [file]
<?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="INT 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="int" />
<link rel="stylesheet" type="text/css" href="../commonltr.css" />
<title>INT Data Type</title>
</head>
<body id="int">
<h1 class="title topictitle1" id="ariaid-title1">INT Data Type</h1>
<div class="body conbody">
<p class="p">
A 4-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> INT</code></pre>
<p class="p">
<strong class="ph b">Range:</strong> -2147483648 .. 2147483647. 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">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">TINYINT</code>, <code class="ph codeph">SMALLINT</code>,
<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">
<strong class="ph b">Usage notes:</strong>
</p>
<p class="p">
The data type <code class="ph codeph">INTEGER</code> is an alias for <code class="ph codeph">INT</code>.
</p>
<p class="p">
For a convenient and automated way to check the bounds of the <code class="ph codeph">INT</code> type, call the functions
<code class="ph codeph">MIN_INT()</code> and <code class="ph codeph">MAX_INT()</code>.
</p>
<p class="p">
If an integer value is too large to be represented as a <code class="ph codeph">INT</code>, use a <code class="ph codeph">BIGINT</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 INT);
SELECT CAST(1000 AS INT);
</code></pre>
<p class="p">
<strong class="ph b">Partitioning:</strong> Prefer to use this type for a partition key column. Impala can
process the numeric type more efficiently than a <code class="ph codeph">STRING</code> representation
of the value.
</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">Parquet considerations:</strong>
</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 4-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>