JBoss.orgCommunity Documentation

Chapter 3. Datatypes

3.1. Supported Types
3.2. Type Conversions
3.3. Special Conversion Cases
3.3.1. Conversion of String Literals
3.3.2. Converting to Boolean
3.3.3. Date/Time/Timestamp Type Conversions
3.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 3.1. Teiid Runtime Types

TypeDescriptionJava Runtime ClassJDBC TypeODBC Type
stringvariable length character string with a maximum length of 4000java.lang.StringVARCHARVARCHAR
chara single Unicode characterjava.lang.CharacterCHARCHAR
booleana single bit, or Boolean, with two possible values java.lang.BooleanBITSMALLINT
bytenumeric, integral type, signed 8-bitjava.lang.ByteTINYINTSMALLINT
shortnumeric, integral type, signed 16-bitjava.lang.ShortSMALLINTSMALLINT
integernumeric, integral type, signed 32-bitjava.lang.IntegerINTEGERINTEGER
longnumeric, integral type, signed 64-bitjava.lang.LongBIGINTNUMERIC
bigintegernumeric, integral type, arbitrary precision of up to 1000 digitsjava.lang.BigIntegerNUMERICNUMERIC
floatnumeric, 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
bigdecimalnumeric, floating point type, arbitrary precision of up to 1000 digitsjava.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 com.metamatrix.common.types.BlobType

[b] The concrete type is expected to be com.metamatrix.common.types.ClobType

[c] The concrete type is expected to be com.metamatrix.common.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'true'true
'false'false
otherfalse
Numeric1true
0false
other error

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.