[
https://issues.apache.org/jira/browse/TRAFODION-2060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15334308#comment-15334308
]
ASF GitHub Bot commented on TRAFODION-2060:
-------------------------------------------
Github user anoopsharma00 commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/545#discussion_r67392794
--- Diff: core/sql/common/NumericType.h ---
@@ -445,6 +443,99 @@ class SQLBPInt : public NumericType
// ***********************************************************************
//
+// SQLTiny : SQL TINY
+//
+// ***********************************************************************
+class SQLTiny : public NumericType
+{
+public:
+ // ---------------------------------------------------------------------
+ // Constructor functions
+ // ---------------------------------------------------------------------
+ SQLTiny (NABoolean allowNegValues = TRUE,
+ NABoolean allowSQLnull = TRUE,
+ CollHeap * heap =0);
+
+ short getFSDatatype() const
+ {
+ if (isUnsigned())
+ return REC_BIN8_UNSIGNED;
+ else
+ return REC_BIN8_SIGNED;
+ }
+
+ NABoolean roundTripConversionToDouble() const { return TRUE; };
+
+ virtual Lng32 getMagnitude() const { return isUnsigned() ? 28 : 25; }
--- End diff --
Magnitude is the number of digits to the left of decimal point.
NUMERIC(5,2) as magnitude of 3.
It is used during expression set up to correctly determine what an
expression result should be.
Datatypes with binary precision and no scale (int, smallint, etc) do not
have exact
precision. Tinyint has precision of 3 digits (max val
255 for unsigned or 127 for signed).
The getMagnitude method returns an approx magnitude that
is used during expression set up. 28 means magnitude between 2 and 3
(multiplied by 10). Unsigned magnitude is larger value than signed
magnitude.
> Add support for native tinyint datatype
> ---------------------------------------
>
> Key: TRAFODION-2060
> URL: https://issues.apache.org/jira/browse/TRAFODION-2060
> Project: Apache Trafodion
> Issue Type: Improvement
> Reporter: Anoop Sharma
> Assignee: Anoop Sharma
> Priority: Minor
>
> Currently, tinyint datatype(1 byte integer) in trafodion is automatically
> converted to smallint (2 byte integer) and treated like smallint.
> It causes values that are beyond the tinyint range to be inserted
> and selected.
> Same issue happens with hive tinyint datatypes which are also
> treated as smallint. That causes inconsistent behavior when that
> datatype is accessed or inserted from hive vs. trafodion.
> This jira is to add support for true tinyint datatype in table definitions,
> cast stmts, param typing and handling of hive tables.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)