public class ConvertModifier extends FunctionModifier
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:
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 addedaddSourceConversion(FunctionModifier, int...)
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.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 neededModifier and Type | Class and Description |
---|---|
static class |
ConvertModifier.FormatModifier |
Constructor and Description |
---|
ConvertModifier() |
Modifier and Type | Method and Description |
---|---|
void |
addConvert(int sourceType,
int targetType,
FunctionModifier convert) |
void |
addNumericBooleanConversions() |
void |
addSourceConversion(FunctionModifier convert,
int... sourceType) |
void |
addTypeConversion(FunctionModifier convert,
int... targetType) |
void |
addTypeMapping(String nativeType,
int... targetType) |
static Function |
createConvertFunction(LanguageFactory langFactory,
Expression expr,
String typeName) |
boolean |
hasTypeMapping(int type) |
void |
setBooleanNullable(boolean booleanNullable) |
void |
setWideningNumericImplicit(boolean wideningNumericImplicit) |
List<?> |
translate(Function function)
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. |
getCode
public void addTypeConversion(FunctionModifier convert, int... targetType)
public void addSourceConversion(FunctionModifier convert, int... sourceType)
public void addTypeMapping(String nativeType, int... targetType)
public void setWideningNumericImplicit(boolean wideningNumericImplicit)
public void addConvert(int sourceType, int targetType, FunctionModifier convert)
public List<?> translate(Function function)
FunctionModifier
LanguageObject
s and Objects), or null
if this FunctionModifier wishes to rely on the default translation of the
conversion visitor.translate
in class FunctionModifier
function
- IFunction to be translatedpublic static Function createConvertFunction(LanguageFactory langFactory, Expression expr, String typeName)
public void addNumericBooleanConversions()
public void setBooleanNullable(boolean booleanNullable)
public boolean hasTypeMapping(int type)
Copyright © 2017 JBoss by Red Hat. All rights reserved.