Search in sources :

Example 11 with FunctionModifier

use of org.teiid.translator.jdbc.FunctionModifier in project teiid by teiid.

the class SAPIQExecutionFactory method start.

public void start() throws TranslatorException {
    super.start();
    registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()) {

        @Override
        public List<?> translate(Function function) {
            // $NON-NLS-1$
            function.setName("||");
            return super.translate(function);
        }
    });
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CONCAT2, new AliasModifier("STRING"));
    registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
    // $NON-NLS-1$ //$NON-NLS-2$
    registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new TemplateFunctionModifier("DATEPART(dy,", 0, ")"));
    registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new AddDiffModifier(true, this.getLanguageFactory()).supportsQuarter(true));
    registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new AddDiffModifier(false, this.getLanguageFactory()).supportsQuarter(true));
    registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier(SourceSystemFunctions.COALESCE));
    registerFunctionModifier(SourceSystemFunctions.LOCATE, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            List<Expression> params = function.getParameters();
            Expression param1 = params.get(0);
            Expression param2 = params.set(1, param1);
            params.set(0, param2);
            return null;
        }
    });
    // add in type conversion
    ConvertModifier convertModifier = new ConvertModifier();
    convertModifier.setBooleanNullable(booleanNullable());
    convertModifier.addNumericBooleanConversions();
    // boolean isn't treated as bit, since it doesn't support null
    // byte is treated as smallint, since tinyint is unsigned
    // $NON-NLS-1$
    convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("bigint", FunctionModifier.LONG);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("int", FunctionModifier.INTEGER);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("double", FunctionModifier.DOUBLE);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("real", FunctionModifier.FLOAT);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("numeric(38, 0)", FunctionModifier.BIGINTEGER);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("numeric(38, 19)", FunctionModifier.BIGDECIMAL);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("varbinary", FunctionModifier.VARBINARY);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("date", FunctionModifier.DATE);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("time", FunctionModifier.TIME);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP);
    convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            return convertTimeToString(function);
        }
    });
    convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            return convertDateToString(function);
        }
    });
    convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            return convertTimestampToString(function);
        }
    });
    registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
}
Also used : Function(org.teiid.language.Function) TemplateFunctionModifier(org.teiid.translator.jdbc.TemplateFunctionModifier) Expression(org.teiid.language.Expression) TemplateFunctionModifier(org.teiid.translator.jdbc.TemplateFunctionModifier) ConcatFunctionModifier(org.teiid.translator.jdbc.oracle.ConcatFunctionModifier) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) AliasModifier(org.teiid.translator.jdbc.AliasModifier) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) EscapeSyntaxModifier(org.teiid.translator.jdbc.EscapeSyntaxModifier) ConcatFunctionModifier(org.teiid.translator.jdbc.oracle.ConcatFunctionModifier) AddDiffModifier(org.teiid.translator.jdbc.hsql.AddDiffModifier) ConvertModifier(org.teiid.translator.jdbc.ConvertModifier)

Example 12 with FunctionModifier

use of org.teiid.translator.jdbc.FunctionModifier in project teiid by teiid.

the class SQLServerExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    registerFunctionModifier(SourceSystemFunctions.WEEK, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            // $NON-NLS-1$ //$NON-NLS-2$
            return Arrays.asList("DATEPART(ISO_WEEK, ", function.getParameters().get(0), ")");
        }
    });
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LOCATE, new AliasModifier("CHARINDEX"));
    // $NON-NLS-1$ //$NON-NLS-2$
    registerFunctionModifier(SourceSystemFunctions.MD5, new TemplateFunctionModifier("HASHBYTES('MD5', ", 0, ")"));
    // $NON-NLS-1$ //$NON-NLS-2$
    registerFunctionModifier(SourceSystemFunctions.SHA1, new TemplateFunctionModifier("HASHBYTES('SHA1', ", 0, ")"));
    // $NON-NLS-1$ //$NON-NLS-2$
    registerFunctionModifier(SourceSystemFunctions.SHA2_256, new TemplateFunctionModifier("HASHBYTES('SHA2_256', ", 0, ")"));
    // $NON-NLS-1$ //$NON-NLS-2$
    registerFunctionModifier(SourceSystemFunctions.SHA2_512, new TemplateFunctionModifier("HASHBYTES('SHA2_512', ", 0, ")"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.UCASE, new UpperLowerFunctionModifier("upper"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LCASE, new UpperLowerFunctionModifier("lower"));
}
Also used : TemplateFunctionModifier(org.teiid.translator.jdbc.TemplateFunctionModifier) TemplateFunctionModifier(org.teiid.translator.jdbc.TemplateFunctionModifier) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) AliasModifier(org.teiid.translator.jdbc.AliasModifier) ArrayList(java.util.ArrayList) List(java.util.List)

Example 13 with FunctionModifier

use of org.teiid.translator.jdbc.FunctionModifier in project teiid by teiid.

the class SQLServerExecutionFactory method initCapabilities.

@Override
public void initCapabilities(Connection connection) throws TranslatorException {
    super.initCapabilities(connection);
    if (getVersion().compareTo(TEN_0) >= 0) {
        // date support
        // $NON-NLS-1$
        convertModifier.addTypeMapping("date", FunctionModifier.DATE);
        // $NON-NLS-1$ //$NON-NLS-2$
        formatMap.put("yyyy-MM-dd", "DATE");
        convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {

            @Override
            public List<?> translate(Function function) {
                List<Object> result = new ArrayList<Object>();
                // $NON-NLS-1$
                result.add("cast(");
                result.add(function.getParameters().get(0));
                // $NON-NLS-1$
                result.add(" AS DATE)");
                return result;
            }
        });
        // timestamp/datetime2
        // $NON-NLS-1$
        convertModifier.addTypeMapping("datetime2", FunctionModifier.TIMESTAMP);
        // $NON-NLS-1$
        registerFunctionModifier(SourceSystemFunctions.PARSETIMESTAMP, new SybaseFormatFunctionModifier("CONVERT(DATETIME2, ", formatMap));
    }
}
Also used : TemplateFunctionModifier(org.teiid.translator.jdbc.TemplateFunctionModifier) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) ArrayList(java.util.ArrayList) List(java.util.List)

Example 14 with FunctionModifier

use of org.teiid.translator.jdbc.FunctionModifier in project teiid by teiid.

the class MySQLExecutionFactory method start.

@Override
public void start() throws TranslatorException {
    super.start();
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITAND, new BitFunctionModifier("&", getLanguageFactory()));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITNOT, new BitFunctionModifier("~", getLanguageFactory()));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITOR, new BitFunctionModifier("|", getLanguageFactory()));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITXOR, new BitFunctionModifier("^", getLanguageFactory()));
    registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
    registerFunctionModifier(SourceSystemFunctions.LPAD, new PadFunctionModifier());
    registerFunctionModifier(SourceSystemFunctions.RPAD, new PadFunctionModifier());
    // WEEKINYEAR assumes 4.1.1
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.WEEK, new AliasModifier("WEEKOFYEAR"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.ST_ASBINARY, new AliasModifier("AsWKB"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.ST_ASTEXT, new AliasModifier("AsWKT"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.ST_GEOMFROMWKB, new AliasModifier("GeomFromWKB"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.ST_GEOMFROMTEXT, new AliasModifier("GeomFromText"));
    // add in type conversion
    ConvertModifier convertModifier = new ConvertModifier();
    // $NON-NLS-1$
    convertModifier.addTypeMapping("signed", FunctionModifier.BOOLEAN, FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG);
    // char(n) assume 4.1 or later
    // $NON-NLS-1$
    convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("char", FunctionModifier.STRING);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("date", FunctionModifier.DATE);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("time", FunctionModifier.TIME);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("datetime", FunctionModifier.TIMESTAMP);
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("DATE"));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("TIME"));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("TIMESTAMP"));
    // $NON-NLS-1$ //$NON-NLS-2$
    convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d"));
    // $NON-NLS-1$ //$NON-NLS-2$
    convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%H:%i:%S"));
    // $NON-NLS-1$ //$NON-NLS-2$
    convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d %H:%i:%S.%f"));
    convertModifier.addTypeConversion(new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            // $NON-NLS-1$ //$NON-NLS-2$
            return Arrays.asList("(", function.getParameters().get(0), " + 0.0)");
        }
    }, FunctionModifier.BIGDECIMAL, FunctionModifier.BIGINTEGER, FunctionModifier.FLOAT, FunctionModifier.DOUBLE);
    convertModifier.addNumericBooleanConversions();
    convertModifier.setWideningNumericImplicit(true);
    registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
    // $NON-NLS-1$ //$NON-NLS-2$
    addPushDownFunction("mysql", "SUBSTRING_INDEX", TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.STRING, TypeFacility.RUNTIME_NAMES.INTEGER);
}
Also used : LocateFunctionModifier(org.teiid.translator.jdbc.LocateFunctionModifier) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) LocateFunctionModifier(org.teiid.translator.jdbc.LocateFunctionModifier) AliasModifier(org.teiid.translator.jdbc.AliasModifier) ArrayList(java.util.ArrayList) List(java.util.List) ConvertModifier(org.teiid.translator.jdbc.ConvertModifier)

Example 15 with FunctionModifier

use of org.teiid.translator.jdbc.FunctionModifier in project teiid by teiid.

the class NetezzaExecutionFactory method start.

public void start() throws TranslatorException {
    super.start();
    // STRING FUNCTION MODIFIERS
    // //////////////////////////////////
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), "INSTR", true));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("||"));
    // /NUMERIC FUNCTION MODIFIERS
    // //////////////////////////////////
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.POWER, new AliasModifier("pow"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN"));
    // /BIT FUNCTION MODIFIERS
    // //////////////////////////////////
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("int4and"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("int4not"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("int4or"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("int4xor"));
    // DATE FUNCTION MODIFIERS
    // ////////////////////////////////////////
    registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ExtractModifier("DOY"));
    registerFunctionModifier(SourceSystemFunctions.QUARTER, new ExtractFunctionModifier());
    registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier());
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY"));
    registerFunctionModifier(SourceSystemFunctions.WEEK, new ExtractFunctionModifier());
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ExtractModifier("DOW"));
    registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
    registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier());
    registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier());
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE"));
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME"));
    // SYSTEM FUNCTIONS
    // //////////////////////////////////
    // $NON-NLS-1$
    registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("NVL"));
    // DATA TYPE CONVERSION
    // /////////////////////////////////////////
    ConvertModifier convertModifier = new ConvertModifier();
    // $NON-NLS-1$
    convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("byteint", FunctionModifier.BYTE);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("smallint", FunctionModifier.SHORT);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("bigint", FunctionModifier.LONG);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("numeric(38)", FunctionModifier.BIGINTEGER);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("numeric(38,18)", FunctionModifier.BIGDECIMAL);
    // $NON-NLS-1$
    convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING);
    // convertModifier.addTypeMapping("nvarchar(5)", FunctionModifier.BOOLEAN);
    // /NO BOOLEAN, INTEGER, FLOAT, DATE, TIME, TIMESTAMP, as they are directly available in netezza
    // /NO NULL, CLOB, BLOB, OBJECT, XML
    // /BOOLEAN--BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, BIGINTEGER, BIGDECIMAL--AS IT DOESN'T WORK IMPLICITLY IN NETEZZA
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.INTEGER, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.BYTE, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.SHORT, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.LONG, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.FLOAT, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.DOUBLE, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.BIGINTEGER, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.BIGDECIMAL, new BooleanToNumericConversionModifier());
    convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new BooleanToStringConversionModifier());
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.BOOLEAN, new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            Expression stringValue = function.getParameters().get(0);
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            return Arrays.asList("CASE WHEN ", stringValue, " IN ('false', '0') THEN '0' WHEN ", stringValue, " IS NOT NULL THEN '1' END");
        }
    });
    convertModifier.addTypeConversion(new FunctionModifier() {

        @Override
        public List<?> translate(Function function) {
            Expression stringValue = function.getParameters().get(0);
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            return Arrays.asList("CASE WHEN ", stringValue, " = 0 THEN '0' WHEN ", stringValue, " IS NOT NULL THEN '1' END");
        }
    }, FunctionModifier.BOOLEAN);
    // //////STRING TO DATATYPE CONVERSION OTHER THAN DATE/TIME
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer"));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float"));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double"));
    // /// STRING --> CHAR, BYTE, SHORT, LONG, BIGI, BIGD, BOOLEAN is taken care by Type Mapping
    // /// NO conversion support for NULL, CLOB, BLOB, OBJECT, XML
    // //STRING TO DATE/TIME CONVERSION////
    // ////////////////////////////////////
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("to_date", DATE_FORMAT));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("to_timestamp", TIME_FORMAT));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("to_timestamp", TIMESTAMP_FORMAT));
    // ////DATE/TIME INTERNAL CONVERSION/////////
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME"));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE"));
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP"));
    // convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //TIME --> TIMESTAMP --DOESN't WORK IN NETEZZA-NO FUNCTION SUPPORT
    // //DATE/TIME to STRING CONVERION////
    // ///////////////////////////////////
    // $NON-NLS-1$
    convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", TIMESTAMP_FORMAT));
    // /NO NETEZAA FUNCTION for DATE, TIME to STRING
    convertModifier.setWideningNumericImplicit(true);
    registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
    if (sqlExtensionsInstalled) {
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_extract", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_extract", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_extract", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_extract_all", RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_extract_all", RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_extract_all", RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_extract_all_sp", RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_extract_all_sp", RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_extract_all_sp", RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_extract_sp", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_extract_sp", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_instr", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_instr", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_instr", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_like", RUNTIME_NAMES.BOOLEAN, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_like", RUNTIME_NAMES.BOOLEAN, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_like", RUNTIME_NAMES.BOOLEAN, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_match_count", RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_match_count", RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_match_count", RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_replace", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_replace", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$
        addPushDownFunction("netezza", "regexp_replace", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_replace_sp", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING + "[]");
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_replace_sp", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.INTEGER);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        addPushDownFunction("netezza", "regexp_replace_sp", RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING, RUNTIME_NAMES.STRING + "[]", RUNTIME_NAMES.INTEGER, RUNTIME_NAMES.STRING);
    }
}
Also used : LocateFunctionModifier(org.teiid.translator.jdbc.LocateFunctionModifier) ExtractFunctionModifier(org.teiid.translator.jdbc.ExtractFunctionModifier) ConvertModifier(org.teiid.translator.jdbc.ConvertModifier) Function(org.teiid.language.Function) Expression(org.teiid.language.Expression) LocateFunctionModifier(org.teiid.translator.jdbc.LocateFunctionModifier) FunctionModifier(org.teiid.translator.jdbc.FunctionModifier) ExtractFunctionModifier(org.teiid.translator.jdbc.ExtractFunctionModifier) AliasModifier(org.teiid.translator.jdbc.AliasModifier) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FunctionModifier (org.teiid.translator.jdbc.FunctionModifier)20 ArrayList (java.util.ArrayList)19 List (java.util.List)19 AliasModifier (org.teiid.translator.jdbc.AliasModifier)17 Function (org.teiid.language.Function)12 ConvertModifier (org.teiid.translator.jdbc.ConvertModifier)6 ModFunctionModifier (org.teiid.translator.jdbc.ModFunctionModifier)5 Expression (org.teiid.language.Expression)4 EscapeSyntaxModifier (org.teiid.translator.jdbc.EscapeSyntaxModifier)4 LocateFunctionModifier (org.teiid.translator.jdbc.LocateFunctionModifier)4 TemplateFunctionModifier (org.teiid.translator.jdbc.TemplateFunctionModifier)4 LinkedList (java.util.LinkedList)3 Literal (org.teiid.language.Literal)3 ConcatFunctionModifier (org.teiid.translator.jdbc.oracle.ConcatFunctionModifier)3 QueryExpression (org.teiid.language.QueryExpression)2 FunctionMethod (org.teiid.metadata.FunctionMethod)2 ExtractFunctionModifier (org.teiid.translator.jdbc.ExtractFunctionModifier)2 ParseFormatFunctionModifier (org.teiid.translator.jdbc.ParseFormatFunctionModifier)2 BasicDBList (com.mongodb.BasicDBList)1 AggregateFunction (org.teiid.language.AggregateFunction)1