teiid SVN: r3480 - in branches/7.1.x/connectors/sandbox: translator-teradata and 3 other directories.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 19:19:22 -0400 (Tue, 13 Sep 2011)
New Revision: 3480
Added:
branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
Modified:
branches/7.1.x/connectors/sandbox/pom.xml
Log:
SOA-3103
Modified: branches/7.1.x/connectors/sandbox/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:59:58 UTC (rev 3479)
+++ branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 23:19:22 UTC (rev 3480)
@@ -13,5 +13,6 @@
<description>Experimental connectors in progress</description>
<modules>
<module>translator-yahoo</module>
+ <module>translator-teradata</module>
</modules>
</project>
Added: branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml 2011-09-13 23:19:22 UTC (rev 3480)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>sandbox</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <version>7.1.1.GA</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>translator-teradata</artifactId>
+ <groupId>org.jboss.teiid.connectors.sandbox</groupId>
+ <name>Teradata Translator</name>
+ <description>Teradata Translator</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+</project>
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 23:19:22 UTC (rev 3480)
@@ -0,0 +1,472 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.jdbc.teradata;
+
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+
+
+/**
+ * Teradata database Release 12
+ */
+@Translator(name="teradata", description="A translator for Teradata Database")
+public class TeradataExecutionFactory extends JDBCExecutionFactory {
+
+ public static String TERADATA = "teradata"; //$NON-NLS-1$
+ protected ConvertModifier convert = new ConvertModifier();
+
+ public TeradataExecutionFactory() {
+ setSupportsOuterJoins(false);
+ }
+
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ convert.addTypeMapping("byteint", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("numeric(18,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGDECIMAL, new CastModifier("decimal(37,5)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGINTEGER, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BOOLEAN, new CastModifier("byteint"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.LONG, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.SHORT, new CastModifier("smallint"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double precision"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BYTE, new CastModifier("byteint")); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'Y4-MM-DDBHH:MI:SSDS(6)') AS VARCHAR(26))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'HH:MI:SS') AS VARCHAR(9))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'YYYY-MM-DD') AS VARCHAR(11))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+
+ convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addNumericBooleanConversions();
+
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstrModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new StringOnlyModifier("LOWER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new StringOnlyModifier("UPPER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractModifier("YEAR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractModifier("MONTH")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractModifier("HOUR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractModifier("MINUTE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractModifier("SECOND")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ function.setName(SourceSystemFunctions.TAN);
+ return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("TRIM(LEADING FROM ");//$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.RTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("TRIM(TRAILING FROM ");//$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.MOD, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$
+ }
+ });
+
+ /* Push down support only available from 7.4
+ addPushDownFunction(TERADATA, "COSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "TANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ACOSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ASINH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ATANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "CHAR2HEXINT", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "INDEX", INTEGER, STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "BYTES", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "OCTET_LENGTH", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBAKAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBUCKET", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHROW", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "NULLIFZERO", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ZEROIFNULL", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ */
+ }
+
+ @Override
+ public SQLConversionVisitor getSQLConversionVisitor() {
+ return new TeradataSQLConversionVisitor(this);
+ }
+
+
+ @Override
+ public List getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.COT);
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.NULLIF);
+ supportedFunctions.add(SourceSystemFunctions.RAND);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+
+ return supportedFunctions;
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "cast('" + formatDateValue(dateValue) + "' AS DATE FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "cast('" + formatDateValue(timeValue) + "' AS TIME(0) FORMAT 'hh:mi:ss')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "cast('" + formatDateValue(timestampValue) + "' AS TIMESTAMP(6))"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ // Teradata also supports MINUS & ALL set operators
+ // more aggregates available
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesEnhancedNumeric() {
+ return true;
+ }
+
+ /* only in 7.4
+ @Override
+ public boolean supportsCommonTableExpressions() {
+ return false;
+ }
+ */
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.FIRST;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
+ public static class LocateModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+
+ public LocateModifier(ConvertModifier convertModifier) {
+ this.convertModifier = convertModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ Expression expr1 = function.getParameters().get(0);
+ Expression expr2 = function.getParameters().get(1);
+ if (function.getParameters().size() > 2) {
+ Expression expr3 = function.getParameters().get(2);
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(expr3);
+ target.add("))"); //$NON-NLS-1$
+ }
+ else {
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ }
+ return target;
+ }
+ }
+
+ private static List<?> expressionToString(Expression expr, ConvertModifier modifier) {
+ Class tgtType = expr.getType();
+ if (tgtType.equals(String.class) && ((expr instanceof Literal) || expr instanceof ColumnReference)) {
+ return Arrays.asList(expr);
+ }
+ else if (tgtType.equals(String.class) && (expr instanceof Function)) {
+
+ Function func = (Function)expr;
+ while(true) {
+ Expression arg1 = func.getParameters().get(0);
+ if ((arg1 instanceof Function) && ((Function)arg1).getName().equals("convert")) { //$NON-NLS-1$
+ func = (Function)arg1;
+ }
+ else {
+ break;
+ }
+ }
+ Expression arg1 = func.getParameters().get(0);
+ if (arg1 instanceof ColumnReference) {
+ ColumnReference ref = (ColumnReference)func.getParameters().get(0);
+ if(Number.class.isAssignableFrom(ref.getType())) {
+ ArrayList target = new ArrayList();
+ target.add("cast("); //$NON-NLS-1$
+ target.add(func.getParameters().get(0));
+ target.add(" AS varchar(100))"); //$NON-NLS-1$
+ return target;
+ }
+ else if (String.class.isAssignableFrom(ref.getType())) {
+ return Arrays.asList(ref);
+ }
+ }
+ return modifier.translate(func);
+ }
+ return Arrays.asList("cast(" , expr, " AS varchar(100))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static class ExtractModifier extends FunctionModifier {
+ private String type;
+ public ExtractModifier(String type) {
+ this.type = type;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class CastModifier extends FunctionModifier {
+ private String target;
+ public CastModifier(String target) {
+ this.target = target;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(", function.getParameters().get(0), " AS "+this.target+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class StringOnlyModifier extends FunctionModifier {
+ String funcName;
+ ConvertModifier convertModifier;
+ public StringOnlyModifier(String name, ConvertModifier converModifier) {
+ this.funcName = name;
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add(this.funcName);
+ target.add("("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class SubstrModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+ public SubstrModifier(ConvertModifier converModifier) {
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(function.getParameters().get(1));
+ if (function.getParameters().size() > 2 ) {
+ target.add(","); //$NON-NLS-1$
+ target.add(function.getParameters().get(2));
+ }
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class LeftOrRightFunctionModifier extends FunctionModifier {
+ private LanguageFactory langFactory;
+ ConvertModifier convertModifier;
+
+ public LeftOrRightFunctionModifier(LanguageFactory langFactory, ConvertModifier converModifier) {
+ this.langFactory = langFactory;
+ this.convertModifier = converModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ List<Expression> args = function.getParameters();
+ ArrayList target = new ArrayList();
+ if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
+ //substr(string, 1, length)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER));
+ target.add(","); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add(")"); //$NON-NLS-1$
+ } else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
+ //substr(case_size, character_length(case_size) -4)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+
+ target.add(",(character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(")-"); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add("+1))"); //$NON-NLS-1$ // offset for 1 based index
+ }
+ return target;
+ }
+ }
+}
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-09-13 23:19:22 UTC (rev 3480)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import java.util.List;
+
+import org.teiid.language.AndOr;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.AndOr.Operator;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+public class TeradataSQLConversionVisitor extends SQLConversionVisitor {
+
+ public TeradataSQLConversionVisitor(TeradataExecutionFactory ef) {
+ super(ef);
+ }
+
+ @Override
+ public void visit(In obj) {
+ List<Expression> exprs = obj.getRightExpressions();
+
+ Class expectedType = obj.getLeftExpression().getType();
+
+ boolean decompose = false;
+ for (Expression expr:exprs) {
+ if (!(expr.getType().equals(expectedType)) || (!(expr.getType().isAssignableFrom(Number.class)) && !expr.getType().isAssignableFrom(String.class))) {
+ decompose = true;
+ }
+ }
+
+ if (decompose) {
+ Comparison.Operator opCode = obj.isNegated()?Comparison.Operator.NE:Comparison.Operator.EQ;
+ if (exprs.size() > 1) {
+ Condition left = LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0));
+ for (int i = 1; i < exprs.size(); i++) {
+ AndOr replace = LanguageFactory.INSTANCE.createAndOr(obj.isNegated()?Operator.AND:Operator.OR, left, LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(i)));
+ left = replace;
+ }
+ super.visit((AndOr)left);
+ }
+ else {
+ super.visit(LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0)));
+ }
+ }
+ else {
+ super.visit(obj);
+ }
+ }
+}
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml 2011-09-13 23:19:22 UTC (rev 3480)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- TERADATA -->
+ <bean name="translator-teradata-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-teradata" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-teradata" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.jdbc.teradata.TeradataExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-teradata</parameter>
+ <parameter class="java.lang.String">teradata</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-09-13 23:19:22 UTC (rev 3480)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+@SuppressWarnings("nls")
+public class TestTeradataTranslator {
+
+ private static TeradataExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new TeradataExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert",
+ Arrays.asList( srcExpression,LANG_FACTORY.createLiteral(tgtType, String.class)),TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
+ expectedExpression, helpGetString(func));
+ }
+
+ public String helpGetString(Expression expr) throws Exception {
+ SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ @Test public void testSubstring1() throws Exception {
+ String input = "SELECT dayofmonth(datevalue) FROM BQT1.SMALLA";
+ String output = "SELECT extract(DAY from SmallA.DateValue) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testTimestampToTime() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(111, 4, 5, 9, 16, 34, 220000000), Timestamp.class), "time", "cast(cast('2011-05-05 09:16:34.22' AS TIMESTAMP(6)) AS TIME)");
+ }
+
+ @Test public void testIntegerToString() throws Exception {
+ String input = "SELECT lcase(bigdecimalvalue) FROM BQT1.SMALLA";
+ String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(100))) FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testSubString() throws Exception {
+ String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1) = '1' ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1) = '1' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testSubString2() throws Exception {
+ String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1, 2) = '1' ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1,2) = '1' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testDateToString() throws Exception {
+ String input = "SELECT intkey, UPPER(timevalue) AS UPPER FROM BQT1.SmallA ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, UPPER(cast(cast(SmallA.TimeValue AS FORMAT 'HH:MI:SS') AS VARCHAR(9))) AS UPPER FROM SmallA ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate() throws Exception {
+ String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA WHERE LOCATE('-', BIGDECIMALVALUE) = 1 ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(100))) = 1 ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+
+ @Test public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ @Test public void testByte2ToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)-1), Byte.class), "string", "cast(-1 AS varchar(4000))");
+ }
+
+ @Test public void testDoubleToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class), "string", "cast(1.0 AS varchar(4000))");
+ }
+
+ @Test public void testStringToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("1.0", String.class), "double", "cast('1.0' AS double precision)");
+ }
+
+ @Test public void testInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2', '3')", helpGetString(expr));
+ }
+
+ @Test public void testSingleInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2')", helpGetString(expr));
+ }
+
+ @Test public void testInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func() OR '1' = '3'", helpGetString(expr));
+ }
+
+ @Test public void testNegatedInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, true);
+
+ assertEquals("'1' <> func() AND '1' <> '3'", helpGetString(expr));
+ }
+
+ @Test public void testsingleInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func()", helpGetString(expr));
+ }
+
+ /* only 7.4
+ @Test public void testNullComapreNull() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM bqt1.smalla WHERE NULL <> NULL";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.DoubleNum FROM SmallA WHERE 1 = 0";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+ @Test public void testPushDownFunction() throws Exception {
+ String input = "SELECT teradata.HASHBAKAMP(STRINGKEY) DOUBLENUM FROM bqt1.smalla";
+ String out = "SELECT HASHBAKAMP(SmallA.StringKey) AS DOUBLENUM FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+ */
+
+ @Test public void testRightFunction() throws Exception {
+ String input = "SELECT INTKEY, FLOATNUM FROM BQT1.SmallA WHERE right(FLOATNUM, 2) <> 0 ORDER BY INTKEY";
+ String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE substr(cast(SmallA.FloatNum AS varchar(100)),(character_length(cast(SmallA.FloatNum AS varchar(100)))-2+1)) <> '0' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+
+ @Test public void testLocateFunction() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, SHORTVALUE FROM BQT1.SmallA WHERE (LOCATE(0, STRINGKEY) = 2) OR (LOCATE(2, SHORTVALUE, 4) = 6) ORDER BY intkey";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.ShortValue FROM SmallA WHERE position('0' in SmallA.StringKey) = 2 OR position('2' in substr(cast(SmallA.ShortValue AS varchar(100)),4)) = 6 ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+}
13 years, 7 months
teiid SVN: r3479 - branches/7.1.x.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:59:58 -0400 (Tue, 13 Sep 2011)
New Revision: 3479
Modified:
branches/7.1.x/pom.xml
Log:
changed pom.xml files for CP3 branch naming
Modified: branches/7.1.x/pom.xml
===================================================================
--- branches/7.1.x/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
+++ branches/7.1.x/pom.xml 2011-09-13 22:59:58 UTC (rev 3479)
@@ -5,7 +5,7 @@
<artifactId>teiid-parent</artifactId>
<packaging>pom</packaging>
<name>Teiid</name>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
<description>Federated SQL and XML query engine.</description>
<properties>
<ant.version>1.7.0</ant.version>
13 years, 7 months
teiid SVN: r3478 - in branches/7.1.x: api and 35 other directories.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:59:52 -0400 (Tue, 13 Sep 2011)
New Revision: 3478
Modified:
branches/7.1.x/adminshell/pom.xml
branches/7.1.x/api/pom.xml
branches/7.1.x/build/pom.xml
branches/7.1.x/cache-jbosscache/pom.xml
branches/7.1.x/client-jdk15/pom.xml
branches/7.1.x/client/pom.xml
branches/7.1.x/common-core/pom.xml
branches/7.1.x/connectors/connector-file/pom.xml
branches/7.1.x/connectors/connector-ldap/pom.xml
branches/7.1.x/connectors/connector-salesforce/pom.xml
branches/7.1.x/connectors/connector-ws/pom.xml
branches/7.1.x/connectors/pom.xml
branches/7.1.x/connectors/salesforce-api/pom.xml
branches/7.1.x/connectors/sandbox/pom.xml
branches/7.1.x/connectors/sandbox/translator-yahoo/pom.xml
branches/7.1.x/connectors/translator-file/pom.xml
branches/7.1.x/connectors/translator-jdbc/pom.xml
branches/7.1.x/connectors/translator-ldap/pom.xml
branches/7.1.x/connectors/translator-loopback/pom.xml
branches/7.1.x/connectors/translator-salesforce/pom.xml
branches/7.1.x/connectors/translator-ws/pom.xml
branches/7.1.x/console/pom.xml
branches/7.1.x/documentation/admin-guide/pom.xml
branches/7.1.x/documentation/caching-guide/pom.xml
branches/7.1.x/documentation/client-developers-guide/pom.xml
branches/7.1.x/documentation/developer-guide/pom.xml
branches/7.1.x/documentation/pom.xml
branches/7.1.x/documentation/quick-start-example/pom.xml
branches/7.1.x/documentation/reference/pom.xml
branches/7.1.x/engine/pom.xml
branches/7.1.x/hibernate-dialect/pom.xml
branches/7.1.x/jboss-integration/pom.xml
branches/7.1.x/metadata/pom.xml
branches/7.1.x/runtime/pom.xml
branches/7.1.x/test-integration/common/pom.xml
branches/7.1.x/test-integration/db/pom.xml
branches/7.1.x/test-integration/pom.xml
Log:
changed pom.xml files for CP3 branch naming
Modified: branches/7.1.x/adminshell/pom.xml
===================================================================
--- branches/7.1.x/adminshell/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/adminshell/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-adminshell</artifactId>
Modified: branches/7.1.x/api/pom.xml
===================================================================
--- branches/7.1.x/api/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/api/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-api</artifactId>
Modified: branches/7.1.x/build/pom.xml
===================================================================
--- branches/7.1.x/build/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/build/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid</artifactId>
Modified: branches/7.1.x/cache-jbosscache/pom.xml
===================================================================
--- branches/7.1.x/cache-jbosscache/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/cache-jbosscache/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-cache-jbosscache</artifactId>
Modified: branches/7.1.x/client/pom.xml
===================================================================
--- branches/7.1.x/client/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/client/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client</artifactId>
Modified: branches/7.1.x/client-jdk15/pom.xml
===================================================================
--- branches/7.1.x/client-jdk15/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/client-jdk15/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client-jdk15</artifactId>
Modified: branches/7.1.x/common-core/pom.xml
===================================================================
--- branches/7.1.x/common-core/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/common-core/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-common-core</artifactId>
Modified: branches/7.1.x/connectors/connector-file/pom.xml
===================================================================
--- branches/7.1.x/connectors/connector-file/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/connector-file/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-file</artifactId>
Modified: branches/7.1.x/connectors/connector-ldap/pom.xml
===================================================================
--- branches/7.1.x/connectors/connector-ldap/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/connector-ldap/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ldap</artifactId>
Modified: branches/7.1.x/connectors/connector-salesforce/pom.xml
===================================================================
--- branches/7.1.x/connectors/connector-salesforce/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/connector-salesforce/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-salesforce</artifactId>
Modified: branches/7.1.x/connectors/connector-ws/pom.xml
===================================================================
--- branches/7.1.x/connectors/connector-ws/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/connector-ws/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ws</artifactId>
Modified: branches/7.1.x/connectors/pom.xml
===================================================================
--- branches/7.1.x/connectors/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: branches/7.1.x/connectors/salesforce-api/pom.xml
===================================================================
--- branches/7.1.x/connectors/salesforce-api/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/salesforce-api/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>salesforce-api</artifactId>
Modified: branches/7.1.x/connectors/sandbox/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid.connectors</groupId>
Modified: branches/7.1.x/connectors/sandbox/translator-yahoo/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-yahoo/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/sandbox/translator-yahoo/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-yahoo</artifactId>
Modified: branches/7.1.x/connectors/translator-file/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-file/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/translator-file/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-file</artifactId>
Modified: branches/7.1.x/connectors/translator-jdbc/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/translator-jdbc/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jdbc</artifactId>
Modified: branches/7.1.x/connectors/translator-ldap/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-ldap/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/translator-ldap/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ldap</artifactId>
Modified: branches/7.1.x/connectors/translator-loopback/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-loopback/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/translator-loopback/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-loopback</artifactId>
Modified: branches/7.1.x/connectors/translator-salesforce/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-salesforce/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/translator-salesforce/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-salesforce</artifactId>
Modified: branches/7.1.x/connectors/translator-ws/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-ws/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/connectors/translator-ws/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ws</artifactId>
Modified: branches/7.1.x/console/pom.xml
===================================================================
--- branches/7.1.x/console/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/console/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -4,7 +4,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/7.1.x/documentation/admin-guide/pom.xml
===================================================================
--- branches/7.1.x/documentation/admin-guide/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/admin-guide/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>admin-guide</artifactId>
Modified: branches/7.1.x/documentation/caching-guide/pom.xml
===================================================================
--- branches/7.1.x/documentation/caching-guide/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/caching-guide/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>caching-guide</artifactId>
Modified: branches/7.1.x/documentation/client-developers-guide/pom.xml
===================================================================
--- branches/7.1.x/documentation/client-developers-guide/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/client-developers-guide/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>client-developers-guide</artifactId>
Modified: branches/7.1.x/documentation/developer-guide/pom.xml
===================================================================
--- branches/7.1.x/documentation/developer-guide/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/developer-guide/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>developer-guide</artifactId>
Modified: branches/7.1.x/documentation/pom.xml
===================================================================
--- branches/7.1.x/documentation/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version> </parent>
+ <version>7.1.1.CP3</version> </parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
Modified: branches/7.1.x/documentation/quick-start-example/pom.xml
===================================================================
--- branches/7.1.x/documentation/quick-start-example/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/quick-start-example/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>quick-start-example</artifactId>
Modified: branches/7.1.x/documentation/reference/pom.xml
===================================================================
--- branches/7.1.x/documentation/reference/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/documentation/reference/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>reference</artifactId>
Modified: branches/7.1.x/engine/pom.xml
===================================================================
--- branches/7.1.x/engine/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/engine/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-engine</artifactId>
Modified: branches/7.1.x/hibernate-dialect/pom.xml
===================================================================
--- branches/7.1.x/hibernate-dialect/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/hibernate-dialect/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-hibernate-dialect</artifactId>
Modified: branches/7.1.x/jboss-integration/pom.xml
===================================================================
--- branches/7.1.x/jboss-integration/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/jboss-integration/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: branches/7.1.x/metadata/pom.xml
===================================================================
--- branches/7.1.x/metadata/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/metadata/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-metadata</artifactId>
Modified: branches/7.1.x/runtime/pom.xml
===================================================================
--- branches/7.1.x/runtime/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/runtime/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: branches/7.1.x/test-integration/common/pom.xml
===================================================================
--- branches/7.1.x/test-integration/common/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/test-integration/common/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-common</artifactId>
Modified: branches/7.1.x/test-integration/db/pom.xml
===================================================================
--- branches/7.1.x/test-integration/db/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/test-integration/db/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -9,7 +9,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: branches/7.1.x/test-integration/pom.xml
===================================================================
--- branches/7.1.x/test-integration/pom.xml 2011-09-13 22:59:10 UTC (rev 3477)
+++ branches/7.1.x/test-integration/pom.xml 2011-09-13 22:59:52 UTC (rev 3478)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.1.1.GA</version>
+ <version>7.1.1.CP3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-test-integration</artifactId>
13 years, 7 months
teiid SVN: r3477 - branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:59:10 -0400 (Tue, 13 Sep 2011)
New Revision: 3477
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
Log:
SOA-3103 supportsOuterJoins=false was removed, teradata does support this.
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:58:58 UTC (rev 3476)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:59:10 UTC (rev 3477)
@@ -56,7 +56,6 @@
protected ConvertModifier convert = new ConvertModifier();
public TeradataExecutionFactory() {
- setSupportsOuterJoins(false);
}
@Override
13 years, 7 months
teiid SVN: r3476 - in branches/7.1.x/connectors/sandbox: translator-teradata and 3 other directories.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:58:58 -0400 (Tue, 13 Sep 2011)
New Revision: 3476
Removed:
branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
Modified:
branches/7.1.x/connectors/sandbox/pom.xml
Log:
SOA-3103: removing the sandbox translator
Modified: branches/7.1.x/connectors/sandbox/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:58:40 UTC (rev 3475)
+++ branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:58:58 UTC (rev 3476)
@@ -13,6 +13,5 @@
<description>Experimental connectors in progress</description>
<modules>
<module>translator-yahoo</module>
- <module>translator-teradata</module>
</modules>
</project>
Deleted: branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml 2011-09-13 22:58:40 UTC (rev 3475)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml 2011-09-13 22:58:58 UTC (rev 3476)
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>sandbox</artifactId>
- <groupId>org.jboss.teiid.connectors</groupId>
- <version>7.1.1.GA</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>translator-teradata</artifactId>
- <groupId>org.jboss.teiid.connectors.sandbox</groupId>
- <name>Teradata Translator</name>
- <description>Teradata Translator</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>translator-jdbc</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>translator-jdbc</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <outputDirectory>target/classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
-</project>
Deleted: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:58:40 UTC (rev 3475)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:58:58 UTC (rev 3476)
@@ -1,472 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.teradata;
-
-import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.LanguageFactory;
-import org.teiid.language.Literal;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.Translator;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.AliasModifier;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-
-
-
-/**
- * Teradata database Release 12
- */
-@Translator(name="teradata", description="A translator for Teradata Database")
-public class TeradataExecutionFactory extends JDBCExecutionFactory {
-
- public static String TERADATA = "teradata"; //$NON-NLS-1$
- protected ConvertModifier convert = new ConvertModifier();
-
- public TeradataExecutionFactory() {
- setSupportsOuterJoins(false);
- }
-
- @Override
- public void start() throws TranslatorException {
- super.start();
- convert.addTypeMapping("byteint", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.BOOLEAN); //$NON-NLS-1$
- convert.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
- convert.addTypeMapping("numeric(18,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
-
- convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME")); //$NON-NLS-1$
- convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE")); //$NON-NLS-1$
- convert.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
- convert.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
-
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer")); //$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGDECIMAL, new CastModifier("decimal(37,5)"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGINTEGER, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.BOOLEAN, new CastModifier("byteint"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.LONG, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.SHORT, new CastModifier("smallint"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double precision"));//$NON-NLS-1$
- convert.addConvert(FunctionModifier.STRING, FunctionModifier.BYTE, new CastModifier("byteint")); //$NON-NLS-1$
-
- convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'Y4-MM-DDBHH:MI:SSDS(6)') AS VARCHAR(26))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convert.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'HH:MI:SS') AS VARCHAR(9))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convert.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'YYYY-MM-DD') AS VARCHAR(11))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
-
- convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
- convert.addNumericBooleanConversions();
-
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstrModifier(this.convert));
- registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LCASE, new StringOnlyModifier("LOWER", this.convert)); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.UCASE, new StringOnlyModifier("UPPER", this.convert)); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LENGTH, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
- target.add("character_length("); //$NON-NLS-1$
- target.addAll(expressionToString(function.getParameters().get(0), convert));
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- });
- registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractModifier("YEAR")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractModifier("MONTH")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractModifier("HOUR")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractModifier("MINUTE")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractModifier("SECOND")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateModifier(this.convert));
- registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
- registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
- registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- function.setName(SourceSystemFunctions.TAN);
- return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
- }
- });
- registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
- target.add("TRIM(LEADING FROM ");//$NON-NLS-1$
- target.addAll(expressionToString(function.getParameters().get(0), convert));
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- });
- registerFunctionModifier(SourceSystemFunctions.RTRIM, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
- target.add("TRIM(TRAILING FROM ");//$NON-NLS-1$
- target.addAll(expressionToString(function.getParameters().get(0), convert));
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- });
- registerFunctionModifier(SourceSystemFunctions.MOD, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$
- }
- });
-
- /* Push down support only available from 7.4
- addPushDownFunction(TERADATA, "COSH", FLOAT, FLOAT); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "TANH", FLOAT, FLOAT); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "ACOSH", FLOAT, FLOAT); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "ASINH", FLOAT, FLOAT); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "ATANH", FLOAT, FLOAT); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "CHAR2HEXINT", STRING, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "INDEX", INTEGER, STRING, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "BYTES", INTEGER, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "OCTET_LENGTH", INTEGER, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "HASHAMP", INTEGER, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "HASHBAKAMP", INTEGER, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "HASHBUCKET", INTEGER, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "HASHROW", INTEGER, STRING); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "NULLIFZERO", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
- addPushDownFunction(TERADATA, "ZEROIFNULL", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
- */
- }
-
- @Override
- public SQLConversionVisitor getSQLConversionVisitor() {
- return new TeradataSQLConversionVisitor(this);
- }
-
-
- @Override
- public List getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
- supportedFunctions.add(SourceSystemFunctions.ABS);
- supportedFunctions.add(SourceSystemFunctions.ACOS);
- supportedFunctions.add(SourceSystemFunctions.ASIN);
- supportedFunctions.add(SourceSystemFunctions.ATAN);
- supportedFunctions.add(SourceSystemFunctions.ATAN2);
- supportedFunctions.add(SourceSystemFunctions.COALESCE);
- supportedFunctions.add(SourceSystemFunctions.COS);
- supportedFunctions.add(SourceSystemFunctions.COT);
- supportedFunctions.add(SourceSystemFunctions.CONVERT);
- supportedFunctions.add(SourceSystemFunctions.CURDATE);
- supportedFunctions.add(SourceSystemFunctions.CURTIME);
- supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
- supportedFunctions.add(SourceSystemFunctions.EXP);
- supportedFunctions.add(SourceSystemFunctions.HOUR);
- supportedFunctions.add(SourceSystemFunctions.LEFT);
- supportedFunctions.add(SourceSystemFunctions.LOCATE);
- supportedFunctions.add(SourceSystemFunctions.LOG);
- supportedFunctions.add(SourceSystemFunctions.LCASE);
- supportedFunctions.add(SourceSystemFunctions.LTRIM);
- supportedFunctions.add(SourceSystemFunctions.LENGTH);
- supportedFunctions.add(SourceSystemFunctions.MINUTE);
- supportedFunctions.add(SourceSystemFunctions.MOD);
- supportedFunctions.add(SourceSystemFunctions.MONTH);
- supportedFunctions.add(SourceSystemFunctions.NULLIF);
- supportedFunctions.add(SourceSystemFunctions.RAND);
- supportedFunctions.add(SourceSystemFunctions.RIGHT);
- supportedFunctions.add(SourceSystemFunctions.RTRIM);
- supportedFunctions.add(SourceSystemFunctions.SECOND);
- supportedFunctions.add(SourceSystemFunctions.SIN);
- supportedFunctions.add(SourceSystemFunctions.SQRT);
- supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
- supportedFunctions.add(SourceSystemFunctions.TAN);
- supportedFunctions.add(SourceSystemFunctions.UCASE);
- supportedFunctions.add(SourceSystemFunctions.YEAR);
-
- return supportedFunctions;
- }
-
- @Override
- public String translateLiteralDate(Date dateValue) {
- return "cast('" + formatDateValue(dateValue) + "' AS DATE FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTime(Time timeValue) {
- return "cast('" + formatDateValue(timeValue) + "' AS TIME(0) FORMAT 'hh:mi:ss')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "cast('" + formatDateValue(timestampValue) + "' AS TIMESTAMP(6))"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- // Teradata also supports MINUS & ALL set operators
- // more aggregates available
-
- @Override
- public boolean supportsScalarSubqueries() {
- return false;
- }
-
- @Override
- public boolean supportsUnions() {
- return true;
- }
-
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- @Override
- public boolean supportsInlineViews() {
- return true;
- }
-
- @Override
- public boolean supportsAggregatesEnhancedNumeric() {
- return true;
- }
-
- /* only in 7.4
- @Override
- public boolean supportsCommonTableExpressions() {
- return false;
- }
- */
-
- @Override
- public NullOrder getDefaultNullOrder() {
- return NullOrder.FIRST;
- }
-
- @Override
- public boolean supportsSetQueryOrderBy() {
- return false;
- }
-
- public static class LocateModifier extends FunctionModifier {
- ConvertModifier convertModifier;
-
- public LocateModifier(ConvertModifier convertModifier) {
- this.convertModifier = convertModifier;
- }
-
- @Override
- public List<?> translate(Function function) {
- ArrayList target = new ArrayList();
- Expression expr1 = function.getParameters().get(0);
- Expression expr2 = function.getParameters().get(1);
- if (function.getParameters().size() > 2) {
- Expression expr3 = function.getParameters().get(2);
- target.add("position("); //$NON-NLS-1$
- target.addAll(expressionToString(expr1, this.convertModifier));
- target.add( " in "); //$NON-NLS-1$
- target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(expr2, this.convertModifier));
- target.add(","); //$NON-NLS-1$
- target.add(expr3);
- target.add("))"); //$NON-NLS-1$
- }
- else {
- target.add("position("); //$NON-NLS-1$
- target.addAll(expressionToString(expr1, this.convertModifier));
- target.add( " in "); //$NON-NLS-1$
- target.addAll(expressionToString(expr2, this.convertModifier));
- target.add(")"); //$NON-NLS-1$
- }
- return target;
- }
- }
-
- private static List<?> expressionToString(Expression expr, ConvertModifier modifier) {
- Class tgtType = expr.getType();
- if (tgtType.equals(String.class) && ((expr instanceof Literal) || expr instanceof ColumnReference)) {
- return Arrays.asList(expr);
- }
- else if (tgtType.equals(String.class) && (expr instanceof Function)) {
-
- Function func = (Function)expr;
- while(true) {
- Expression arg1 = func.getParameters().get(0);
- if ((arg1 instanceof Function) && ((Function)arg1).getName().equals("convert")) { //$NON-NLS-1$
- func = (Function)arg1;
- }
- else {
- break;
- }
- }
- Expression arg1 = func.getParameters().get(0);
- if (arg1 instanceof ColumnReference) {
- ColumnReference ref = (ColumnReference)func.getParameters().get(0);
- if(Number.class.isAssignableFrom(ref.getType())) {
- ArrayList target = new ArrayList();
- target.add("cast("); //$NON-NLS-1$
- target.add(func.getParameters().get(0));
- target.add(" AS varchar(100))"); //$NON-NLS-1$
- return target;
- }
- else if (String.class.isAssignableFrom(ref.getType())) {
- return Arrays.asList(ref);
- }
- }
- return modifier.translate(func);
- }
- return Arrays.asList("cast(" , expr, " AS varchar(100))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static class ExtractModifier extends FunctionModifier {
- private String type;
- public ExtractModifier(String type) {
- this.type = type;
- }
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public static class CastModifier extends FunctionModifier {
- private String target;
- public CastModifier(String target) {
- this.target = target;
- }
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(", function.getParameters().get(0), " AS "+this.target+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public static class StringOnlyModifier extends FunctionModifier {
- String funcName;
- ConvertModifier convertModifier;
- public StringOnlyModifier(String name, ConvertModifier converModifier) {
- this.funcName = name;
- this.convertModifier = converModifier;
- }
- @Override
- public List<?> translate(Function function) {
- Expression expr = function.getParameters().get(0);
- ArrayList target = new ArrayList();
- target.add(this.funcName);
- target.add("("); //$NON-NLS-1$
- target.addAll(expressionToString(expr, this.convertModifier));
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- }
-
- public static class SubstrModifier extends FunctionModifier {
- ConvertModifier convertModifier;
- public SubstrModifier(ConvertModifier converModifier) {
- this.convertModifier = converModifier;
- }
- @Override
- public List<?> translate(Function function) {
- Expression expr = function.getParameters().get(0);
- ArrayList target = new ArrayList();
- target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(expr, this.convertModifier));
- target.add(","); //$NON-NLS-1$
- target.add(function.getParameters().get(1));
- if (function.getParameters().size() > 2 ) {
- target.add(","); //$NON-NLS-1$
- target.add(function.getParameters().get(2));
- }
- target.add(")"); //$NON-NLS-1$
- return target;
- }
- }
-
- public static class LeftOrRightFunctionModifier extends FunctionModifier {
- private LanguageFactory langFactory;
- ConvertModifier convertModifier;
-
- public LeftOrRightFunctionModifier(LanguageFactory langFactory, ConvertModifier converModifier) {
- this.langFactory = langFactory;
- this.convertModifier = converModifier;
- }
-
- @Override
- public List<?> translate(Function function) {
- List<Expression> args = function.getParameters();
- ArrayList target = new ArrayList();
- if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
- //substr(string, 1, length)
- target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(args.get(0), this.convertModifier));
- target.add(","); //$NON-NLS-1$
- target.add(langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER));
- target.add(","); //$NON-NLS-1$
- target.add(args.get(1));
- target.add(")"); //$NON-NLS-1$
- } else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
- //substr(case_size, character_length(case_size) -4)
- target.add("substr("); //$NON-NLS-1$
- target.addAll(expressionToString(args.get(0), this.convertModifier));
-
- target.add(",(character_length("); //$NON-NLS-1$
- target.addAll(expressionToString(args.get(0), this.convertModifier));
- target.add(")-"); //$NON-NLS-1$
- target.add(args.get(1));
- target.add("+1))"); //$NON-NLS-1$ // offset for 1 based index
- }
- return target;
- }
- }
-}
Deleted: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-09-13 22:58:40 UTC (rev 3475)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-09-13 22:58:58 UTC (rev 3476)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.translator.jdbc.teradata;
-
-import java.util.List;
-
-import org.teiid.language.AndOr;
-import org.teiid.language.Comparison;
-import org.teiid.language.Condition;
-import org.teiid.language.Expression;
-import org.teiid.language.In;
-import org.teiid.language.LanguageFactory;
-import org.teiid.language.AndOr.Operator;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-
-public class TeradataSQLConversionVisitor extends SQLConversionVisitor {
-
- public TeradataSQLConversionVisitor(TeradataExecutionFactory ef) {
- super(ef);
- }
-
- @Override
- public void visit(In obj) {
- List<Expression> exprs = obj.getRightExpressions();
-
- Class expectedType = obj.getLeftExpression().getType();
-
- boolean decompose = false;
- for (Expression expr:exprs) {
- if (!(expr.getType().equals(expectedType)) || (!(expr.getType().isAssignableFrom(Number.class)) && !expr.getType().isAssignableFrom(String.class))) {
- decompose = true;
- }
- }
-
- if (decompose) {
- Comparison.Operator opCode = obj.isNegated()?Comparison.Operator.NE:Comparison.Operator.EQ;
- if (exprs.size() > 1) {
- Condition left = LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0));
- for (int i = 1; i < exprs.size(); i++) {
- AndOr replace = LanguageFactory.INSTANCE.createAndOr(obj.isNegated()?Operator.AND:Operator.OR, left, LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(i)));
- left = replace;
- }
- super.visit((AndOr)left);
- }
- else {
- super.visit(LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0)));
- }
- }
- else {
- super.visit(obj);
- }
- }
-}
Deleted: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml 2011-09-13 22:58:40 UTC (rev 3475)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml 2011-09-13 22:58:58 UTC (rev 3476)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- TERADATA -->
- <bean name="translator-teradata-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
- <property name="info"><inject bean="translator-teradata" /> </property>
- <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
- </bean>
-
- <bean name="translator-teradata" class="org.teiid.templates.TranslatorTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="TranslatorDeploymentTemplateInfoFactory" />
- <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.translator.jdbc.teradata.TeradataExecutionFactory</parameter>
- <parameter class="java.lang.String">translator-teradata</parameter>
- <parameter class="java.lang.String">teradata</parameter>
- </constructor>
- </bean>
-</deployment>
Deleted: branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-09-13 22:58:40 UTC (rev 3475)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-09-13 22:58:58 UTC (rev 3476)
@@ -1,207 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.translator.jdbc.teradata;
-
-import static org.junit.Assert.assertEquals;
-
-import java.sql.Date;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.In;
-import org.teiid.language.LanguageFactory;
-import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.TranslationHelper;
-
-@SuppressWarnings("nls")
-public class TestTeradataTranslator {
-
- private static TeradataExecutionFactory TRANSLATOR;
- private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
-
- @BeforeClass
- public static void setUp() throws TranslatorException {
- TRANSLATOR = new TeradataExecutionFactory();
- TRANSLATOR.setUseBindVariables(false);
- TRANSLATOR.start();
- }
-
- public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
- Function func = LANG_FACTORY.createFunction("convert",
- Arrays.asList( srcExpression,LANG_FACTORY.createLiteral(tgtType, String.class)),TypeFacility.getDataTypeClass(tgtType));
-
- assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
- expectedExpression, helpGetString(func));
- }
-
- public String helpGetString(Expression expr) throws Exception {
- SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
- sqlVisitor.append(expr);
-
- return sqlVisitor.toString();
- }
-
- @Test public void testSubstring1() throws Exception {
- String input = "SELECT dayofmonth(datevalue) FROM BQT1.SMALLA";
- String output = "SELECT extract(DAY from SmallA.DateValue) FROM SmallA";
-
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
- }
-
- @Test public void testTimestampToTime() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(111, 4, 5, 9, 16, 34, 220000000), Timestamp.class), "time", "cast(cast('2011-05-05 09:16:34.22' AS TIMESTAMP(6)) AS TIME)");
- }
-
- @Test public void testIntegerToString() throws Exception {
- String input = "SELECT lcase(bigdecimalvalue) FROM BQT1.SMALLA";
- String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(100))) FROM SmallA";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
- }
-
- @Test public void testSubString() throws Exception {
- String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1) = '1' ORDER BY intkey";
- String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1) = '1' ORDER BY SmallA.IntKey";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
- }
-
- @Test public void testSubString2() throws Exception {
- String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1, 2) = '1' ORDER BY intkey";
- String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1,2) = '1' ORDER BY SmallA.IntKey";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
- }
-
- @Test public void testDateToString() throws Exception {
- String input = "SELECT intkey, UPPER(timevalue) AS UPPER FROM BQT1.SmallA ORDER BY intkey";
- String output = "SELECT SmallA.IntKey, UPPER(cast(cast(SmallA.TimeValue AS FORMAT 'HH:MI:SS') AS VARCHAR(9))) AS UPPER FROM SmallA ORDER BY SmallA.IntKey";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
- }
-
- @Test public void testLocate() throws Exception {
- String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA WHERE LOCATE('-', BIGDECIMALVALUE) = 1 ORDER BY intkey";
- String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(100))) = 1 ORDER BY SmallA.IntKey";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
- }
-
-
- @Test public void testByteToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))");
- }
-
- @Test public void testByte2ToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)-1), Byte.class), "string", "cast(-1 AS varchar(4000))");
- }
-
- @Test public void testDoubleToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class), "string", "cast(1.0 AS varchar(4000))");
- }
-
- @Test public void testStringToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("1.0", String.class), "double", "cast('1.0' AS double precision)");
- }
-
- @Test public void testInDecompose() throws Exception {
- Expression left = LANG_FACTORY.createLiteral("1", String.class);
- List<Expression> right = new ArrayList<Expression>();
- right.add(LANG_FACTORY.createLiteral("2", String.class));
- right.add(LANG_FACTORY.createLiteral("3", String.class));
-
- In expr = LANG_FACTORY.createIn(left,right, false);
-
- assertEquals("'1' IN ('2', '3')", helpGetString(expr));
- }
-
- @Test public void testSingleInDecompose() throws Exception {
- Expression left = LANG_FACTORY.createLiteral("1", String.class);
- List<Expression> right = new ArrayList<Expression>();
- right.add(LANG_FACTORY.createLiteral("2", String.class));
-
- In expr = LANG_FACTORY.createIn(left,right, false);
-
- assertEquals("'1' IN ('2')", helpGetString(expr));
- }
-
- @Test public void testInDecomposeNonLiterals() throws Exception {
- Expression left = LANG_FACTORY.createLiteral("1", String.class);
- List<Expression> right = new ArrayList<Expression>();
- right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
- right.add(LANG_FACTORY.createLiteral("3", String.class));
-
- In expr = LANG_FACTORY.createIn(left,right, false);
-
- assertEquals("'1' = func() OR '1' = '3'", helpGetString(expr));
- }
-
- @Test public void testNegatedInDecomposeNonLiterals() throws Exception {
- Expression left = LANG_FACTORY.createLiteral("1", String.class);
- List<Expression> right = new ArrayList<Expression>();
- right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
- right.add(LANG_FACTORY.createLiteral("3", String.class));
-
- In expr = LANG_FACTORY.createIn(left,right, true);
-
- assertEquals("'1' <> func() AND '1' <> '3'", helpGetString(expr));
- }
-
- @Test public void testsingleInDecomposeNonLiterals() throws Exception {
- Expression left = LANG_FACTORY.createLiteral("1", String.class);
- List<Expression> right = new ArrayList<Expression>();
- right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
-
- In expr = LANG_FACTORY.createIn(left,right, false);
-
- assertEquals("'1' = func()", helpGetString(expr));
- }
-
- /* only 7.4
- @Test public void testNullComapreNull() throws Exception {
- String input = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM bqt1.smalla WHERE NULL <> NULL";
- String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.DoubleNum FROM SmallA WHERE 1 = 0";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
- }
- @Test public void testPushDownFunction() throws Exception {
- String input = "SELECT teradata.HASHBAKAMP(STRINGKEY) DOUBLENUM FROM bqt1.smalla";
- String out = "SELECT HASHBAKAMP(SmallA.StringKey) AS DOUBLENUM FROM SmallA";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
- }
- */
-
- @Test public void testRightFunction() throws Exception {
- String input = "SELECT INTKEY, FLOATNUM FROM BQT1.SmallA WHERE right(FLOATNUM, 2) <> 0 ORDER BY INTKEY";
- String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE substr(cast(SmallA.FloatNum AS varchar(100)),(character_length(cast(SmallA.FloatNum AS varchar(100)))-2+1)) <> '0' ORDER BY SmallA.IntKey";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
- }
-
- @Test public void testLocateFunction() throws Exception {
- String input = "SELECT INTKEY, STRINGKEY, SHORTVALUE FROM BQT1.SmallA WHERE (LOCATE(0, STRINGKEY) = 2) OR (LOCATE(2, SHORTVALUE, 4) = 6) ORDER BY intkey";
- String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.ShortValue FROM SmallA WHERE position('0' in SmallA.StringKey) = 2 OR position('2' in substr(cast(SmallA.ShortValue AS varchar(100)),4)) = 6 ORDER BY SmallA.IntKey";
- TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
- }
-}
13 years, 7 months
teiid SVN: r3475 - in branches/7.1.x/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc and 1 other directories.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:58:40 -0400 (Tue, 13 Sep 2011)
New Revision: 3475
Added:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
Modified:
branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
Log:
SOA-3103
Modified: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:58:22 UTC (rev 3474)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:58:40 UTC (rev 3475)
@@ -22,60 +22,449 @@
package org.teiid.translator.jdbc.teradata;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
/**
- * for Teradata database Release V2R5.1
+ * Teradata database Release 12
*/
@Translator(name="teradata", description="A translator for Teradata Database")
public class TeradataExecutionFactory extends JDBCExecutionFactory {
+ public static String TERADATA = "teradata"; //$NON-NLS-1$
+ protected ConvertModifier convert = new ConvertModifier();
+
public TeradataExecutionFactory() {
setSupportsOuterJoins(false);
}
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ convert.addTypeMapping("byteint", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("numeric(18,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGDECIMAL, new CastModifier("decimal(37,5)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGINTEGER, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BOOLEAN, new CastModifier("byteint"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.LONG, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.SHORT, new CastModifier("smallint"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double precision"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BYTE, new CastModifier("byteint")); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'Y4-MM-DDBHH:MI:SSDS(6)') AS VARCHAR(26))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'HH:MI:SS') AS VARCHAR(9))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'YYYY-MM-DD') AS VARCHAR(11))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+
+ convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addNumericBooleanConversions();
+
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstrModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new StringOnlyModifier("LOWER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new StringOnlyModifier("UPPER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractModifier("YEAR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractModifier("MONTH")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractModifier("HOUR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractModifier("MINUTE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractModifier("SECOND")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ function.setName(SourceSystemFunctions.TAN);
+ return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("TRIM(LEADING FROM ");//$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.RTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("TRIM(TRAILING FROM ");//$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.MOD, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$
+ }
+ });
+
+ /* Push down support only available from 7.4
+ addPushDownFunction(TERADATA, "COSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "TANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ACOSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ASINH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ATANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "CHAR2HEXINT", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "INDEX", INTEGER, STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "BYTES", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "OCTET_LENGTH", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBAKAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBUCKET", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHROW", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "NULLIFZERO", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ZEROIFNULL", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ */
+ }
+
+ @Override
+ public SQLConversionVisitor getSQLConversionVisitor() {
+ return new TeradataSQLConversionVisitor(this);
+ }
+
+
@Override
public List getSupportedFunctions() {
- List supportedFunctions = new ArrayList();
+ List<String> supportedFunctions = new ArrayList<String>();
supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
-// supportedFunctions.add("LOG"); //$NON-NLS-1$ // "LN"
-// supportedFunctions.add("LOG10"); //$NON-NLS-1$ // "LOG"
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
-// supportedFunctions.add("CONCAT"); //$NON-NLS-1$ // "||"
-// supportedFunctions.add("LCASE"); //$NON-NLS-1$ // "LOWER"
-// supportedFunctions.add("LOCATE"); //$NON-NLS-1$ //"POSITION", "INDEX" ?
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
-// supportedFunctions.add("UCASE"); //$NON-NLS-1$ // "UPPER"
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("DAY"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- //supportedFunctions.add("CONVERT"); //$NON-NLS-1$ "CAST"
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.COT);
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.NULLIF);
+ supportedFunctions.add(SourceSystemFunctions.RAND);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
return supportedFunctions;
}
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "cast('" + formatDateValue(dateValue) + "' AS DATE FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "cast('" + formatDateValue(timeValue) + "' AS TIME(0) FORMAT 'hh:mi:ss')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "cast('" + formatDateValue(timestampValue) + "' AS TIMESTAMP(6))"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ // Teradata also supports MINUS & ALL set operators
+ // more aggregates available
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesEnhancedNumeric() {
+ return true;
+ }
+
+ /* only in 7.4
+ @Override
+ public boolean supportsCommonTableExpressions() {
+ return false;
+ }
+ */
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.FIRST;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
+ public static class LocateModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+
+ public LocateModifier(ConvertModifier convertModifier) {
+ this.convertModifier = convertModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ Expression expr1 = function.getParameters().get(0);
+ Expression expr2 = function.getParameters().get(1);
+ if (function.getParameters().size() > 2) {
+ Expression expr3 = function.getParameters().get(2);
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(expr3);
+ target.add("))"); //$NON-NLS-1$
+ }
+ else {
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ }
+ return target;
+ }
+ }
+
+ private static List<?> expressionToString(Expression expr, ConvertModifier modifier) {
+ Class tgtType = expr.getType();
+ if (tgtType.equals(String.class) && ((expr instanceof Literal) || expr instanceof ColumnReference)) {
+ return Arrays.asList(expr);
+ }
+ else if (tgtType.equals(String.class) && (expr instanceof Function)) {
+
+ Function func = (Function)expr;
+ while(true) {
+ Expression arg1 = func.getParameters().get(0);
+ if ((arg1 instanceof Function) && ((Function)arg1).getName().equals("convert")) { //$NON-NLS-1$
+ func = (Function)arg1;
+ }
+ else {
+ break;
+ }
+ }
+ Expression arg1 = func.getParameters().get(0);
+ if (arg1 instanceof ColumnReference) {
+ ColumnReference ref = (ColumnReference)func.getParameters().get(0);
+ if(Number.class.isAssignableFrom(ref.getType())) {
+ ArrayList target = new ArrayList();
+ target.add("cast("); //$NON-NLS-1$
+ target.add(func.getParameters().get(0));
+ target.add(" AS varchar(100))"); //$NON-NLS-1$
+ return target;
+ }
+ else if (String.class.isAssignableFrom(ref.getType())) {
+ return Arrays.asList(ref);
+ }
+ }
+ return modifier.translate(func);
+ }
+ return Arrays.asList("cast(" , expr, " AS varchar(100))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static class ExtractModifier extends FunctionModifier {
+ private String type;
+ public ExtractModifier(String type) {
+ this.type = type;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class CastModifier extends FunctionModifier {
+ private String target;
+ public CastModifier(String target) {
+ this.target = target;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(", function.getParameters().get(0), " AS "+this.target+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class StringOnlyModifier extends FunctionModifier {
+ String funcName;
+ ConvertModifier convertModifier;
+ public StringOnlyModifier(String name, ConvertModifier converModifier) {
+ this.funcName = name;
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add(this.funcName);
+ target.add("("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class SubstrModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+ public SubstrModifier(ConvertModifier converModifier) {
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(function.getParameters().get(1));
+ if (function.getParameters().size() > 2 ) {
+ target.add(","); //$NON-NLS-1$
+ target.add(function.getParameters().get(2));
+ }
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class LeftOrRightFunctionModifier extends FunctionModifier {
+ private LanguageFactory langFactory;
+ ConvertModifier convertModifier;
+
+ public LeftOrRightFunctionModifier(LanguageFactory langFactory, ConvertModifier converModifier) {
+ this.langFactory = langFactory;
+ this.convertModifier = converModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ List<Expression> args = function.getParameters();
+ ArrayList target = new ArrayList();
+ if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
+ //substr(string, 1, length)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER));
+ target.add(","); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add(")"); //$NON-NLS-1$
+ } else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
+ //substr(case_size, character_length(case_size) -4)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+
+ target.add(",(character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(")-"); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add("+1))"); //$NON-NLS-1$ // offset for 1 based index
+ }
+ return target;
+ }
+ }
}
Added: branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java (rev 0)
+++ branches/7.1.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-09-13 22:58:40 UTC (rev 3475)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import java.util.List;
+
+import org.teiid.language.AndOr;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.AndOr.Operator;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+public class TeradataSQLConversionVisitor extends SQLConversionVisitor {
+
+ public TeradataSQLConversionVisitor(TeradataExecutionFactory ef) {
+ super(ef);
+ }
+
+ @Override
+ public void visit(In obj) {
+ List<Expression> exprs = obj.getRightExpressions();
+
+ Class expectedType = obj.getLeftExpression().getType();
+
+ boolean decompose = false;
+ for (Expression expr:exprs) {
+ if (!(expr.getType().equals(expectedType)) || (!(expr.getType().isAssignableFrom(Number.class)) && !expr.getType().isAssignableFrom(String.class))) {
+ decompose = true;
+ }
+ }
+
+ if (decompose) {
+ Comparison.Operator opCode = obj.isNegated()?Comparison.Operator.NE:Comparison.Operator.EQ;
+ if (exprs.size() > 1) {
+ Condition left = LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0));
+ for (int i = 1; i < exprs.size(); i++) {
+ AndOr replace = LanguageFactory.INSTANCE.createAndOr(obj.isNegated()?Operator.AND:Operator.OR, left, LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(i)));
+ left = replace;
+ }
+ super.visit((AndOr)left);
+ }
+ else {
+ super.visit(LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0)));
+ }
+ }
+ else {
+ super.visit(obj);
+ }
+ }
+}
Added: branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
--- branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java (rev 0)
+++ branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-09-13 22:58:40 UTC (rev 3475)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+@SuppressWarnings("nls")
+public class TestTeradataTranslator {
+
+ private static TeradataExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new TeradataExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert",
+ Arrays.asList( srcExpression,LANG_FACTORY.createLiteral(tgtType, String.class)),TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
+ expectedExpression, helpGetString(func));
+ }
+
+ public String helpGetString(Expression expr) throws Exception {
+ SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ @Test public void testSubstring1() throws Exception {
+ String input = "SELECT dayofmonth(datevalue) FROM BQT1.SMALLA";
+ String output = "SELECT extract(DAY from SmallA.DateValue) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testTimestampToTime() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(111, 4, 5, 9, 16, 34, 220000000), Timestamp.class), "time", "cast(cast('2011-05-05 09:16:34.22' AS TIMESTAMP(6)) AS TIME)");
+ }
+
+ @Test public void testIntegerToString() throws Exception {
+ String input = "SELECT lcase(bigdecimalvalue) FROM BQT1.SMALLA";
+ String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(100))) FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testSubString() throws Exception {
+ String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1) = '1' ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1) = '1' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testSubString2() throws Exception {
+ String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1, 2) = '1' ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1,2) = '1' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testDateToString() throws Exception {
+ String input = "SELECT intkey, UPPER(timevalue) AS UPPER FROM BQT1.SmallA ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, UPPER(cast(cast(SmallA.TimeValue AS FORMAT 'HH:MI:SS') AS VARCHAR(9))) AS UPPER FROM SmallA ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate() throws Exception {
+ String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA WHERE LOCATE('-', BIGDECIMALVALUE) = 1 ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(100))) = 1 ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+
+ @Test public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ @Test public void testByte2ToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)-1), Byte.class), "string", "cast(-1 AS varchar(4000))");
+ }
+
+ @Test public void testDoubleToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class), "string", "cast(1.0 AS varchar(4000))");
+ }
+
+ @Test public void testStringToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("1.0", String.class), "double", "cast('1.0' AS double precision)");
+ }
+
+ @Test public void testInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2', '3')", helpGetString(expr));
+ }
+
+ @Test public void testSingleInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2')", helpGetString(expr));
+ }
+
+ @Test public void testInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func() OR '1' = '3'", helpGetString(expr));
+ }
+
+ @Test public void testNegatedInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, true);
+
+ assertEquals("'1' <> func() AND '1' <> '3'", helpGetString(expr));
+ }
+
+ @Test public void testsingleInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func()", helpGetString(expr));
+ }
+
+ /* only 7.4
+ @Test public void testNullComapreNull() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM bqt1.smalla WHERE NULL <> NULL";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.DoubleNum FROM SmallA WHERE 1 = 0";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+ @Test public void testPushDownFunction() throws Exception {
+ String input = "SELECT teradata.HASHBAKAMP(STRINGKEY) DOUBLENUM FROM bqt1.smalla";
+ String out = "SELECT HASHBAKAMP(SmallA.StringKey) AS DOUBLENUM FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+ */
+
+ @Test public void testRightFunction() throws Exception {
+ String input = "SELECT INTKEY, FLOATNUM FROM BQT1.SmallA WHERE right(FLOATNUM, 2) <> 0 ORDER BY INTKEY";
+ String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE substr(cast(SmallA.FloatNum AS varchar(100)),(character_length(cast(SmallA.FloatNum AS varchar(100)))-2+1)) <> '0' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+
+ @Test public void testLocateFunction() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, SHORTVALUE FROM BQT1.SmallA WHERE (LOCATE(0, STRINGKEY) = 2) OR (LOCATE(2, SHORTVALUE, 4) = 6) ORDER BY intkey";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.ShortValue FROM SmallA WHERE position('0' in SmallA.StringKey) = 2 OR position('2' in substr(cast(SmallA.ShortValue AS varchar(100)),4)) = 6 ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+}
13 years, 7 months
teiid SVN: r3474 - in branches/7.1.x/connectors/sandbox: translator-teradata and 17 other directories.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:58:22 -0400 (Tue, 13 Sep 2011)
New Revision: 3474
Added:
branches/7.1.x/connectors/sandbox/translator-teradata/
branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml
branches/7.1.x/connectors/sandbox/translator-teradata/src/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/
branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/
branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
Modified:
branches/7.1.x/connectors/sandbox/pom.xml
Log:
SOA-3103
Modified: branches/7.1.x/connectors/sandbox/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:57:41 UTC (rev 3473)
+++ branches/7.1.x/connectors/sandbox/pom.xml 2011-09-13 22:58:22 UTC (rev 3474)
@@ -13,5 +13,6 @@
<description>Experimental connectors in progress</description>
<modules>
<module>translator-yahoo</module>
+ <module>translator-teradata</module>
</modules>
</project>
Added: branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/pom.xml 2011-09-13 22:58:22 UTC (rev 3474)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>sandbox</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <version>7.1.1.GA</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>translator-teradata</artifactId>
+ <groupId>org.jboss.teiid.connectors.sandbox</groupId>
+ <name>Teradata Translator</name>
+ <description>Teradata Translator</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+</project>
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-09-13 22:58:22 UTC (rev 3474)
@@ -0,0 +1,472 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.jdbc.teradata;
+
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+
+
+/**
+ * Teradata database Release 12
+ */
+@Translator(name="teradata", description="A translator for Teradata Database")
+public class TeradataExecutionFactory extends JDBCExecutionFactory {
+
+ public static String TERADATA = "teradata"; //$NON-NLS-1$
+ protected ConvertModifier convert = new ConvertModifier();
+
+ public TeradataExecutionFactory() {
+ setSupportsOuterJoins(false);
+ }
+
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ convert.addTypeMapping("byteint", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("numeric(18,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new CastModifier("TIME")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new CastModifier("DATE")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.INTEGER, new CastModifier("integer")); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGDECIMAL, new CastModifier("decimal(37,5)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BIGINTEGER, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new CastModifier("float"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BOOLEAN, new CastModifier("byteint"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.LONG, new CastModifier("numeric(18,0)"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.SHORT, new CastModifier("smallint"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.DOUBLE, new CastModifier("double precision"));//$NON-NLS-1$
+ convert.addConvert(FunctionModifier.STRING, FunctionModifier.BYTE, new CastModifier("byteint")); //$NON-NLS-1$
+
+ convert.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'Y4-MM-DDBHH:MI:SSDS(6)') AS VARCHAR(26))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convert.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'HH:MI:SS') AS VARCHAR(9))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convert.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(cast(", function.getParameters().get(0), " AS FORMAT 'YYYY-MM-DD') AS VARCHAR(11))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+
+ convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addNumericBooleanConversions();
+
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstrModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new StringOnlyModifier("LOWER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new StringOnlyModifier("UPPER", this.convert)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractModifier("YEAR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractModifier("MONTH")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractModifier("HOUR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractModifier("MINUTE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractModifier("SECOND")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateModifier(this.convert));
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory(), this.convert));
+ registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ function.setName(SourceSystemFunctions.TAN);
+ return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.LTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("TRIM(LEADING FROM ");//$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.RTRIM, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ target.add("TRIM(TRAILING FROM ");//$NON-NLS-1$
+ target.addAll(expressionToString(function.getParameters().get(0), convert));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.MOD, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$
+ }
+ });
+
+ /* Push down support only available from 7.4
+ addPushDownFunction(TERADATA, "COSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "TANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ACOSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ASINH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ATANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "CHAR2HEXINT", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "INDEX", INTEGER, STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "BYTES", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "OCTET_LENGTH", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBAKAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBUCKET", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHROW", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "NULLIFZERO", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ZEROIFNULL", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ */
+ }
+
+ @Override
+ public SQLConversionVisitor getSQLConversionVisitor() {
+ return new TeradataSQLConversionVisitor(this);
+ }
+
+
+ @Override
+ public List getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.COT);
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.NULLIF);
+ supportedFunctions.add(SourceSystemFunctions.RAND);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+
+ return supportedFunctions;
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "cast('" + formatDateValue(dateValue) + "' AS DATE FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "cast('" + formatDateValue(timeValue) + "' AS TIME(0) FORMAT 'hh:mi:ss')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "cast('" + formatDateValue(timestampValue) + "' AS TIMESTAMP(6))"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ // Teradata also supports MINUS & ALL set operators
+ // more aggregates available
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesEnhancedNumeric() {
+ return true;
+ }
+
+ /* only in 7.4
+ @Override
+ public boolean supportsCommonTableExpressions() {
+ return false;
+ }
+ */
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.FIRST;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
+ public static class LocateModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+
+ public LocateModifier(ConvertModifier convertModifier) {
+ this.convertModifier = convertModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ ArrayList target = new ArrayList();
+ Expression expr1 = function.getParameters().get(0);
+ Expression expr2 = function.getParameters().get(1);
+ if (function.getParameters().size() > 2) {
+ Expression expr3 = function.getParameters().get(2);
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(expr3);
+ target.add("))"); //$NON-NLS-1$
+ }
+ else {
+ target.add("position("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr1, this.convertModifier));
+ target.add( " in "); //$NON-NLS-1$
+ target.addAll(expressionToString(expr2, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ }
+ return target;
+ }
+ }
+
+ private static List<?> expressionToString(Expression expr, ConvertModifier modifier) {
+ Class tgtType = expr.getType();
+ if (tgtType.equals(String.class) && ((expr instanceof Literal) || expr instanceof ColumnReference)) {
+ return Arrays.asList(expr);
+ }
+ else if (tgtType.equals(String.class) && (expr instanceof Function)) {
+
+ Function func = (Function)expr;
+ while(true) {
+ Expression arg1 = func.getParameters().get(0);
+ if ((arg1 instanceof Function) && ((Function)arg1).getName().equals("convert")) { //$NON-NLS-1$
+ func = (Function)arg1;
+ }
+ else {
+ break;
+ }
+ }
+ Expression arg1 = func.getParameters().get(0);
+ if (arg1 instanceof ColumnReference) {
+ ColumnReference ref = (ColumnReference)func.getParameters().get(0);
+ if(Number.class.isAssignableFrom(ref.getType())) {
+ ArrayList target = new ArrayList();
+ target.add("cast("); //$NON-NLS-1$
+ target.add(func.getParameters().get(0));
+ target.add(" AS varchar(100))"); //$NON-NLS-1$
+ return target;
+ }
+ else if (String.class.isAssignableFrom(ref.getType())) {
+ return Arrays.asList(ref);
+ }
+ }
+ return modifier.translate(func);
+ }
+ return Arrays.asList("cast(" , expr, " AS varchar(100))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static class ExtractModifier extends FunctionModifier {
+ private String type;
+ public ExtractModifier(String type) {
+ this.type = type;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class CastModifier extends FunctionModifier {
+ private String target;
+ public CastModifier(String target) {
+ this.target = target;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(", function.getParameters().get(0), " AS "+this.target+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class StringOnlyModifier extends FunctionModifier {
+ String funcName;
+ ConvertModifier convertModifier;
+ public StringOnlyModifier(String name, ConvertModifier converModifier) {
+ this.funcName = name;
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add(this.funcName);
+ target.add("("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class SubstrModifier extends FunctionModifier {
+ ConvertModifier convertModifier;
+ public SubstrModifier(ConvertModifier converModifier) {
+ this.convertModifier = converModifier;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ Expression expr = function.getParameters().get(0);
+ ArrayList target = new ArrayList();
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(expr, this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(function.getParameters().get(1));
+ if (function.getParameters().size() > 2 ) {
+ target.add(","); //$NON-NLS-1$
+ target.add(function.getParameters().get(2));
+ }
+ target.add(")"); //$NON-NLS-1$
+ return target;
+ }
+ }
+
+ public static class LeftOrRightFunctionModifier extends FunctionModifier {
+ private LanguageFactory langFactory;
+ ConvertModifier convertModifier;
+
+ public LeftOrRightFunctionModifier(LanguageFactory langFactory, ConvertModifier converModifier) {
+ this.langFactory = langFactory;
+ this.convertModifier = converModifier;
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ List<Expression> args = function.getParameters();
+ ArrayList target = new ArrayList();
+ if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
+ //substr(string, 1, length)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(","); //$NON-NLS-1$
+ target.add(langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER));
+ target.add(","); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add(")"); //$NON-NLS-1$
+ } else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
+ //substr(case_size, character_length(case_size) -4)
+ target.add("substr("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+
+ target.add(",(character_length("); //$NON-NLS-1$
+ target.addAll(expressionToString(args.get(0), this.convertModifier));
+ target.add(")-"); //$NON-NLS-1$
+ target.add(args.get(1));
+ target.add("+1))"); //$NON-NLS-1$ // offset for 1 based index
+ }
+ return target;
+ }
+ }
+}
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-09-13 22:58:22 UTC (rev 3474)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import java.util.List;
+
+import org.teiid.language.AndOr;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.AndOr.Operator;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+public class TeradataSQLConversionVisitor extends SQLConversionVisitor {
+
+ public TeradataSQLConversionVisitor(TeradataExecutionFactory ef) {
+ super(ef);
+ }
+
+ @Override
+ public void visit(In obj) {
+ List<Expression> exprs = obj.getRightExpressions();
+
+ Class expectedType = obj.getLeftExpression().getType();
+
+ boolean decompose = false;
+ for (Expression expr:exprs) {
+ if (!(expr.getType().equals(expectedType)) || (!(expr.getType().isAssignableFrom(Number.class)) && !expr.getType().isAssignableFrom(String.class))) {
+ decompose = true;
+ }
+ }
+
+ if (decompose) {
+ Comparison.Operator opCode = obj.isNegated()?Comparison.Operator.NE:Comparison.Operator.EQ;
+ if (exprs.size() > 1) {
+ Condition left = LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0));
+ for (int i = 1; i < exprs.size(); i++) {
+ AndOr replace = LanguageFactory.INSTANCE.createAndOr(obj.isNegated()?Operator.AND:Operator.OR, left, LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(i)));
+ left = replace;
+ }
+ super.visit((AndOr)left);
+ }
+ else {
+ super.visit(LanguageFactory.INSTANCE.createCompareCriteria(opCode, obj.getLeftExpression(), exprs.get(0)));
+ }
+ }
+ else {
+ super.visit(obj);
+ }
+ }
+}
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/main/resources/META-INF/jboss-beans.xml 2011-09-13 22:58:22 UTC (rev 3474)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- TERADATA -->
+ <bean name="translator-teradata-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-teradata" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-teradata" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.jdbc.teradata.TeradataExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-teradata</parameter>
+ <parameter class="java.lang.String">teradata</parameter>
+ </constructor>
+ </bean>
+</deployment>
Added: branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
--- branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java (rev 0)
+++ branches/7.1.x/connectors/sandbox/translator-teradata/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-09-13 22:58:22 UTC (rev 3474)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+@SuppressWarnings("nls")
+public class TestTeradataTranslator {
+
+ private static TeradataExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new TeradataExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert",
+ Arrays.asList( srcExpression,LANG_FACTORY.createLiteral(tgtType, String.class)),TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
+ expectedExpression, helpGetString(func));
+ }
+
+ public String helpGetString(Expression expr) throws Exception {
+ SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ @Test public void testSubstring1() throws Exception {
+ String input = "SELECT dayofmonth(datevalue) FROM BQT1.SMALLA";
+ String output = "SELECT extract(DAY from SmallA.DateValue) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testTimestampToTime() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(111, 4, 5, 9, 16, 34, 220000000), Timestamp.class), "time", "cast(cast('2011-05-05 09:16:34.22' AS TIMESTAMP(6)) AS TIME)");
+ }
+
+ @Test public void testIntegerToString() throws Exception {
+ String input = "SELECT lcase(bigdecimalvalue) FROM BQT1.SMALLA";
+ String output = "SELECT LOWER(cast(SmallA.BigDecimalValue AS varchar(100))) FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testSubString() throws Exception {
+ String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1) = '1' ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1) = '1' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testSubString2() throws Exception {
+ String input = "SELECT intkey FROM BQT1.SmallA WHERE SUBSTRING(BQT1.SmallA.IntKey, 1, 2) = '1' ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE substr(cast(SmallA.IntKey AS varchar(100)),1,2) = '1' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testDateToString() throws Exception {
+ String input = "SELECT intkey, UPPER(timevalue) AS UPPER FROM BQT1.SmallA ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, UPPER(cast(cast(SmallA.TimeValue AS FORMAT 'HH:MI:SS') AS VARCHAR(9))) AS UPPER FROM SmallA ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate() throws Exception {
+ String input = "SELECT INTKEY, BIGDECIMALVALUE FROM BQT1.SmallA WHERE LOCATE('-', BIGDECIMALVALUE) = 1 ORDER BY intkey";
+ String output = "SELECT SmallA.IntKey, SmallA.BigDecimalValue FROM SmallA WHERE position('-' in cast(SmallA.BigDecimalValue AS varchar(100))) = 1 ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+
+ @Test public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ @Test public void testByte2ToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)-1), Byte.class), "string", "cast(-1 AS varchar(4000))");
+ }
+
+ @Test public void testDoubleToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class), "string", "cast(1.0 AS varchar(4000))");
+ }
+
+ @Test public void testStringToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("1.0", String.class), "double", "cast('1.0' AS double precision)");
+ }
+
+ @Test public void testInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2', '3')", helpGetString(expr));
+ }
+
+ @Test public void testSingleInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2')", helpGetString(expr));
+ }
+
+ @Test public void testInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func() OR '1' = '3'", helpGetString(expr));
+ }
+
+ @Test public void testNegatedInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, true);
+
+ assertEquals("'1' <> func() AND '1' <> '3'", helpGetString(expr));
+ }
+
+ @Test public void testsingleInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func()", helpGetString(expr));
+ }
+
+ /* only 7.4
+ @Test public void testNullComapreNull() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM bqt1.smalla WHERE NULL <> NULL";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.DoubleNum FROM SmallA WHERE 1 = 0";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+ @Test public void testPushDownFunction() throws Exception {
+ String input = "SELECT teradata.HASHBAKAMP(STRINGKEY) DOUBLENUM FROM bqt1.smalla";
+ String out = "SELECT HASHBAKAMP(SmallA.StringKey) AS DOUBLENUM FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+ */
+
+ @Test public void testRightFunction() throws Exception {
+ String input = "SELECT INTKEY, FLOATNUM FROM BQT1.SmallA WHERE right(FLOATNUM, 2) <> 0 ORDER BY INTKEY";
+ String out = "SELECT SmallA.IntKey, SmallA.FloatNum FROM SmallA WHERE substr(cast(SmallA.FloatNum AS varchar(100)),(character_length(cast(SmallA.FloatNum AS varchar(100)))-2+1)) <> '0' ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+
+ @Test public void testLocateFunction() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, SHORTVALUE FROM BQT1.SmallA WHERE (LOCATE(0, STRINGKEY) = 2) OR (LOCATE(2, SHORTVALUE, 4) = 6) ORDER BY intkey";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.ShortValue FROM SmallA WHERE position('0' in SmallA.StringKey) = 2 OR position('2' in substr(cast(SmallA.ShortValue AS varchar(100)),4)) = 6 ORDER BY SmallA.IntKey";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, TRANSLATOR);
+ }
+}
13 years, 7 months
teiid SVN: r3473 - in branches/7.1.x/runtime/src/main/java/org/teiid: transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:57:41 -0400 (Tue, 13 Sep 2011)
New Revision: 3473
Modified:
branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
Log:
TEIID-1631 : ODBC SQLDescribeCol was not working when used with Prepare Statement
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-09-13 22:57:30 UTC (rev 3472)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-09-13 22:57:41 UTC (rev 3473)
@@ -462,7 +462,12 @@
}
else {
try {
+ // The response is a ParameterDescription message describing the parameters needed by the statement,
this.client.sendParameterDescription(query.stmt.getParameterMetaData(), query.paramType);
+
+ // followed by a RowDescription message describing the rows that will be returned when the statement
+ // is eventually executed (or a NoData message if the statement will not return rows).
+ this.client.sendResultSetDescription(query.stmt.getMetaData(), query.stmt);
} catch (SQLException e) {
this.client.errorOccurred(e);
}
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-09-13 22:57:30 UTC (rev 3472)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-09-13 22:57:41 UTC (rev 3473)
@@ -214,7 +214,7 @@
if (paramType != null && paramType[i] != 0) {
type = paramType[i];
} else {
- type = PG_TYPE_VARCHAR;
+ type = convertType(meta.getParameterType(i+1));
}
writeInt(type);
}
13 years, 7 months
teiid SVN: r3472 - branches/7.1.x/test-integration/common/src/test/resources/TestODBCSchema.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:57:30 -0400 (Tue, 13 Sep 2011)
New Revision: 3472
Modified:
branches/7.1.x/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
Log:
TEIID-1623 - Resolves issue with ODBC precision and scale data for numeric and string types. Fixed Unit Test
Modified: branches/7.1.x/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
===================================================================
--- branches/7.1.x/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2011-09-13 22:57:20 UTC (rev 3471)
+++ branches/7.1.x/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2011-09-13 22:57:30 UTC (rev 3472)
@@ -1,247 +1,247 @@
integer integer string integer short short integer boolean boolean boolean
oid attrelid attname atttypid attlen attnum atttypmod attnotnull attisdropped atthasdef
-1 1 PART_ID 1043 -1 1 4 true false false
-2 1 PART_NAME 1043 -1 2 255 false false false
-3 1 PART_COLOR 1043 -1 3 30 false false false
-4 1 PART_WEIGHT 1043 -1 4 255 false false false
-5 2 SHIPPER_ID 21 2 1 0 true false false
-6 2 SHIPPER_NAME 1043 -1 2 30 false false false
-7 3 STATUS_ID 21 2 1 0 true false false
-8 3 STATUS_NAME 1043 -1 2 30 false false false
-9 4 SUPPLIER_ID 1043 -1 1 10 true false false
-10 4 PART_ID 1043 -1 2 4 true false false
-11 4 QUANTITY 21 2 3 0 false false false
-12 4 SHIPPER_ID 21 2 4 0 false false false
-13 5 SUPPLIER_ID 1043 -1 1 10 true false false
-14 5 SUPPLIER_NAME 1043 -1 2 30 false false false
-15 5 SUPPLIER_STATUS 21 2 3 0 false false false
-16 5 SUPPLIER_CITY 1043 -1 4 30 false false false
-17 5 SUPPLIER_STATE 1043 -1 5 2 false false false
-18 6 VDBName 1043 -1 1 255 true false false
-19 6 SchemaName 1043 -1 2 255 true false false
-20 6 Name 1043 -1 3 255 true false false
-21 6 TargetSchemaName 1043 -1 4 255 false false false
-22 6 TargetName 1043 -1 5 4000 false false false
-23 6 Valid 16 1 6 0 false false false
-24 6 LoadState 1043 -1 7 255 false false false
-25 6 Updated 1114 8 8 0 false false false
-26 6 Cardinality 23 4 9 10 false false false
-27 7 resourcePath 1043 -1 1 255 false false false
-28 7 contents 14939 -1 2 0 false false false
-29 8 VDBName 1043 -1 1 255 true false false
-30 8 SchemaName 1043 -1 2 255 false false false
-31 8 TableName 1043 -1 3 255 true false false
-32 8 Name 1043 -1 4 255 true false false
-33 8 Position 23 4 5 10 true false false
-34 8 NameInSource 1043 -1 6 255 false false false
-35 8 DataType 1043 -1 7 100 true false false
-36 8 Scale 23 4 8 10 true false false
-37 8 Length 23 4 9 10 true false false
-38 8 IsLengthFixed 16 1 10 1 true false false
-39 8 SupportsSelect 16 1 11 1 true false false
-40 8 SupportsUpdates 16 1 12 1 true false false
-41 8 IsCaseSensitive 16 1 13 1 true false false
-42 8 IsSigned 16 1 14 1 true false false
-43 8 IsCurrency 16 1 15 1 true false false
-44 8 IsAutoIncremented 16 1 16 1 true false false
-45 8 NullType 1043 -1 17 20 true false false
-46 8 MinRange 1043 -1 18 50 false false false
-47 8 MaxRange 1043 -1 19 50 false false false
-48 8 SearchType 1043 -1 20 20 true false false
-49 8 Format 1043 -1 21 255 false false false
-50 8 DefaultValue 1043 -1 22 255 false false false
-51 8 JavaClass 1043 -1 23 500 true false false
-52 8 Precision 23 4 24 10 true false false
-53 8 CharOctetLength 23 4 25 10 false false false
-54 8 Radix 23 4 26 10 true false false
-55 8 UID 1043 -1 27 50 true false false
-56 8 Description 1043 -1 28 255 false false false
-57 8 OID 23 4 29 10 true false false
-58 9 Name 1043 -1 1 100 true false false
-59 9 IsStandard 16 1 2 1 false false false
-60 9 IsPhysical 16 1 3 1 false false false
-61 9 TypeName 1043 -1 4 100 true false false
-62 9 JavaClass 1043 -1 5 500 true false false
-63 9 Scale 23 4 6 10 false false false
-64 9 TypeLength 23 4 7 10 true false false
-65 9 NullType 1043 -1 8 20 true false false
-66 9 IsSigned 16 1 9 1 true false false
-67 9 IsAutoIncremented 16 1 10 1 true false false
-68 9 IsCaseSensitive 16 1 11 1 true false false
-69 9 Precision 23 4 12 10 true false false
-70 9 Radix 23 4 13 10 false false false
-71 9 SearchType 1043 -1 14 20 true false false
-72 9 UID 1043 -1 15 50 true false false
-73 9 RuntimeType 1043 -1 16 64 false false false
-74 9 BaseType 1043 -1 17 64 false false false
-75 9 Description 1043 -1 18 255 false false false
-76 9 OID 23 4 19 10 true false false
-77 10 VDBName 1043 -1 1 255 true false false
-78 10 SchemaName 1043 -1 2 255 false false false
-79 10 TableName 1043 -1 3 2048 true false false
-80 10 Name 1043 -1 4 255 true false false
-81 10 KeyName 1043 -1 5 255 false false false
-82 10 KeyType 1043 -1 6 20 true false false
-83 10 RefKeyUID 1043 -1 7 50 false false false
-84 10 UID 1043 -1 8 50 true false false
-85 10 Position 23 4 9 10 false false false
-86 10 OID 23 4 10 10 true false false
-87 11 VDBName 1043 -1 1 255 true false false
-88 11 SchemaName 1043 -1 2 255 false false false
-89 11 TableName 1043 -1 3 2048 true false false
-90 11 Name 1043 -1 4 255 true false false
-91 11 Description 1043 -1 5 255 false false false
-92 11 NameInSource 1043 -1 6 255 false false false
-93 11 Type 1043 -1 7 20 true false false
-94 11 IsIndexed 16 1 8 1 true false false
-95 11 RefKeyUID 1043 -1 9 50 false false false
-96 11 UID 1043 -1 10 50 true false false
-97 11 OID 23 4 11 10 true false false
-98 12 VDBName 1043 -1 1 255 true false false
-99 12 SchemaName 1043 -1 2 255 false false false
-100 12 ProcedureName 1043 -1 3 255 true false false
-101 12 Name 1043 -1 4 255 true false false
-102 12 DataType 1043 -1 5 25 true false false
-103 12 Position 23 4 6 10 true false false
-104 12 Type 1043 -1 7 100 true false false
-105 12 Optional 16 1 8 1 true false false
-106 12 Precision 23 4 9 10 true false false
-107 12 TypeLength 23 4 10 10 true false false
-108 12 Scale 23 4 11 10 true false false
-109 12 Radix 23 4 12 10 true false false
-110 12 NullType 1043 -1 13 10 true false false
-111 12 UID 1043 -1 14 50 false false false
-112 12 Description 1043 -1 15 255 false false false
-113 12 OID 23 4 16 10 true false false
-114 13 VDBName 1043 -1 1 255 true false false
-115 13 SchemaName 1043 -1 2 255 false false false
-116 13 Name 1043 -1 3 255 true false false
-117 13 NameInSource 1043 -1 4 255 false false false
-118 13 ReturnsResults 16 1 5 1 true false false
-119 13 UID 1043 -1 6 50 true false false
-120 13 Description 1043 -1 7 255 false false false
-121 13 OID 23 4 8 10 true false false
-122 14 Name 1043 -1 1 255 true false false
-123 14 Value 1043 -1 2 255 true false false
-124 14 UID 1043 -1 3 50 true false false
-125 14 OID 23 4 4 10 true false false
-126 15 PKTABLE_CAT 1043 -1 1 255 false false false
-127 15 PKTABLE_SCHEM 1043 -1 2 255 false false false
-128 15 PKTABLE_NAME 1043 -1 3 255 false false false
-129 15 PKCOLUMN_NAME 1043 -1 4 255 false false false
-130 15 FKTABLE_CAT 1043 -1 5 255 false false false
-131 15 FKTABLE_SCHEM 1043 -1 6 255 false false false
-132 15 FKTABLE_NAME 1043 -1 7 255 false false false
-133 15 FKCOLUMN_NAME 1043 -1 8 255 false false false
-134 15 KEY_SEQ 21 2 9 5 false false false
-135 15 UPDATE_RULE 23 4 10 10 false false false
-136 15 DELETE_RULE 23 4 11 10 false false false
-137 15 FK_NAME 1043 -1 12 255 false false false
-138 15 PK_NAME 1043 -1 13 255 false false false
-139 15 DEFERRABILITY 23 4 14 10 false false false
-140 16 VDBName 1043 -1 1 255 false false false
-141 16 Name 1043 -1 2 255 false false false
-142 16 IsPhysical 16 1 3 1 true false false
-143 16 UID 1043 -1 4 50 true false false
-144 16 Description 1043 -1 5 255 false false false
-145 16 PrimaryMetamodelURI 1043 -1 6 255 true false false
-146 16 OID 23 4 7 10 true false false
-147 17 VDBName 1043 -1 1 255 false false false
-148 17 SchemaName 1043 -1 2 255 false false false
-149 17 Name 1043 -1 3 255 true false false
-150 17 Type 1043 -1 4 20 true false false
-151 17 NameInSource 1043 -1 5 255 false false false
-152 17 IsPhysical 16 1 6 1 true false false
-153 17 SupportsUpdates 16 1 7 1 true false false
-154 17 UID 1043 -1 8 50 true false false
-155 17 Cardinality 23 4 9 10 true false false
-156 17 Description 1043 -1 10 255 false false false
-157 17 IsSystem 16 1 11 1 false false false
-158 17 IsMaterialized 16 1 12 0 true false false
-159 17 OID 23 4 13 10 true false false
-160 18 Name 1043 -1 1 255 true false false
-161 18 Version 1043 -1 2 50 true false false
-162 19 oid 23 4 1 0 false false false
-163 19 nspname 1043 -1 2 0 false false false
-164 20 oid 23 4 1 0 false false false
-165 20 relname 1043 -1 2 0 false false false
-166 20 relnamespace 23 4 3 0 false false false
-167 20 relkind 1042 1 4 0 false false false
-168 20 relam 23 4 5 0 false false false
-169 20 reltuples 700 4 6 0 false false false
-170 20 relpages 23 4 7 0 false false false
-171 20 relhasrules 16 1 8 0 false false false
-172 20 relhasoids 1043 -1 9 0 false false false
-173 21 oid 23 4 1 0 false false false
-174 21 attrelid 23 4 2 0 false false false
-175 21 attname 1043 -1 3 0 false false false
-176 21 atttypid 23 4 4 0 false false false
-177 21 attlen 21 2 5 0 false false false
-178 21 attnum 21 2 6 0 false false false
-179 21 atttypmod 23 4 7 0 false false false
-180 21 attnotnull 16 1 8 0 false false false
-181 21 attisdropped 16 1 9 0 false false false
-182 21 atthasdef 16 1 10 0 false false false
-183 22 oid 23 4 1 0 false false false
-184 22 typname 1043 -1 2 0 false false false
-185 22 typnamespace 23 4 3 0 false false false
-186 22 typlen 21 2 4 0 false false false
-187 22 typtype 1042 1 5 0 false false false
-188 22 typbasetype 23 4 6 0 false false false
-189 22 typtypmod 23 4 7 0 false false false
-190 22 typrelid 23 4 8 0 false false false
-191 23 oid 23 4 1 0 false false false
-192 23 indexrelid 23 4 2 0 false false false
-193 23 indrelid 23 4 3 0 false false false
-194 23 indisclustered 16 1 4 0 false false false
-195 23 indisunique 16 1 5 0 false false false
-196 23 indisprimary 16 1 6 0 false false false
-197 23 indexprs 1043 -1 7 0 false false false
-198 23 indkey 1043 -1 8 0 false false false
-199 24 oid 23 4 1 0 false false false
-200 24 amname 1043 -1 2 0 false false false
-201 25 oid 23 4 1 0 false false false
-202 25 proname 1043 -1 2 0 false false false
-203 25 proretset 16 1 3 0 false false false
-204 25 prorettype 23 4 4 0 false false false
-205 25 pronargs 21 2 5 0 false false false
-206 25 proargtypes <null> <null> 6 0 false false false
-207 25 proargnames <null> <null> 7 0 false false false
-208 25 proargmodes <null> <null> 8 0 false false false
-209 25 proallargtypes <null> <null> 9 0 false false false
-210 25 pronamespace 23 4 10 0 false false false
-211 26 oid 23 4 1 0 false false false
-212 26 tgconstrrelid 23 4 2 0 false false false
-213 26 tgfoid 23 4 3 0 false false false
-214 26 tgargs 23 4 4 0 false false false
-215 26 tgnargs 23 4 5 0 false false false
-216 26 tgdeferrable 16 1 6 0 false false false
-217 26 tginitdeferred 16 1 7 0 false false false
-218 26 tgconstrname 1043 -1 8 0 false false false
-219 26 tgrelid 23 4 9 0 false false false
-220 27 adrelid 23 4 1 0 false false false
-221 27 adnum 23 4 2 0 false false false
-222 27 adbin 1043 -1 3 0 false false false
-223 27 adsrc 1043 -1 4 0 false false false
-224 28 oid 23 4 1 0 false false false
-225 28 datname 1043 -1 2 0 false false false
-226 28 encoding 23 4 3 0 false false false
-227 28 datlastsysoid 23 4 4 0 false false false
-228 28 datallowconn 1042 1 5 0 false false false
-229 28 datconfig <null> <null> 6 0 false false false
-230 28 datacl <null> <null> 7 0 false false false
-231 28 datdba 23 4 8 0 false false false
-232 28 dattablespace 23 4 9 0 false false false
-233 29 oid 23 4 1 0 false false false
-234 29 usename 1043 -1 2 0 false false false
-235 29 usecreatedb 16 1 3 0 false false false
-236 29 usesuper 16 1 4 0 false false false
-237 30 attrelid 23 4 1 0 false false false
-238 30 attnum 21 2 2 0 false false false
-239 30 attname 1043 -1 3 0 false false false
-240 30 relname 1043 -1 4 0 false false false
-241 30 nspname 1043 -1 5 0 false false false
-242 30 autoinc 16 1 6 0 false false false
+1 1 PART_ID 1043 -1 1 8 true false false
+2 1 PART_NAME 1043 -1 2 259 false false false
+3 1 PART_COLOR 1043 -1 3 34 false false false
+4 1 PART_WEIGHT 1043 -1 4 259 false false false
+5 2 SHIPPER_ID 21 2 1 4 true false false
+6 2 SHIPPER_NAME 1043 -1 2 34 false false false
+7 3 STATUS_ID 21 2 1 4 true false false
+8 3 STATUS_NAME 1043 -1 2 34 false false false
+9 4 SUPPLIER_ID 1043 -1 1 14 true false false
+10 4 PART_ID 1043 -1 2 8 true false false
+11 4 QUANTITY 21 2 3 4 false false false
+12 4 SHIPPER_ID 21 2 4 4 false false false
+13 5 SUPPLIER_ID 1043 -1 1 14 true false false
+14 5 SUPPLIER_NAME 1043 -1 2 34 false false false
+15 5 SUPPLIER_STATUS 21 2 3 4 false false false
+16 5 SUPPLIER_CITY 1043 -1 4 34 false false false
+17 5 SUPPLIER_STATE 1043 -1 5 6 false false false
+18 6 VDBName 1043 -1 1 259 true false false
+19 6 SchemaName 1043 -1 2 259 true false false
+20 6 Name 1043 -1 3 259 true false false
+21 6 TargetSchemaName 1043 -1 4 259 false false false
+22 6 TargetName 1043 -1 5 4004 false false false
+23 6 Valid 16 1 6 4 false false false
+24 6 LoadState 1043 -1 7 259 false false false
+25 6 Updated 1114 8 8 4 false false false
+26 6 Cardinality 23 4 9 14 false false false
+27 7 resourcePath 1043 -1 1 259 false false false
+28 7 contents 14939 -1 2 4 false false false
+29 8 VDBName 1043 -1 1 259 true false false
+30 8 SchemaName 1043 -1 2 259 false false false
+31 8 TableName 1043 -1 3 259 true false false
+32 8 Name 1043 -1 4 259 true false false
+33 8 Position 23 4 5 14 true false false
+34 8 NameInSource 1043 -1 6 259 false false false
+35 8 DataType 1043 -1 7 104 true false false
+36 8 Scale 23 4 8 14 true false false
+37 8 Length 23 4 9 14 true false false
+38 8 IsLengthFixed 16 1 10 5 true false false
+39 8 SupportsSelect 16 1 11 5 true false false
+40 8 SupportsUpdates 16 1 12 5 true false false
+41 8 IsCaseSensitive 16 1 13 5 true false false
+42 8 IsSigned 16 1 14 5 true false false
+43 8 IsCurrency 16 1 15 5 true false false
+44 8 IsAutoIncremented 16 1 16 5 true false false
+45 8 NullType 1043 -1 17 24 true false false
+46 8 MinRange 1043 -1 18 54 false false false
+47 8 MaxRange 1043 -1 19 54 false false false
+48 8 SearchType 1043 -1 20 24 true false false
+49 8 Format 1043 -1 21 259 false false false
+50 8 DefaultValue 1043 -1 22 259 false false false
+51 8 JavaClass 1043 -1 23 504 true false false
+52 8 Precision 23 4 24 14 true false false
+53 8 CharOctetLength 23 4 25 14 false false false
+54 8 Radix 23 4 26 14 true false false
+55 8 UID 1043 -1 27 54 true false false
+56 8 Description 1043 -1 28 259 false false false
+57 8 OID 23 4 29 14 true false false
+58 9 Name 1043 -1 1 104 true false false
+59 9 IsStandard 16 1 2 5 false false false
+60 9 IsPhysical 16 1 3 5 false false false
+61 9 TypeName 1043 -1 4 104 true false false
+62 9 JavaClass 1043 -1 5 504 true false false
+63 9 Scale 23 4 6 14 false false false
+64 9 TypeLength 23 4 7 14 true false false
+65 9 NullType 1043 -1 8 24 true false false
+66 9 IsSigned 16 1 9 5 true false false
+67 9 IsAutoIncremented 16 1 10 5 true false false
+68 9 IsCaseSensitive 16 1 11 5 true false false
+69 9 Precision 23 4 12 14 true false false
+70 9 Radix 23 4 13 14 false false false
+71 9 SearchType 1043 -1 14 24 true false false
+72 9 UID 1043 -1 15 54 true false false
+73 9 RuntimeType 1043 -1 16 68 false false false
+74 9 BaseType 1043 -1 17 68 false false false
+75 9 Description 1043 -1 18 259 false false false
+76 9 OID 23 4 19 14 true false false
+77 10 VDBName 1043 -1 1 259 true false false
+78 10 SchemaName 1043 -1 2 259 false false false
+79 10 TableName 1043 -1 3 2052 true false false
+80 10 Name 1043 -1 4 259 true false false
+81 10 KeyName 1043 -1 5 259 false false false
+82 10 KeyType 1043 -1 6 24 true false false
+83 10 RefKeyUID 1043 -1 7 54 false false false
+84 10 UID 1043 -1 8 54 true false false
+85 10 Position 23 4 9 14 false false false
+86 10 OID 23 4 10 14 true false false
+87 11 VDBName 1043 -1 1 259 true false false
+88 11 SchemaName 1043 -1 2 259 false false false
+89 11 TableName 1043 -1 3 2052 true false false
+90 11 Name 1043 -1 4 259 true false false
+91 11 Description 1043 -1 5 259 false false false
+92 11 NameInSource 1043 -1 6 259 false false false
+93 11 Type 1043 -1 7 24 true false false
+94 11 IsIndexed 16 1 8 5 true false false
+95 11 RefKeyUID 1043 -1 9 54 false false false
+96 11 UID 1043 -1 10 54 true false false
+97 11 OID 23 4 11 14 true false false
+98 12 VDBName 1043 -1 1 259 true false false
+99 12 SchemaName 1043 -1 2 259 false false false
+100 12 ProcedureName 1043 -1 3 259 true false false
+101 12 Name 1043 -1 4 259 true false false
+102 12 DataType 1043 -1 5 29 true false false
+103 12 Position 23 4 6 14 true false false
+104 12 Type 1043 -1 7 104 true false false
+105 12 Optional 16 1 8 5 true false false
+106 12 Precision 23 4 9 14 true false false
+107 12 TypeLength 23 4 10 14 true false false
+108 12 Scale 23 4 11 14 true false false
+109 12 Radix 23 4 12 14 true false false
+110 12 NullType 1043 -1 13 14 true false false
+111 12 UID 1043 -1 14 54 false false false
+112 12 Description 1043 -1 15 259 false false false
+113 12 OID 23 4 16 14 true false false
+114 13 VDBName 1043 -1 1 259 true false false
+115 13 SchemaName 1043 -1 2 259 false false false
+116 13 Name 1043 -1 3 259 true false false
+117 13 NameInSource 1043 -1 4 259 false false false
+118 13 ReturnsResults 16 1 5 5 true false false
+119 13 UID 1043 -1 6 54 true false false
+120 13 Description 1043 -1 7 259 false false false
+121 13 OID 23 4 8 14 true false false
+122 14 Name 1043 -1 1 259 true false false
+123 14 Value 1043 -1 2 259 true false false
+124 14 UID 1043 -1 3 54 true false false
+125 14 OID 23 4 4 14 true false false
+126 15 PKTABLE_CAT 1043 -1 1 259 false false false
+127 15 PKTABLE_SCHEM 1043 -1 2 259 false false false
+128 15 PKTABLE_NAME 1043 -1 3 259 false false false
+129 15 PKCOLUMN_NAME 1043 -1 4 259 false false false
+130 15 FKTABLE_CAT 1043 -1 5 259 false false false
+131 15 FKTABLE_SCHEM 1043 -1 6 259 false false false
+132 15 FKTABLE_NAME 1043 -1 7 259 false false false
+133 15 FKCOLUMN_NAME 1043 -1 8 259 false false false
+134 15 KEY_SEQ 21 2 9 9 false false false
+135 15 UPDATE_RULE 23 4 10 14 false false false
+136 15 DELETE_RULE 23 4 11 14 false false false
+137 15 FK_NAME 1043 -1 12 259 false false false
+138 15 PK_NAME 1043 -1 13 259 false false false
+139 15 DEFERRABILITY 23 4 14 14 false false false
+140 16 VDBName 1043 -1 1 259 false false false
+141 16 Name 1043 -1 2 259 false false false
+142 16 IsPhysical 16 1 3 5 true false false
+143 16 UID 1043 -1 4 54 true false false
+144 16 Description 1043 -1 5 259 false false false
+145 16 PrimaryMetamodelURI 1043 -1 6 259 true false false
+146 16 OID 23 4 7 14 true false false
+147 17 VDBName 1043 -1 1 259 false false false
+148 17 SchemaName 1043 -1 2 259 false false false
+149 17 Name 1043 -1 3 259 true false false
+150 17 Type 1043 -1 4 24 true false false
+151 17 NameInSource 1043 -1 5 259 false false false
+152 17 IsPhysical 16 1 6 5 true false false
+153 17 SupportsUpdates 16 1 7 5 true false false
+154 17 UID 1043 -1 8 54 true false false
+155 17 Cardinality 23 4 9 14 true false false
+156 17 Description 1043 -1 10 259 false false false
+157 17 IsSystem 16 1 11 5 false false false
+158 17 IsMaterialized 16 1 12 4 true false false
+159 17 OID 23 4 13 14 true false false
+160 18 Name 1043 -1 1 259 true false false
+161 18 Version 1043 -1 2 54 true false false
+162 19 oid 23 4 1 4 false false false
+163 19 nspname 1043 -1 2 4 false false false
+164 20 oid 23 4 1 4 false false false
+165 20 relname 1043 -1 2 4 false false false
+166 20 relnamespace 23 4 3 4 false false false
+167 20 relkind 1042 1 4 4 false false false
+168 20 relam 23 4 5 4 false false false
+169 20 reltuples 700 4 6 4 false false false
+170 20 relpages 23 4 7 4 false false false
+171 20 relhasrules 16 1 8 4 false false false
+172 20 relhasoids 1043 -1 9 4 false false false
+173 21 oid 23 4 1 4 false false false
+174 21 attrelid 23 4 2 4 false false false
+175 21 attname 1043 -1 3 4 false false false
+176 21 atttypid 23 4 4 4 false false false
+177 21 attlen 21 2 5 4 false false false
+178 21 attnum 21 2 6 4 false false false
+179 21 atttypmod 23 4 7 4 false false false
+180 21 attnotnull 16 1 8 4 false false false
+181 21 attisdropped 16 1 9 4 false false false
+182 21 atthasdef 16 1 10 4 false false false
+183 22 oid 23 4 1 4 false false false
+184 22 typname 1043 -1 2 4 false false false
+185 22 typnamespace 23 4 3 4 false false false
+186 22 typlen 21 2 4 4 false false false
+187 22 typtype 1042 1 5 4 false false false
+188 22 typbasetype 23 4 6 4 false false false
+189 22 typtypmod 23 4 7 4 false false false
+190 22 typrelid 23 4 8 4 false false false
+191 23 oid 23 4 1 4 false false false
+192 23 indexrelid 23 4 2 4 false false false
+193 23 indrelid 23 4 3 4 false false false
+194 23 indisclustered 16 1 4 4 false false false
+195 23 indisunique 16 1 5 4 false false false
+196 23 indisprimary 16 1 6 4 false false false
+197 23 indexprs 1043 -1 7 4 false false false
+198 23 indkey 1043 -1 8 4 false false false
+199 24 oid 23 4 1 4 false false false
+200 24 amname 1043 -1 2 4 false false false
+201 25 oid 23 4 1 4 false false false
+202 25 proname 1043 -1 2 4 false false false
+203 25 proretset 16 1 3 4 false false false
+204 25 prorettype 23 4 4 4 false false false
+205 25 pronargs 21 2 5 4 false false false
+206 25 proargtypes <null> <null> 6 4 false false false
+207 25 proargnames <null> <null> 7 4 false false false
+208 25 proargmodes <null> <null> 8 4 false false false
+209 25 proallargtypes <null> <null> 9 4 false false false
+210 25 pronamespace 23 4 10 4 false false false
+211 26 oid 23 4 1 4 false false false
+212 26 tgconstrrelid 23 4 2 4 false false false
+213 26 tgfoid 23 4 3 4 false false false
+214 26 tgargs 23 4 4 4 false false false
+215 26 tgnargs 23 4 5 4 false false false
+216 26 tgdeferrable 16 1 6 4 false false false
+217 26 tginitdeferred 16 1 7 4 false false false
+218 26 tgconstrname 1043 -1 8 4 false false false
+219 26 tgrelid 23 4 9 4 false false false
+220 27 adrelid 23 4 1 4 false false false
+221 27 adnum 23 4 2 4 false false false
+222 27 adbin 1043 -1 3 4 false false false
+223 27 adsrc 1043 -1 4 4 false false false
+224 28 oid 23 4 1 4 false false false
+225 28 datname 1043 -1 2 4 false false false
+226 28 encoding 23 4 3 4 false false false
+227 28 datlastsysoid 23 4 4 4 false false false
+228 28 datallowconn 1042 1 5 4 false false false
+229 28 datconfig <null> <null> 6 4 false false false
+230 28 datacl <null> <null> 7 4 false false false
+231 28 datdba 23 4 8 4 false false false
+232 28 dattablespace 23 4 9 4 false false false
+233 29 oid 23 4 1 4 false false false
+234 29 usename 1043 -1 2 4 false false false
+235 29 usecreatedb 16 1 3 4 false false false
+236 29 usesuper 16 1 4 4 false false false
+237 30 attrelid 23 4 1 4 false false false
+238 30 attnum 21 2 2 4 false false false
+239 30 attname 1043 -1 3 4 false false false
+240 30 relname 1043 -1 4 4 false false false
+241 30 nspname 1043 -1 5 4 false false false
+242 30 autoinc 16 1 6 4 false false false
Row Count : 242
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_attribute 11 10 0 false false false false 2 true true false false
13 years, 7 months
teiid SVN: r3471 - in branches/7.1.x/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: loleary
Date: 2011-09-13 18:57:20 -0400 (Tue, 13 Sep 2011)
New Revision: 3471
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java
Log:
TEIID-1622 - Fixes issue with optimization of optional JOIN when used with UNION ALL
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2011-09-13 22:57:03 UTC (rev 3470)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2011-09-13 22:57:20 UTC (rev 3471)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@@ -50,6 +51,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
import org.teiid.query.util.CommandContext;
@@ -72,7 +74,7 @@
TeiidComponentException {
try {
- removeOptionalJoinNodes(plan, metadata, capFinder, null);
+ removeOptionalJoinNodes(plan, metadata, capFinder, null, null);
} catch (QueryResolverException e) {
throw new TeiidComponentException(e);
}
@@ -85,13 +87,22 @@
*/
private boolean removeOptionalJoinNodes(PlanNode node,
QueryMetadataInterface metadata,
- CapabilitiesFinder capFinder, Set<ElementSymbol> elements) throws QueryPlannerException,
+ CapabilitiesFinder capFinder, Set<ElementSymbol> elements, List<Integer> indexes) throws QueryPlannerException,
QueryMetadataException,
TeiidComponentException, QueryResolverException {
if (node.getChildCount() == 0) {
return false;
}
+ if (indexes != null && node.getParent() != null && node.getParent().getType() == NodeConstants.Types.SET_OP && node.getParent().getFirstChild() != node) {
+ elements = new HashSet<ElementSymbol>();
+ List columns = (List)node.getProperty(NodeConstants.Info.PROJECT_COLS);
+ for (int i : indexes) {
+ SingleElementSymbol column = (SingleElementSymbol) columns.get(i);
+ ElementCollectorVisitor.getElements(column, elements);
+ }
+ }
+
boolean isRoot = false;
switch (node.getType()) {
@@ -138,15 +149,21 @@
case NodeConstants.Types.SOURCE:
{
if (elements == null) {
+ indexes = null;
break;
}
SymbolMap symbolMap = (SymbolMap)node.getProperty(NodeConstants.Info.SYMBOL_MAP);
Set convertedElements = new HashSet();
+ indexes = new LinkedList<Integer>();
+ List<ElementSymbol> keys = symbolMap.getKeys();
+ List<Expression> values = symbolMap.getValues();
for (ElementSymbol element : elements) {
- Expression convertedExpression = symbolMap.getMappedExpression(element);
- if (convertedExpression != null) {
+ int index = keys.indexOf(element);
+ if (index >= 0) {
+ Expression convertedExpression = values.get(index);
+ indexes.add(index);
ElementCollectorVisitor.getElements(convertedExpression, convertedElements);
- }
+ }
}
elements = convertedElements;
isRoot = true;
@@ -170,6 +187,14 @@
break;
}
case NodeConstants.Types.SET_OP:
+ {
+ if (!node.hasBooleanProperty(NodeConstants.Info.USE_ALL)) {
+ //allow project nodes to be seen as roots
+ elements = null;
+ indexes = null;
+ }
+ break;
+ }
case NodeConstants.Types.DUP_REMOVE:
{
//allow project nodes to be seen as roots
@@ -182,7 +207,7 @@
if (isRoot) {
boolean optionalRemoved = false;
do {
- optionalRemoved = removeOptionalJoinNodes(node.getFirstChild(), metadata, capFinder, elements);
+ optionalRemoved = removeOptionalJoinNodes(node.getFirstChild(), metadata, capFinder, elements, indexes);
} while (optionalRemoved);
return false;
}
@@ -191,7 +216,7 @@
Iterator iter = node.getChildren().iterator();
while (node.getChildCount() >= 1 && iter.hasNext()) {
- if (removeOptionalJoinNodes((PlanNode)iter.next(), metadata, capFinder, elements)) {
+ if (removeOptionalJoinNodes((PlanNode)iter.next(), metadata, capFinder, elements, indexes)) {
return true;
}
}
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java 2011-09-13 22:57:03 UTC (rev 3470)
+++ branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java 2011-09-13 22:57:20 UTC (rev 3471)
@@ -311,7 +311,7 @@
}
/**
- * Union should prevent the removal from happening
+ * Union all should not prevent the removal from happening
*/
@Test public void testOptionalJoinWithUnion() {
ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g2.e4 from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1 union all select convert(pm1.g2.e2, double) from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
@@ -335,6 +335,31 @@
});
}
+ /**
+ * The first branch should have the join removed, but not the second branch
+ */
+ @Test public void testOptionalJoinWithUnion1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select e4 from (select e4, e2 from (select pm1.g2.e4, pm1.g1.e2 from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1) as x union all select e4, e2 from (select convert(pm2.g1.e2, double) as e4, pm2.g2.e2 from /* optional */ pm2.g1 inner join pm2.g2 on pm2.g1.e1 = pm2.g2.e1) as x) as y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g2.e4 FROM pm1.g2", "SELECT g_0.e2 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE g_0.e1 = g_1.e1"} ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
@Test public void testOptionalJoinWithCompoundCriteria() {
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y and concat(x.y, x.z) = '1'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] {"SELECT e3 FROM pm1.g1"} ); //$NON-NLS-1$
13 years, 7 months