org.teiid.translator.jdbc
Class ConvertModifier
java.lang.Object
org.teiid.translator.jdbc.FunctionModifier
org.teiid.translator.jdbc.ConvertModifier
public class ConvertModifier
- extends FunctionModifier
Base class for handling the convert function.
Convert is by far the most complicated pushdown function since it actually
represents a matrix of possible functions. Additionally not every source supports
the same semantics as our conversions.
Each instance of this class makes a best effort at handling converts for for a
given source - compensating for differing string representation, the lack a time type
etc.
The choice of conversion logic is as follows:
- Provide specific conversion between the source and target -
addConvert(int, int, FunctionModifier)
mostly one do not need to provide any conversion if the default is cast(srcType AS targetType), however if the source
database requires different specific format for example to cast(srctype, targetType FORMAT 'more-info') this conversion needs to be added
- Filter common implicit conversions
- Look for a general source conversion -
addSourceConversion(FunctionModifier, int...)
- Look for a general target conversion -
addTypeConversion(FunctionModifier, int...)
. If the source
database provides a specific function for converting *any* source datatype to this target datatype then use this to define it.
Like in oracle "to_char" function will convert any other data type to string. Use this to define those kind of conversions
convert any data type to string. so you can use this for purpose.
- Type maps from database data type to Teiid runtime types. -
addTypeMapping(String, int...)
define mappings for every datatype available in database. The cast operation will replace the target type (teiid type) with the given
native type in the cast operation generated. Do not need to really look at implicit/explicit conversions that are
supported by the source database, because when a cast is defined on the sql it is up to the source database to apply it
as implicit or explicit operation. Teiid generates cast always when needed
- Drop the conversion
Fields inherited from class org.teiid.translator.jdbc.FunctionModifier |
BIGDECIMAL, BIGINTEGER, BLOB, BOOLEAN, BYTE, CHAR, CLOB, DATE, DOUBLE, FLOAT, INTEGER, LONG, NULL, OBJECT, SHORT, STRING, TIME, TIMESTAMP, XML |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConvertModifier
public ConvertModifier()
addTypeConversion
public void addTypeConversion(FunctionModifier convert,
int... targetType)
addSourceConversion
public void addSourceConversion(FunctionModifier convert,
int... sourceType)
addTypeMapping
public void addTypeMapping(String nativeType,
int... targetType)
setWideningNumericImplicit
public void setWideningNumericImplicit(boolean wideningNumericImplicit)
addConvert
public void addConvert(int sourceType,
int targetType,
FunctionModifier convert)
translate
public List<?> translate(Function function)
- Description copied from class:
FunctionModifier
- Return a List of translated parts (
LanguageObject
s and Objects), or null
if this FunctionModifier wishes to rely on the default translation of the
conversion visitor.
- Specified by:
translate
in class FunctionModifier
- Parameters:
function
- IFunction to be translated
- Returns:
- List of translated parts, or null
createConvertFunction
public static Function createConvertFunction(LanguageFactory langFactory,
Expression expr,
String typeName)
addNumericBooleanConversions
public void addNumericBooleanConversions()
setBooleanNullable
public void setBooleanNullable(boolean booleanNullable)
Copyright © 2011. All Rights Reserved.