blob: 10c81b9d74d7f0140186fc9454fd8aa732467eb0 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="bigint">
<title>BIGINT Data Type</title>
<titlealts audience="PDF"><navtitle>BIGINT</navtitle></titlealts>
<prolog>
<metadata>
<data name="Category" value="Impala"/>
<data name="Category" value="Impala Data Types"/>
<data name="Category" value="SQL"/>
<data name="Category" value="Data Analysts"/>
<data name="Category" value="Developers"/>
<data name="Category" value="Schemas"/>
</metadata>
</prolog>
<conbody>
<p>
An 8-byte integer data type used in <codeph>CREATE TABLE</codeph> and <codeph>ALTER TABLE</codeph>
statements.
</p>
<p conref="../shared/impala_common.xml#common/syntax_blurb"/>
<p>
In the column definition of a <codeph>CREATE TABLE</codeph> statement:
</p>
<codeblock><varname>column_name</varname> BIGINT</codeblock>
<p>
<b>Range:</b> -9223372036854775808 .. 9223372036854775807. There is no <codeph>UNSIGNED</codeph> subtype.
</p>
<p>
<b>Conversions:</b> Impala automatically converts to a floating-point type
(<codeph>FLOAT</codeph> or <codeph>DOUBLE</codeph>) automatically. Use
<codeph>CAST()</codeph> to convert to <codeph>TINYINT</codeph>,
<codeph>SMALLINT</codeph>, <codeph>INT</codeph>,
<codeph>STRING</codeph>, or <codeph>TIMESTAMP</codeph>. <ph
conref="../shared/impala_common.xml#common/cast_int_to_timestamp"/>
</p>
<p conref="../shared/impala_common.xml#common/example_blurb"/>
<codeblock>CREATE TABLE t1 (x BIGINT);
SELECT CAST(1000 AS BIGINT);
</codeblock>
<p conref="../shared/impala_common.xml#common/usage_notes_blurb"/>
<p>
<codeph>BIGINT</codeph> is a convenient type to use for column declarations because you can use any kind of
integer values in <codeph>INSERT</codeph> statements and they are promoted to <codeph>BIGINT</codeph> where
necessary. However, <codeph>BIGINT</codeph> also requires the most bytes of any integer type on disk and in
memory, meaning your queries are not as efficient and scalable as possible if you overuse this type.
Therefore, prefer to use the smallest integer type with sufficient range to hold all input values, and
<codeph>CAST()</codeph> when necessary to the appropriate type.
</p>
<p>
For a convenient and automated way to check the bounds of the <codeph>BIGINT</codeph> type, call the
functions <codeph>MIN_BIGINT()</codeph> and <codeph>MAX_BIGINT()</codeph>.
</p>
<p>
If an integer value is too large to be represented as a <codeph>BIGINT</codeph>, use a
<codeph>DECIMAL</codeph> instead with sufficient digits of precision.
</p>
<p conref="../shared/impala_common.xml#common/null_bad_numeric_cast"/>
<p conref="../shared/impala_common.xml#common/partitioning_good"/>
<p conref="../shared/impala_common.xml#common/hbase_ok"/>
<!-- <p conref="../shared/impala_common.xml#common/parquet_blurb"/> -->
<p conref="../shared/impala_common.xml#common/text_bulky"/>
<!-- <p conref="../shared/impala_common.xml#common/compatibility_blurb"/> -->
<p conref="../shared/impala_common.xml#common/internals_8_bytes"/>
<p conref="../shared/impala_common.xml#common/added_forever"/>
<p conref="../shared/impala_common.xml#common/column_stats_constant"/>
<p conref="../shared/impala_common.xml#common/sqoop_blurb" audience="hidden"/>
<p conref="../shared/impala_common.xml#common/sqoop_timestamp_caveat"
audience="hidden"/>
<p conref="../shared/impala_common.xml#common/related_info"/>
<p>
<xref href="impala_literals.xml#numeric_literals"/>, <xref href="impala_tinyint.xml#tinyint"/>,
<xref href="impala_smallint.xml#smallint"/>, <xref href="impala_int.xml#int"/>,
<xref href="impala_bigint.xml#bigint"/>, <xref href="impala_decimal.xml#decimal"/>,
<xref href="impala_math_functions.xml#math_functions"/>
</p>
</conbody>
</concept>