JBoss.orgCommunity Documentation

Chapter 5. Datatypes

5.1. Supported Types
5.2. Type Conversions
5.3. Special Conversion Cases
5.3.1. Conversion of String Literals
5.3.2. Converting to Boolean
5.3.3. Date/Time/Timestamp Type Conversions
5.4. Escaped Literal Syntax

Teiid supports a core set of runtime types. Runtime types can be different than semantic types defined in type fields at design time. The runtime type can also be specified at design time or it will be automatically chosen as the closest base type to the semantic type.

Table 5.1. Teiid Runtime Types

TypeDescriptionJava Runtime ClassJDBC TypeODBC Type
string or varcharvariable length character string with a maximum length of 4000. Note that the length cannot be explicitly set with the type literal, e.g. varchar(100).java.lang.StringVARCHARVARCHAR
chara single Unicode characterjava.lang.CharacterCHARCHAR
booleana single bit, or Boolean, that can be true, false, or null (unknown) java.lang.BooleanBITSMALLINT
byte or tinyintnumeric, integral type, signed 8-bitjava.lang.ByteTINYINTSMALLINT
short or smallintnumeric, integral type, signed 16-bitjava.lang.ShortSMALLINTSMALLINT
integer or serialnumeric, integral type, signed 32-bit. The serial type also implies not null and has an auto-incrementing value that starts at 1. serial types are not automatically UNIQUE.java.lang.IntegerINTEGERINTEGER
long or bigintnumeric, integral type, signed 64-bitjava.lang.LongBIGINTNUMERIC
bigintegernumeric, integral type, arbitrary precision of up to 1000 digitsjava.lang.BigIntegerNUMERICNUMERIC
float or realnumeric, floating point type, 32-bit IEEE 754 floating-point numbersjava.lang.FloatREALFLOAT
doublenumeric, floating point type, 64-bit IEEE 754 floating-point numbersjava.lang.StringDOUBLEDOUBLE
bigdecimal or decimalnumeric, floating point type, arbitrary precision of up to 1000 digits. Note that the precision and scale cannot be explicitly set with the type literal, e.g. decimal(38, 2).java.math.BigDecimalNUMERICNUMERIC
datedatetime, representing a single day (year, month, day)java.sql.DateDATEDATE
timedatetime, representing a single time (hours, minutes, seconds, milliseconds)java.sql.TimeTIMETIME
timestampdatetime, representing a single date and time (year, month, day, hours, minutes, seconds, milliseconds, nanoseconds)java.sql.TimestampTIMESTAMPTIMESTAMP
objectany arbitrary Java object, must implement java.lang.SerializableAnyJAVA_OBJECTVARCHAR
blobbinary large object, representing a stream of bytes java.sql.Blob [a] BLOBVARCHAR
clobcharacter large object, representing a stream of characters java.sql.Clob [b] CLOBVARCHAR
xmlXML document java.sql.SQLXML [c] JAVA_OBJECTVARCHAR

[a] The concrete type is expected to be org.teiid.core.types.BlobType

[b] The concrete type is expected to be org.teiid.core.types.ClobType

[c] The concrete type is expected to be org.teiid.core.types.XMLType


Data types may be converted from one form to another either explicitly or implicitly. Implicit conversions automatically occur in criteria and expressions to ease development. Explicit datatype conversions require the use of the CONVERT function or CAST keyword.


Teiid can automatically convert literal strings and numeric type values to Boolean values as follows:

TypeLiteral ValueBoolean Value
String'false'false
'unknown'null
othertrue
Numeric0false
othertrue

Rather than relying on implicit conversion, datatype values may be expressed directly in SQL using escape syntax to define the type. Note that the supplied string value must match the expected format exactly or an exception will occur.