teiid SVN: r3633 - in trunk: adminshell and 37 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-10 14:12:59 -0500 (Thu, 10 Nov 2011)
New Revision: 3633
Modified:
trunk/adminshell/pom.xml
trunk/api/pom.xml
trunk/build/pom.xml
trunk/cache-jbosscache/pom.xml
trunk/client-jdk15/pom.xml
trunk/client/pom.xml
trunk/common-core/pom.xml
trunk/connectors/connector-file/pom.xml
trunk/connectors/connector-ldap/pom.xml
trunk/connectors/connector-salesforce/pom.xml
trunk/connectors/connector-ws/pom.xml
trunk/connectors/pom.xml
trunk/connectors/salesforce-api/pom.xml
trunk/connectors/sandbox/pom.xml
trunk/connectors/sandbox/translator-yahoo/pom.xml
trunk/connectors/translator-file/pom.xml
trunk/connectors/translator-jdbc/pom.xml
trunk/connectors/translator-ldap/pom.xml
trunk/connectors/translator-loopback/pom.xml
trunk/connectors/translator-olap/pom.xml
trunk/connectors/translator-salesforce/pom.xml
trunk/connectors/translator-ws/pom.xml
trunk/console/pom.xml
trunk/documentation/admin-guide/pom.xml
trunk/documentation/caching-guide/pom.xml
trunk/documentation/client-developers-guide/pom.xml
trunk/documentation/developer-guide/pom.xml
trunk/documentation/pom.xml
trunk/documentation/quick-start-example/pom.xml
trunk/documentation/reference/pom.xml
trunk/engine/pom.xml
trunk/hibernate-dialect/pom.xml
trunk/jboss-integration/pom.xml
trunk/metadata/pom.xml
trunk/pom.xml
trunk/runtime/pom.xml
trunk/test-integration/common/pom.xml
trunk/test-integration/db/pom.xml
trunk/test-integration/pom.xml
Log:
[maven-release-plugin] prepare release teiid-parent-7.6.0.Beta2
Modified: trunk/adminshell/pom.xml
===================================================================
--- trunk/adminshell/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/adminshell/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-adminshell</artifactId>
Modified: trunk/api/pom.xml
===================================================================
--- trunk/api/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/api/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-api</artifactId>
Modified: trunk/build/pom.xml
===================================================================
--- trunk/build/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/build/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid</artifactId>
Modified: trunk/cache-jbosscache/pom.xml
===================================================================
--- trunk/cache-jbosscache/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/cache-jbosscache/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-cache-jbosscache</artifactId>
Modified: trunk/client/pom.xml
===================================================================
--- trunk/client/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/client/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client</artifactId>
Modified: trunk/client-jdk15/pom.xml
===================================================================
--- trunk/client-jdk15/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/client-jdk15/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-client-jdk15</artifactId>
Modified: trunk/common-core/pom.xml
===================================================================
--- trunk/common-core/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/common-core/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-common-core</artifactId>
Modified: trunk/connectors/connector-file/pom.xml
===================================================================
--- trunk/connectors/connector-file/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/connector-file/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-file</artifactId>
Modified: trunk/connectors/connector-ldap/pom.xml
===================================================================
--- trunk/connectors/connector-ldap/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/connector-ldap/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ldap</artifactId>
Modified: trunk/connectors/connector-salesforce/pom.xml
===================================================================
--- trunk/connectors/connector-salesforce/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/connector-salesforce/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-salesforce</artifactId>
Modified: trunk/connectors/connector-ws/pom.xml
===================================================================
--- trunk/connectors/connector-ws/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/connector-ws/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>connector-ws</artifactId>
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/connectors/salesforce-api/pom.xml
===================================================================
--- trunk/connectors/salesforce-api/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/salesforce-api/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>salesforce-api</artifactId>
Modified: trunk/connectors/sandbox/pom.xml
===================================================================
--- trunk/connectors/sandbox/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/sandbox/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid.connectors</groupId>
Modified: trunk/connectors/sandbox/translator-yahoo/pom.xml
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/sandbox/translator-yahoo/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>sandbox</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-yahoo</artifactId>
Modified: trunk/connectors/translator-file/pom.xml
===================================================================
--- trunk/connectors/translator-file/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-file/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-file</artifactId>
Modified: trunk/connectors/translator-jdbc/pom.xml
===================================================================
--- trunk/connectors/translator-jdbc/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-jdbc/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-jdbc</artifactId>
Modified: trunk/connectors/translator-ldap/pom.xml
===================================================================
--- trunk/connectors/translator-ldap/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-ldap/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ldap</artifactId>
Modified: trunk/connectors/translator-loopback/pom.xml
===================================================================
--- trunk/connectors/translator-loopback/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-loopback/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-loopback</artifactId>
Modified: trunk/connectors/translator-olap/pom.xml
===================================================================
--- trunk/connectors/translator-olap/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-olap/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-olap</artifactId>
Modified: trunk/connectors/translator-salesforce/pom.xml
===================================================================
--- trunk/connectors/translator-salesforce/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-salesforce/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-salesforce</artifactId>
Modified: trunk/connectors/translator-ws/pom.xml
===================================================================
--- trunk/connectors/translator-ws/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/connectors/translator-ws/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>connectors</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>translator-ws</artifactId>
Modified: trunk/console/pom.xml
===================================================================
--- trunk/console/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/console/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/documentation/admin-guide/pom.xml
===================================================================
--- trunk/documentation/admin-guide/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/admin-guide/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>admin-guide</artifactId>
Modified: trunk/documentation/caching-guide/pom.xml
===================================================================
--- trunk/documentation/caching-guide/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/caching-guide/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>caching-guide</artifactId>
Modified: trunk/documentation/client-developers-guide/pom.xml
===================================================================
--- trunk/documentation/client-developers-guide/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/client-developers-guide/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>client-developers-guide</artifactId>
Modified: trunk/documentation/developer-guide/pom.xml
===================================================================
--- trunk/documentation/developer-guide/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/developer-guide/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>developer-guide</artifactId>
Modified: trunk/documentation/pom.xml
===================================================================
--- trunk/documentation/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/documentation/quick-start-example/pom.xml
===================================================================
--- trunk/documentation/quick-start-example/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/quick-start-example/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>quick-start-example</artifactId>
Modified: trunk/documentation/reference/pom.xml
===================================================================
--- trunk/documentation/reference/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/documentation/reference/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<groupId>org.jboss.teiid</groupId>
<artifactId>documentation</artifactId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>reference</artifactId>
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/engine/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-engine</artifactId>
Modified: trunk/hibernate-dialect/pom.xml
===================================================================
--- trunk/hibernate-dialect/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/hibernate-dialect/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-hibernate-dialect</artifactId>
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/jboss-integration/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -2,7 +2,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/metadata/pom.xml
===================================================================
--- trunk/metadata/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/metadata/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-metadata</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -5,16 +5,16 @@
<artifactId>teiid-parent</artifactId>
<packaging>pom</packaging>
<name>Teiid</name>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
<description>Federated SQL and XML query engine.</description>
<properties>
<ant.version>1.7.0</ant.version>
<site.url>http://www.jboss.org/teiid</site.url>
</properties>
<scm>
- <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/trunk</developerConnection>
- <url>http://anonsvn.jboss.org/repos/teiid/trunk</url>
+ <connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/tags/teiid-parent-7.6.0.Beta2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/teiid/tags/teiid-parent-7.6.0.Beta2</developerConnection>
+ <url>http://anonsvn.jboss.org/repos/teiid/tags/teiid-parent-7.6.0.Beta2</url>
</scm>
<licenses>
<license>
Modified: trunk/runtime/pom.xml
===================================================================
--- trunk/runtime/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/runtime/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
Modified: trunk/test-integration/common/pom.xml
===================================================================
--- trunk/test-integration/common/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/test-integration/common/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-common</artifactId>
Modified: trunk/test-integration/db/pom.xml
===================================================================
--- trunk/test-integration/db/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/test-integration/db/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -9,7 +9,7 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2011-11-10 18:16:54 UTC (rev 3632)
+++ trunk/test-integration/pom.xml 2011-11-10 19:12:59 UTC (rev 3633)
@@ -3,7 +3,7 @@
<parent>
<artifactId>teiid-parent</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.6.0.Beta2-SNAPSHOT</version>
+ <version>7.6.0.Beta2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-test-integration</artifactId>
13 years, 1 month
teiid SVN: r3632 - in trunk: client/src/main/java/org/teiid/net and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-10 13:16:54 -0500 (Thu, 10 Nov 2011)
New Revision: 3632
Added:
trunk/client/src/main/java/org/teiid/net/socket/AuthenticationType.java
Modified:
trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
trunk/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
trunk/client/src/main/java/org/teiid/net/TeiidURL.java
trunk/client/src/main/java/org/teiid/net/socket/Handshake.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
Log:
TEIID-1610 removing the need for the client to set the auth type property
Modified: trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/jdbc/JDBCURL.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -74,7 +74,6 @@
TeiidURL.CONNECTION.AUTO_FAILOVER,
TeiidURL.CONNECTION.DISCOVERY_STRATEGY,
TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION,
- TeiidURL.CONNECTION.AUTHENTICATION_TYPE,
TeiidURL.CONNECTION.JAAS_NAME,
TeiidURL.CONNECTION.KERBEROS_SERVICE_PRINCIPLE_NAME));
props.addAll(EXECUTION_PROPERTIES);
Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -99,11 +99,6 @@
private boolean passthroughAuthentication = false;
/**
- * Authentication type to used from client. choices are simple - which is plain user/password; krb5 - kerberos
- */
- private String authenticationType;
-
- /**
* Name of the jass configuration to use from the -Djava.security.auth.login.config=login.conf property
*/
private String jaasName;
@@ -258,9 +253,6 @@
Properties props = buildProperties(userName, password);
props.setProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, Boolean.toString(this.passthroughAuthentication));
- if (getAuthenticationType() != null) {
- props.setProperty(TeiidURL.CONNECTION.AUTHENTICATION_TYPE, getAuthenticationType());
- }
if (getJaasName() != null) {
props.setProperty(TeiidURL.CONNECTION.JAAS_NAME, getJaasName());
}
@@ -492,24 +484,7 @@
this.passthroughAuthentication = passthroughAuthentication;
}
- /**
- * Authentication Type {simple, krb5} default:simple
- * @return
- */
- public String getAuthenticationType() {
- return authenticationType;
- }
-
/**
- * Authentication Type.
- * @since 7.6
- * @return
- */
- public void setAuthenticationType(final String authType) {
- this.authenticationType = authType;
- }
-
- /**
* Application name from JAAS Login Config file
* @since 7.6
* @return
Modified: trunk/client/src/main/java/org/teiid/net/TeiidURL.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/TeiidURL.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/net/TeiidURL.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -83,15 +83,9 @@
public static final String PASSTHROUGH_AUTHENTICATION = "PassthroughAuthentication"; //$NON-NLS-1$
- public static final String AUTHENTICATION_TYPE = "authenticationType"; //$NON-NLS-1$
-
public static final String JAAS_NAME = "jaasName"; //$NON-NLS-1$
- public static final String KERBEROS_SERVICE_PRINCIPLE_NAME = "kerberosServicePrincipleName"; //$NON-NLS-1$
-
- public enum AuthenticationType {
- CLEARTEXT,GSS
- };
+ public static final String KERBEROS_SERVICE_PRINCIPLE_NAME = "kerberosServicePrincipleName"; //$NON-NLS-1$;
}
public static final String DOT_DELIMITER = "."; //$NON-NLS-1$
Added: trunk/client/src/main/java/org/teiid/net/socket/AuthenticationType.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/AuthenticationType.java (rev 0)
+++ trunk/client/src/main/java/org/teiid/net/socket/AuthenticationType.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -0,0 +1,27 @@
+/*
+ * 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.net.socket;
+
+public enum AuthenticationType {
+ CLEARTEXT,GSS
+}
\ No newline at end of file
Property changes on: trunk/client/src/main/java/org/teiid/net/socket/AuthenticationType.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/client/src/main/java/org/teiid/net/socket/Handshake.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/Handshake.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/net/socket/Handshake.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -26,6 +26,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.OptionalDataException;
import org.teiid.core.util.ApplicationInfo;
@@ -39,6 +40,7 @@
private String version = ApplicationInfo.getInstance().getReleaseNumber();
private byte[] publicKey;
+ private AuthenticationType authType = AuthenticationType.CLEARTEXT;
/**
* @return Returns the version.
@@ -68,17 +70,31 @@
this.publicKey = key;
}
+ public AuthenticationType getAuthType() {
+ return authType;
+ }
+
+ public void setAuthType(AuthenticationType authType) {
+ this.authType = authType;
+ }
+
@Override
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
version = (String)in.readObject();
publicKey = (byte[])in.readObject();
+ try {
+ authType = AuthenticationType.values()[in.readByte()];
+ } catch (OptionalDataException e) {
+
+ }
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(version);
out.writeObject(publicKey);
+ out.writeByte(authType.ordinal());
}
}
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -56,7 +56,6 @@
import org.teiid.net.HostInfo;
import org.teiid.net.ServerConnection;
import org.teiid.net.TeiidURL;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
/**
@@ -172,7 +171,7 @@
SocketServerInstance instance = this.serverInstance;
LogonResult newResult = null;
- AuthenticationType authType = getAuthenticationType();
+ AuthenticationType authType = instance.getAuthenticationType();
if (AuthenticationType.CLEARTEXT.equals(authType)) {
newResult = newLogon.logon(connProps);
}
@@ -194,14 +193,6 @@
this.connectionFactory.connected(instance, this.logonResult.getSessionToken());
}
- private AuthenticationType getAuthenticationType() {
- String authStr = this.connProps.getProperty(TeiidURL.CONNECTION.AUTHENTICATION_TYPE);
- if (authStr == null) {
- return AuthenticationType.CLEARTEXT;
- }
- return AuthenticationType.valueOf(authStr);
- }
-
private ILogon connect(HostInfo hostInfo) throws CommunicationException,
IOException {
hostInfo.setSsl(secure);
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstance.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -53,4 +53,6 @@
String getServerVersion();
+ AuthenticationType getAuthenticationType();
+
}
\ No newline at end of file
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerInstanceImpl.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -76,6 +76,7 @@
private ObjectChannel socketChannel;
private Cryptor cryptor;
private String serverVersion;
+ private AuthenticationType authType = AuthenticationType.CLEARTEXT;
private boolean hasReader;
@@ -130,6 +131,7 @@
throw new CommunicationException(NetPlugin.Util.getString("SocketServerInstanceImpl.version_mismatch", getVersionInfo(), handshake.getVersion())); //$NON-NLS-1$
}*/
serverVersion = handshake.getVersion();
+ authType = handshake.getAuthType();
handshake.setVersion();
byte[] serverPublicKey = handshake.getPublicKey();
@@ -369,4 +371,9 @@
}
+ @Override
+ public AuthenticationType getAuthenticationType() {
+ return authType;
+ }
+
}
\ No newline at end of file
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -138,7 +138,7 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb@mm://localhost:12345;applicationName=x", null); //$NON-NLS-1$
- assertEquals(24, info.length);
+ assertEquals(23, info.length);
assertEquals(false, info[0].required);
assertEquals("ApplicationName", info[0].name); //$NON-NLS-1$
assertEquals("x", info[0].value); //$NON-NLS-1$
Modified: trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java
===================================================================
--- trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/client/src/test/java/org/teiid/net/socket/TestSocketServerConnection.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -213,6 +213,7 @@
Mockito.stub(instance.getHostInfo()).toReturn(hostInfo);
Mockito.stub(instance.getService(ILogon.class)).toReturn(logon);
Mockito.stub(instance.getServerVersion()).toReturn("7.3");
+ Mockito.stub(instance.getAuthenticationType()).toReturn(AuthenticationType.CLEARTEXT);
if (t != null) {
try {
Mockito.doAnswer(new Answer<Void>() {
Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-connection.xml 2011-11-10 18:16:54 UTC (rev 3632)
@@ -258,27 +258,14 @@
</row>
<row>
<entry>
- <code>authenticationType</code>
- </entry>
- <entry>
- <code>String</code>
- </entry>
- <entry>
- <para>Type of authentication to use. Valid values are CLEARTEXT (default) and KRB5 (kerberos). See
- Admin Guide for configuration required for kerberos
- </para>
- </entry>
- </row>
- <row>
- <entry>
<code>jaasName</code>
</entry>
<entry>
<code>String</code>
</entry>
<entry>
- <para>JAAS configuration name. Only applies when configuring a kerberos authentication.
- See Admin Guide for configuration required for kerberos</para>
+ <para>JAAS configuration name. Only applies when configuring a GSS authentication.
+ See the Admin Guide for configuration required for GSS.</para>
</entry>
</row>
<row>
@@ -289,8 +276,8 @@
<code>String</code>
</entry>
<entry>
- <para>Kerberos authenticated principle name. Only applies when configuring a kerberos authentication.
- See Admin Guide for configuration required for kerberos</para>
+ <para>Kerberos authenticated principle name. Only applies when configuring a GSS authentication.
+ See the Admin Guide for configuration required for GSS</para>
</entry>
</row>
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -32,7 +32,7 @@
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.client.security.InvalidSessionException;
import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.security.Credentials;
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -113,6 +113,7 @@
import org.teiid.metadata.TableStats;
import org.teiid.metadata.Table.TriggerEvent;
import org.teiid.net.TeiidURL;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.query.ObjectReplicator;
import org.teiid.query.metadata.TransformationMetadata;
import org.teiid.query.optimizer.relational.RelationalPlanner;
@@ -230,6 +231,7 @@
this.csr.registerClientService(Admin.class, adminProxy, LogConstants.CTX_ADMIN_API);
ClientServiceRegistryImpl jdbcCsr = new ClientServiceRegistryImpl();
+ jdbcCsr.setAuthenticationType(this.sessionService.getAuthType());
jdbcCsr.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
jdbcCsr.registerClientService(DQP.class, dqpProxy, LogConstants.CTX_DQP);
@@ -241,6 +243,7 @@
}
ClientServiceRegistryImpl adminCsr = new ClientServiceRegistryImpl(Type.Admin);
+ adminCsr.setAuthenticationType(this.sessionService.getAuthType());
adminCsr.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
adminCsr.registerClientService(Admin.class, adminProxy, LogConstants.CTX_ADMIN_API);
@@ -857,4 +860,9 @@
*/
public void setContainerLifeCycleListener(ContainerLifeCycleListener listener) {
}
+
+ @Override
+ public AuthenticationType getAuthenticationType() {
+ return this.sessionService.getAuthType();
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -54,7 +54,7 @@
import org.teiid.jdbc.TeiidDriver;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.odbc.PGUtil.PgColInfo;
import org.teiid.query.parser.SQLParserUtil;
import org.teiid.runtime.RuntimePlugin;
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -63,7 +63,7 @@
import org.teiid.logging.LogManager;
import org.teiid.net.ServerConnection;
import org.teiid.net.TeiidURL;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.Credentials;
import org.teiid.security.SecurityHelper;
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -23,6 +23,7 @@
package org.teiid.transport;
import org.teiid.core.ComponentNotFoundException;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.security.SecurityHelper;
@@ -35,5 +36,7 @@
<T> T getClientService(Class<T> iface) throws ComponentNotFoundException;
SecurityHelper getSecurityHelper();
+
+ AuthenticationType getAuthenticationType();
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -26,6 +26,7 @@
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.SecurityHelper;
@@ -58,6 +59,7 @@
private HashMap<String, ClientService> clientServices = new HashMap<String, ClientService>();
private SecurityHelper securityHelper;
private Type type = Type.JDBC;
+ private AuthenticationType authenticationType = AuthenticationType.CLEARTEXT;
public ClientServiceRegistryImpl() {
@@ -66,6 +68,10 @@
public ClientServiceRegistryImpl(Type type) {
this.type = type;
}
+
+ public void setAuthenticationType(AuthenticationType authenticationType) {
+ this.authenticationType = authenticationType;
+ }
public <T> T getClientService(Class<T> iface) throws ComponentNotFoundException {
ClientService cs = getClientService(iface.getName());
@@ -92,5 +98,10 @@
public void setSecurityHelper(SecurityHelper securityHelper) {
this.securityHelper = securityHelper;
}
+
+ @Override
+ public AuthenticationType getAuthenticationType() {
+ return authenticationType;
+ }
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -50,7 +50,7 @@
import org.teiid.logging.LogManager;
import org.teiid.net.CommunicationException;
import org.teiid.net.TeiidURL;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.Credentials;
Modified: trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -36,7 +36,7 @@
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.net.CommunicationException;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.net.socket.ObjectChannel;
import org.teiid.net.socket.ServiceInvocationStruct;
import org.teiid.odbc.ODBCClientRemote;
Modified: trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/transport/ODBCSocketListener.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -26,7 +26,7 @@
import org.teiid.client.security.ILogon;
import org.teiid.common.buffer.StorageManager;
import org.teiid.jdbc.TeiidDriver;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
import org.teiid.net.socket.ObjectChannel;
public class ODBCSocketListener extends SocketListener {
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -95,7 +95,7 @@
public void onConnection() throws CommunicationException {
Handshake handshake = new Handshake();
-
+ handshake.setAuthType(csr.getAuthenticationType());
if (usingEncryption) {
keyGen = new DhKeyGenerator();
byte[] publicKey;
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2011-11-10 17:48:21 UTC (rev 3631)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2011-11-10 18:16:54 UTC (rev 3632)
@@ -34,7 +34,7 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.service.SessionService;
import org.teiid.net.TeiidURL;
-import org.teiid.net.TeiidURL.CONNECTION.AuthenticationType;
+import org.teiid.net.socket.AuthenticationType;
public class TestLogonImpl extends TestCase {
13 years, 1 month
teiid SVN: r3631 - in branches/7.1.x/connectors: translator-netezza and 15 other directories.
by teiid-commits@lists.jboss.org
Author: van.halbert
Date: 2011-11-10 12:48:21 -0500 (Thu, 10 Nov 2011)
New Revision: 3631
Added:
branches/7.1.x/connectors/translator-netezza/
branches/7.1.x/connectors/translator-netezza/pom.xml
branches/7.1.x/connectors/translator-netezza/src/
branches/7.1.x/connectors/translator-netezza/src/main/
branches/7.1.x/connectors/translator-netezza/src/main/java/
branches/7.1.x/connectors/translator-netezza/src/main/java/org/
branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/
branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/translator/
branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/translator/jdbc/
branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/translator/jdbc/netezza/
branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java
branches/7.1.x/connectors/translator-netezza/src/test/
branches/7.1.x/connectors/translator-netezza/src/test/java/
branches/7.1.x/connectors/translator-netezza/src/test/java/org/
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaConvertModifier.java
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorCapabilities.java
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorDatetimeConversion.java
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorTypeMapping.java
branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestSubstringFunctionModifier.java
Modified:
branches/7.1.x/connectors/pom.xml
Log:
SOA-3573 backporting the Netezza translator from 7.4.x
Modified: branches/7.1.x/connectors/pom.xml
===================================================================
--- branches/7.1.x/connectors/pom.xml 2011-11-10 17:02:42 UTC (rev 3630)
+++ branches/7.1.x/connectors/pom.xml 2011-11-10 17:48:21 UTC (rev 3631)
@@ -90,5 +90,6 @@
<module>sandbox</module>
<module>translator-ws</module>
+ <module>translator-netezza</module>
</modules>
</project>
Added: branches/7.1.x/connectors/translator-netezza/pom.xml
===================================================================
--- branches/7.1.x/connectors/translator-netezza/pom.xml (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/pom.xml 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,71 @@
+<?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>connectors</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.1.1.CP3</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>translator-netezza</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <name>Netezza Translator</name>
+
+ <description>This project contains translator for a Netezza source. </description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-jdbc</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <version>1.5</version>
+ </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/translator-netezza/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/main/java/org/teiid/translator/jdbc/netezza/NetezzaExecutionFactory.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,465 @@
+package org.teiid.translator.jdbc.netezza;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.Limit;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.ExtractFunctionModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.LocateFunctionModifier;
+
+@SuppressWarnings("nls")
+@Translator(name = "netezza", description = "A translator for Netezza Database")
+public class NetezzaExecutionFactory extends JDBCExecutionFactory {
+
+ private static final String TIME_FORMAT = "HH24:MI:SS";
+ private static final String DATE_FORMAT = "YYYY-MM-DD";
+ private static final String DATETIME_FORMAT = DATE_FORMAT + " "
+ + TIME_FORMAT;
+ private static final String TIMESTAMP_FORMAT = DATETIME_FORMAT + ".MS";
+
+ public NetezzaExecutionFactory() {
+ setSupportsFullOuterJoins(true);
+ setSupportsOrderBy(true);
+ setSupportsOuterJoins(true);
+ setSupportsSelectDistinct(true);
+ setSupportsInnerJoins(true);
+ }
+
+ public void start() throws TranslatorException {
+ super.start();
+
+ // STRING FUNCTION MODIFIERS
+ // //////////////////////////////////
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier(
+ "chr"));
+ registerFunctionModifier(SourceSystemFunctions.LCASE,
+ new AliasModifier("lower"));
+ registerFunctionModifier(SourceSystemFunctions.UCASE,
+ new AliasModifier("upper"));
+ registerFunctionModifier(SourceSystemFunctions.LOCATE,
+ new LocateFunctionModifier(getLanguageFactory(), "INSTR", true));
+ registerFunctionModifier(SourceSystemFunctions.CONCAT,
+ new AliasModifier("||"));
+ // /NUMERIC FUNCTION MODIFIERS
+ // //////////////////////////////////
+ registerFunctionModifier(SourceSystemFunctions.CEILING,
+ new AliasModifier("ceil"));
+ registerFunctionModifier(SourceSystemFunctions.POWER,
+ new AliasModifier("pow"));
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier(
+ "LN"));
+ // /BIT FUNCTION MODIFIERS
+ // //////////////////////////////////
+ registerFunctionModifier(SourceSystemFunctions.BITAND,
+ new AliasModifier("intNand"));
+ registerFunctionModifier(SourceSystemFunctions.BITNOT,
+ new AliasModifier("intNnot"));
+ registerFunctionModifier(SourceSystemFunctions.BITOR,
+ new AliasModifier("intNor"));
+ registerFunctionModifier(SourceSystemFunctions.BITXOR,
+ new AliasModifier("intNxor"));
+ // DATE FUNCTION MODIFIERS
+ // ////////////////////////////////////////
+ registerFunctionModifier(SourceSystemFunctions.YEAR,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR,
+ new ExtractModifier("DOY"));
+ registerFunctionModifier(SourceSystemFunctions.QUARTER,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTH,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH,
+ new ExtractModifier("DAY"));
+ registerFunctionModifier(SourceSystemFunctions.WEEK,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK,
+ new ExtractModifier("DOW"));
+ registerFunctionModifier(SourceSystemFunctions.HOUR,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MINUTE,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.SECOND,
+ new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.CURDATE,
+ new AliasModifier("CURRENT_DATE"));
+ registerFunctionModifier(SourceSystemFunctions.CURTIME,
+ new AliasModifier("CURRENT_TIME"));
+ // SYSTEM FUNCTIONS
+ // //////////////////////////////////
+ registerFunctionModifier(SourceSystemFunctions.IFNULL,
+ new AliasModifier("NVL"));
+
+ // DATA TYPE CONVERSION
+ // /////////////////////////////////////////
+ ConvertModifier convertModifier = new ConvertModifier();
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR);
+ convertModifier.addTypeMapping("byteint", FunctionModifier.BYTE);
+ convertModifier.addTypeMapping("smallint", FunctionModifier.SHORT);
+ convertModifier.addTypeMapping("bigint", FunctionModifier.LONG);
+ convertModifier.addTypeMapping("numeric(38)",
+ FunctionModifier.BIGINTEGER);
+ convertModifier.addTypeMapping("numeric(38,18)",
+ FunctionModifier.BIGDECIMAL);
+ convertModifier
+ .addTypeMapping("varchar(4000)", FunctionModifier.STRING);
+
+ // /NO BOOLEAN, INTEGER, FLOAT, DATE, TIME, TIMESTAMP, as they are
+ // directly available in netezza
+ // /NO NULL, CLOB, BLOB, OBJECT, XML
+
+ // /BOOLEAN--BYTE, SHORT, INTEGER, LONG, FLOAT, DOUBLE, BIGINTEGER,
+ // BIGDECIMAL--AS IT DOESN'T WORK IMPLICITLY IN NETEZZA
+
+
+ convertModifier.addConvert(FunctionModifier.FLOAT, FunctionModifier.BIGDECIMAL, new CastModifier("numeric"));
+ convertModifier.addConvert(FunctionModifier.DOUBLE, FunctionModifier.BIGDECIMAL, new CastModifier("numeric"));
+
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.INTEGER,
+ new BooleanToNumericConversionModifier());
+ convertModifier
+ .addConvert(FunctionModifier.BOOLEAN, FunctionModifier.BYTE,
+ new BooleanToNumericConversionModifier());
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.SHORT,
+ new BooleanToNumericConversionModifier());
+ convertModifier
+ .addConvert(FunctionModifier.BOOLEAN, FunctionModifier.LONG,
+ new BooleanToNumericConversionModifier());
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.FLOAT,
+ new BooleanToNumericConversionModifier());
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.DOUBLE,
+ new BooleanToNumericConversionModifier());
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.BIGINTEGER,
+ new BooleanToNumericConversionModifier());
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.BIGDECIMAL,
+ new BooleanToNumericConversionModifier());
+ convertModifier.addConvert(FunctionModifier.BOOLEAN,
+ FunctionModifier.STRING,
+ new BooleanToStringConversionModifier());
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.BOOLEAN, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ Expression stringValue = function.getParameters()
+ .get(0);
+ return Arrays.asList("CASE WHEN ", stringValue,
+ " IN ('false', '0') THEN '0' WHEN ",
+ stringValue, " IS NOT NULL THEN '1' END");
+ }
+ });
+ convertModifier.addTypeConversion(new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ Expression stringValue = function.getParameters().get(0);
+ return Arrays.asList("CASE WHEN ", stringValue,
+ " = 0 THEN '0' WHEN ", stringValue,
+ " IS NOT NULL THEN '1' END");
+ }
+ }, FunctionModifier.BOOLEAN);
+
+ // //////STRING TO DATATYPE CONVERSION OTHER THAN DATE/TIME
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.INTEGER, new CastModifier("integer"));
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.FLOAT, new CastModifier("float"));
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.DOUBLE, new CastModifier("double"));
+ // /// STRING --> CHAR, BYTE, SHORT, LONG, BIGI, BIGD, BOOLEAN is taken
+ // care by Type Mapping
+ // /// NO conversion support for NULL, CLOB, BLOB, OBJECT, XML
+ // //STRING TO DATE/TIME CONVERSION////
+ // ////////////////////////////////////
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.DATE, new ConvertModifier.FormatModifier(
+ "to_date", DATE_FORMAT));
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.TIME, new ConvertModifier.FormatModifier(
+ "to_timestamp", TIME_FORMAT));
+ convertModifier.addConvert(FunctionModifier.STRING,
+ FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier(
+ "to_timestamp", TIMESTAMP_FORMAT));
+ // ////DATE/TIME INTERNAL CONVERSION/////////
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP,
+ FunctionModifier.TIME, new CastModifier("TIME"));
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP,
+ FunctionModifier.DATE, new CastModifier("DATE"));
+ convertModifier.addConvert(FunctionModifier.DATE,
+ FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP"));
+ // convertModifier.addConvert(FunctionModifier.TIME,
+ // FunctionModifier.TIMESTAMP, new CastModifier("TIMESTAMP")); //TIME
+ // --> TIMESTAMP --DOESN't WORK IN NETEZZA-NO FUNCTION SUPPORT
+
+ // //DATE/TIME to STRING CONVERION////
+ // ///////////////////////////////////
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP,
+ FunctionModifier.STRING, new ConvertModifier.FormatModifier(
+ "to_char", TIMESTAMP_FORMAT));
+ // /NO NETEZAA FUNCTION for DATE, TIME to STRING
+
+ convertModifier.setWideningNumericImplicit(true);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ // //////////////////////////////////////////////////////////
+ // STRING FUNCTIONS
+ // ////////////////////////////////////////////////////////
+ supportedFunctions.add(SourceSystemFunctions.ASCII);// taken care with
+ // alias function
+ // modifier
+ supportedFunctions.add(SourceSystemFunctions.CHAR);// ALIAS to use 'chr'
+ supportedFunctions.add(SourceSystemFunctions.CONCAT); // ALIAS ||
+ supportedFunctions.add(SourceSystemFunctions.INITCAP);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);// ALIAS 'lower'
+// supportedFunctions.add(SourceSystemFunctions.LPAD);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE); // LOCATE FUNCTIO
+ // MODIFIER
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ // supportedFunctions.add(SourceSystemFunctions.REPEAT);
+// supportedFunctions.add(SourceSystemFunctions.RPAD);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING); // No Need of
+ // ALIAS as
+ // both
+ // substring
+ // and
+ // substr
+ // work in
+ // netezza
+ supportedFunctions.add(SourceSystemFunctions.UCASE); // ALIAS UPPER
+ // FUNCTION DIFFERENCE = "difference"; ///NO FUNCTION FOUND--DIFFERENCE
+ // FUNCTION INSERT = "insert";
+ // supportedFunctions.add(SourceSystemFunctions.LEFT); //is this
+ // available or is it simply for LEFT OUTER JOIN?
+ // FUNCTION REPLACE = "replace"; // NO REPLACE Function
+ // supportedFunctions.add(SourceSystemFunctions.RIGHT);--is this
+ // available or is it simply for RIGHT OUTER JOIN?
+ // FUNCTION SOUNDEX = "soundex";
+ // FUNCTION TO_BYTES = "to_bytes";
+ // FUNCTION TO_CHARS = "to_chars";
+ // ////////
+ // ////////////////////////////////////////////////////////////////////
+ // NUMERIC
+ // FUNCTIONS////////////////////////////////////////////////////////////
+ // ////////////////////////////////////////////////////////////////////////////
+ // supportedFunctions.add(SourceSystemFunctions.ABS);
+// supportedFunctions.add(SourceSystemFunctions.ACOS);
+// supportedFunctions.add(SourceSystemFunctions.ASIN);
+// supportedFunctions.add(SourceSystemFunctions.ATAN);
+// supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.CEILING); // /ALIAS-ceil
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.COT);
+ supportedFunctions.add(SourceSystemFunctions.DEGREES);
+ // supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.FLOOR);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+// supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.PI);
+ supportedFunctions.add(SourceSystemFunctions.POWER);// ALIAS-POW
+ supportedFunctions.add(SourceSystemFunctions.RADIANS);
+ supportedFunctions.add(SourceSystemFunctions.ROUND);
+ supportedFunctions.add(SourceSystemFunctions.SIGN);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+ // FUNCTION TRANSLATE = "translate";
+ // FUNCTION TRUNCATE = "truncate";
+ // FUNCTION FORMATINTEGER = "formatinteger";
+ // FUNCTION FORMATLONG = "formatlong";
+ // FUNCTION FORMATDOUBLE = "formatdouble";
+ // FUNCTION FORMATFLOAT = "formatfloat";
+ // FUNCTION FORMATBIGINTEGER = "formatbiginteger";
+ // FUNCTION FORMATBIGDECIMAL = "formatbigdecimal";
+ // FUNCTION LOG10 = "log10";
+ // FUNCTION PARSEINTEGER = "parseinteger";
+ // FUNCTION PARSELONG = "parselong";
+ // FUNCTION PARSEDOUBLE = "parsedouble";
+ // FUNCTION PARSEFLOAT = "parsefloat";
+ // FUNCTION PARSEBIGINTEGER = "parsebiginteger";
+ // FUNCTION PARSEBIGDECIMAL = "parsebigdecimal";
+ // supportedFunctions.add(SourceSystemFunctions.RAND); --Needs
+ // Alias--But, is it required to even have an alias???
+ // ///////////////////////////////////////////////////////////////////
+ // BIT FUNCTIONS//////////////////////////////////////////////////////
+ // ALIAS FUNCTION MODIFIER IS APPLIED//////////////////////////////
+ supportedFunctions.add(SourceSystemFunctions.BITAND);
+ supportedFunctions.add(SourceSystemFunctions.BITOR);
+ supportedFunctions.add(SourceSystemFunctions.BITNOT);
+ supportedFunctions.add(SourceSystemFunctions.BITXOR);
+ // DATE FUNCTIONS
+ supportedFunctions.add(SourceSystemFunctions.CURDATE);
+ supportedFunctions.add(SourceSystemFunctions.CURTIME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.QUARTER);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.WEEK);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+ // FUNCTION DAYNAME = "dayname";
+ // FUNCTION FORMATTIMESTAMP = "formattimestamp";
+ // FUNCTION MODIFYTIMEZONE = "modifytimezone";
+ // FUNCTION MONTHNAME = "monthname";
+ // FUNCTION NOW = "now";
+ // FUNCTION PARSETIMESTAMP = "parsetimestamp";
+ // FUNCTION TIMESTAMPADD = "timestampadd";
+ // FUNCTION TIMESTAMPCREATE = "timestampcreate";
+ // FUNCTION TIMESTAMPDIFF = "timestampdiff";
+
+ // SYSTEM FUNCTIONS
+ supportedFunctions.add(SourceSystemFunctions.IFNULL); // ALIAS-NVL
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ supportedFunctions.add(SourceSystemFunctions.NULLIF);
+
+ // CONVERSION functions
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+
+ // USER DEFINED FUNCTIONS
+ // supportedFunctions.add("USR_DEF_FUNC");
+
+ return supportedFunctions;
+ }
+
+ 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), ")");
+ }
+ }
+
+ public static class BooleanToNumericConversionModifier extends
+ FunctionModifier {
+ @Override
+ public List<?> translate(Function function) {
+ Expression booleanValue = function.getParameters().get(0);
+ if (booleanValue instanceof Function) {
+ Function nested = (Function) booleanValue;
+ if (nested.getName().equalsIgnoreCase("convert")
+ && Number.class.isAssignableFrom(nested.getParameters()
+ .get(0).getType())) {
+ booleanValue = nested.getParameters().get(0);
+ }
+ }
+ return Arrays.asList("(CASE WHEN ", booleanValue,
+ " IN ( '0', 'FALSE') THEN 0 WHEN ", booleanValue,
+ " IS NOT NULL THEN 1 END)");
+ }
+
+ }
+
+ public static class BooleanToStringConversionModifier extends
+ FunctionModifier {
+ @Override
+ public List<?> translate(Function function) {
+ Expression booleanValue = function.getParameters().get(0);
+ if (booleanValue instanceof Function) {
+ Function nested = (Function) booleanValue;
+ if (nested.getName().equalsIgnoreCase("convert")
+ && Number.class.isAssignableFrom(nested.getParameters()
+ .get(0).getType())) {
+ booleanValue = nested.getParameters().get(0);
+ }
+ }
+ return Arrays.asList("CASE WHEN ", booleanValue,
+ " = '0' THEN 'false' WHEN ", booleanValue,
+ " IS NOT NULL THEN 'true' END");
+ }
+
+ }
+
+ 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 + ")");
+ }
+ }
+
+ @Override
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ if (limit.getRowOffset() > 0) {
+ return Arrays.asList("LIMIT ", limit.getRowLimit(), " OFFSET ",
+ limit.getRowOffset());
+ }
+ return null;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesEnhancedNumeric() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+
+}
Added: branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaConvertModifier.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaConvertModifier.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaConvertModifier.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,509 @@
+/*
+ * 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.netezza;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+
+/**
+ */
+public class TestNetezzaConvertModifier extends TestCase {
+
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ public TestNetezzaConvertModifier(String name) {
+ super(name);
+ }
+
+ public String helpGetString(Expression expr) throws Exception {
+ NetezzaExecutionFactory trans = new NetezzaExecutionFactory();
+ trans.start();
+ SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
+ Arrays.asList(
+ srcExpression,
+ LANG_FACTORY.createLiteral(tgtType, String.class)),
+ TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
+ expectedExpression, helpGetString(func));
+ }
+
+
+
+
+ // Source = STRING
+ public void testStringToChar() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "cast('5' AS char(1))");
+ }
+
+ public void testStringToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "CASE WHEN '5' IN ('false', '0') THEN '0' WHEN '5' IS NOT NULL THEN '1' END");
+ }
+
+ public void testStringToByte() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "byte", "cast('5' AS byteint)");
+ }
+
+ public void testStringToShort() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "short", "cast('5' AS smallint)");
+ }
+
+ public void testStringToInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "integer", "cast('5' AS integer)");
+ }
+
+ public void testStringToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "long", "cast('5' AS bigint)");
+ }
+
+ public void testStringToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "cast('5' AS numeric(38))"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testStringToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "float", "cast('5' AS float)");
+ }
+
+ public void testStringToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "double", "cast('5' AS double)");
+ }
+
+ public void testStringToDate() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("2004-06-29", String.class), "date", "to_date('2004-06-29', 'YYYY-MM-DD')");
+ }
+
+ public void testStringToTime() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("23:59:59", String.class), "time", "to_timestamp('23:59:59', 'HH24:MI:SS')");
+ }
+
+ public void testStringToTimestamp() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("2004-06-29 23:59:59.987", String.class), "timestamp", "to_timestamp('2004-06-29 23:59:59.987', 'YYYY-MM-DD HH24:MI:SS.MS')");
+ }
+
+ public void testStringToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral("5", String.class), "bigdecimal", "cast('5' AS numeric(38,18))");
+ }
+
+ // Source = CHAR
+
+ public void testCharToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "'5'");
+ }
+
+ // Source = BOOLEAN
+
+ public void testBooleanToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "CASE WHEN 1 = '0' THEN 'false' WHEN 1 IS NOT NULL THEN 'true' END");
+ }
+
+ public void testBooleanToByte() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "byte", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToShort() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "short", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "integer", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "long", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "biginteger", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "float", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "double", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ public void testBooleanToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.FALSE, Boolean.class), "bigdecimal", "(CASE WHEN 0 IN ( '0', 'FALSE') THEN 0 WHEN 0 IS NOT NULL THEN 1 END)");
+ }
+
+ // Source = BYTE
+
+ public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ public void testByteToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "CASE WHEN 1 = 0 THEN '0' WHEN 1 IS NOT NULL THEN '1' END");
+ }
+
+// public void testByteToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "short", "1");
+// }
+//
+// public void testByteToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "integer", "integer(1)");
+// }
+//
+// public void testByteToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "bigint(1)");
+// }
+//
+// public void testByteToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "cast(1 AS numeric(31,0))");
+// }
+//
+// public void testByteToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "cast(1 AS real)");
+// }
+//
+// public void testByteToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "double(1)");
+// }
+//
+// public void testByteToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "cast(1 AS numeric(31,12))");
+// }
+
+ // Source = SHORT
+
+ public void testShortToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ public void testShortToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "CASE WHEN 1 = 0 THEN '0' WHEN 1 IS NOT NULL THEN '1' END");
+ }
+
+// public void testShortToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "byte", "1");
+// }
+//
+// public void testShortToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "integer", "integer(1)");
+// }
+//
+// public void testShortToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "bigint(1)");
+// }
+//
+// public void testShortToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "cast(1 AS numeric(31,0))");
+// }
+//
+// public void testShortToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "cast(1 AS real)");
+// }
+//
+// public void testShortToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "double(1)");
+// }
+//
+// public void testShortToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "cast(1 AS numeric(31,12))");
+// }
+
+ // Source = INTEGER
+
+ public void testIntegerToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ public void testIntegerToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "CASE WHEN 1 = 0 THEN '0' WHEN 1 IS NOT NULL THEN '1' END");
+ }
+
+// public void testIntegerToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "byte", "smallint(1)");
+// }
+//
+// public void testIntegerToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "short", "smallint(1)");
+// }
+//
+// public void testIntegerToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "bigint(1)");
+// }
+//
+// public void testIntegerToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "cast(1 AS numeric(31,0))");
+// }
+//
+// public void testIntegerToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "cast(1 AS real)");
+// }
+//
+// public void testIntegerToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "double(1)");
+// }
+//
+// public void testIntegerToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "cast(1 AS numeric(31,12))");
+// }
+
+ // Source = LONG
+
+ public void testLongToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ public void testLongToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "CASE WHEN 1 = 0 THEN '0' WHEN 1 IS NOT NULL THEN '1' END");
+ }
+
+// public void testLongToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "byte", "smallint(1)");
+// }
+//
+// public void testLongToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "short", "smallint(1)");
+// }
+//
+// public void testLongToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "integer", "integer(1)");
+// }
+//
+// public void testLongToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "cast(1 AS numeric(31,0))");
+// }
+//
+// public void testLongToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "cast(1 AS real)");
+// }
+//
+// public void testLongToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "double(1)");
+// }
+//
+// public void testLongToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "cast(1 AS numeric(31,12))");
+// }
+
+ // Source = BIGINTEGER
+
+ public void testBigIntegerToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "cast(1 AS varchar(4000))");
+ }
+
+ public void testBigIntegerToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "CASE WHEN 1 = 0 THEN '0' WHEN 1 IS NOT NULL THEN '1' END");
+ }
+
+// public void testBigIntegerToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "byte", "smallint(1)");
+// }
+//
+// public void testBigIntegerToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "short", "smallint(1)");
+// }
+//
+// public void testBigIntegerToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "integer", "integer(1)");
+// }
+//
+// public void testBigIntegerToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "bigint(1)");
+// }
+//
+// public void testBigIntegerToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "cast(1 AS real)");
+// }
+//
+// public void testBigIntegerToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "double(1)");
+// }
+//
+// public void testBigIntegerToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "cast(1 AS numeric(31,12))");
+// }
+
+ // Source = FLOAT
+
+ public void testFloatToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "cast(1.2 AS varchar(4000))");
+ }
+
+ public void testFloatToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "CASE WHEN 1.2 = 0 THEN '0' WHEN 1.2 IS NOT NULL THEN '1' END");
+ }
+
+// public void testFloatToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "byte", "smallint(1.2)");
+// }
+//
+// public void testFloatToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "short", "smallint(1.2)");
+// }
+//
+// public void testFloatToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "integer", "integer(1.2)");
+// }
+//
+// public void testFloatToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "bigint(1.2)");
+// }
+//
+// public void testFloatToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "cast(1.2 AS numeric(31,0))");
+// }
+//
+// public void testFloatToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "double(1.2)");
+// }
+//
+// public void testFloatToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "cast(1.2 AS numeric(31,12))");
+// }
+
+ // Source = DOUBLE
+
+ public void testDoubleToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "cast(1.2 AS varchar(4000))");
+ }
+
+ public void testDoubleToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "CASE WHEN 1.2 = 0 THEN '0' WHEN 1.2 IS NOT NULL THEN '1' END");
+ }
+
+// public void testDoubleToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "byte", "smallint(1.2)");
+// }
+//
+// public void testDoubleToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "smallint(1.2)");
+// }
+//
+// public void testDoubleToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "integer", "integer(1.2)");
+// }
+//
+// public void testDoubleToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "bigint(1.2)");
+// }
+//
+// public void testDoubleToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "cast(1.2 AS numeric(31,0))");
+// }
+//
+// public void testDoubleToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "cast(1.2 AS real)");
+// }
+//
+// public void testDoubleToBigDecimal() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "cast(1.2 AS numeric(31,12))");
+// }
+
+ // Source = BIGDECIMAL
+
+ public void testBigDecimalToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "string", "cast(1.0 AS varchar(4000))");
+ }
+
+ public void testBigDecimalToBoolean() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "CASE WHEN 1.0 = 0 THEN '0' WHEN 1.0 IS NOT NULL THEN '1' END");
+ }
+
+// public void testBigDecimalToByte() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "smallint(1.0)");
+// }
+//
+// public void testBigDecimalToShort() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "short", "smallint(1.0)");
+// }
+//
+// public void testBigDecimalToInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "integer", "integer(1.0)");
+// }
+//
+// public void testBigDecimalToLong() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "bigint(1.0)");
+// }
+//
+// public void testBigDecimalToBigInteger() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "cast(1.0 AS numeric(31,0))");
+// }
+//
+// public void testBigDecimalToFloat() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "cast(1.0 AS real)");
+// }
+//
+// public void testBigDecimalToDouble() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "double(1.0)");
+// }
+
+// // Source = DATE
+//
+// public void testDateToString() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "char({d '2003-11-01'})");
+// }
+//
+// public void testDateToTimestamp() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "timestamp({d '2003-11-01'}, '00:00:00')");
+// }
+//
+// // Source = TIME
+//
+// public void testTimeToString() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "char({t '23:59:59'})");
+// }
+//
+// public void testTimeToTimestamp() throws Exception {
+// helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "timestamp('1970-01-01', {t '23:59:59'})");
+// }
+//
+// // Source = TIMESTAMP
+//
+// public void testTimestampToString() throws Exception {
+// Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
+// helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts '2003-11-01 12:05:02.0'})");
+// }
+//
+// public void testTimestampToDate() throws Exception {
+// Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
+// helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "date({ts '2003-11-01 12:05:02.0'})");
+// }
+//
+// public void testTimestampToTime() throws Exception {
+// Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
+// helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "time({ts '2003-11-01 12:05:02.0'})");
+// }
+
+}
Added: branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorCapabilities.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorCapabilities.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorCapabilities.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,376 @@
+package org.teiid.translator.jdbc.netezza;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.cdk.unittest.FakeTranslationFactory;
+import org.teiid.dqp.internal.datamgr.FakeExecutionContextImpl;
+import org.teiid.language.Command;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+public class TestNetezzaTranslatorCapabilities extends TestCase {
+
+ private static NetezzaExecutionFactory TRANSLATOR;
+ private static ExecutionContext EMPTY_CONTEXT = new FakeExecutionContextImpl();
+
+ static {
+ try {
+ TRANSLATOR = new NetezzaExecutionFactory();
+ TRANSLATOR.start();
+ } catch(TranslatorException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ private String getTestBQTVDB() {
+ return TranslationHelper.BQT_VDB;
+ }
+
+ public void helpTestVisitor(String input, String expectedOutput) throws TranslatorException {
+ // Convert from sql to objects
+ Command obj = FakeTranslationFactory.getInstance().getBQTTranslationUtility().parseCommand(input);
+
+ TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), TRANSLATOR);
+ tc.translateCommand(obj);
+
+
+ // Check stuff
+ assertEquals("Did not get correct sql", expectedOutput, tc.getSql());
+ }
+
+
+ /////////BASIC TEST CASES FOR CAPABILITIES/////////////
+ /////////////////////////////////////////////////
+ @Test
+ public void testRowLimit() throws Exception {
+ String input = "select intkey from bqt1.smalla limit 100";
+ String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100";
+
+ helpTestVisitor(
+ input,
+ output);
+
+ }
+ @Test
+ public void testSelectDistinct() throws Exception {
+ String input = "select distinct intkey from bqt1.smalla limit 100";
+ String output = "SELECT DISTINCT SmallA.IntKey FROM SmallA LIMIT 100";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ @Test
+ public void testSelectExpression() throws Exception {
+ String input = "select intkey, intkey + longnum / 2 as test from bqt1.smalla";
+ String output = "SELECT SmallA.IntKey, (SmallA.IntKey + (SmallA.LongNum / 2)) AS test FROM SmallA";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ public void testBetweenCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum BETWEEN 2 AND 10";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum >= ? AND SmallA.IntNum <= ?";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ public void testCompareCriteriaEquals() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum = 10";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum = ?";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ public void testCompareCriteriaOrdered() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum < 10";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum < ?";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ public void testLikeCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where stringkey like '4%'";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.StringKey LIKE ?";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ public void testLikeWithEscapeCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where stringkey like '4\\%'";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.StringKey LIKE ?";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ public void testInCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where stringkey IN ('10', '11', '12')";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.StringKey IN (?, ?, ?)";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ public void testInCriteriaSubQuery() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where stringkey IN (select stringkey from bqt1.smalla where intkey < 10)";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.StringKey IN (SELECT SmallA.StringKey FROM SmallA WHERE SmallA.IntKey < ?)";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ public void testIsNullCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum IS NULL";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum IS NULL";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ @Test public void testOrCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum < 2 OR intnum > 10";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum < ? OR SmallA.IntNum > ?";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ @Test public void testIsNotNullCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum IS NOT NULL";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum IS NOT NULL";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testExistsCriteria() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where exists (select intkey from bqt1.smallb)";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE EXISTS (SELECT SmallB.IntKey FROM SmallB)";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+ @Test public void testHavingClauseCriteria() throws Exception {
+ String input = "SELECT INTKEY FROM BQT1.SMALLA GROUP BY INTKEY HAVING INTKEY = (SELECT INTKEY FROM BQT1.SMALLA WHERE STRINGKEY = 20)";
+ String output = "SELECT SmallA.IntKey FROM SmallA GROUP BY SmallA.IntKey HAVING SmallA.IntKey = (SELECT SmallA.IntKey FROM SmallA WHERE SmallA.StringKey = ?)";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testScalarSubQuery() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla where intnum < (0.01 * (select sum(intnum) from bqt1.smalla ))";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA WHERE SmallA.IntNum < (0.010000000000000 * (SELECT SUM(SmallA.IntNum) FROM SmallA))";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testSimpleCaseExpression() throws Exception {
+ String input = "SELECT stringnum, intnum, CASE BOOLEANVALUE WHEN 'true' then 'true' WHEN false THEN 'FALSE' ELSE 'GOOD' END FROM bqt1.smalla;";
+ String output = "SELECT SmallA.StringNum, SmallA.IntNum, CASE WHEN SmallA.BooleanValue = ? THEN 'true' WHEN SmallA.BooleanValue = ? THEN 'FALSE' ELSE 'GOOD' END FROM SmallA";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testSearchedCaseExpression() throws Exception {
+ String input = "SELECT AVG(CASE WHEN intnum > 10 THEN intnum ELSE intkey END) \"Average\" FROM bqt1.smalla";
+ String output = "SELECT AVG(CASE WHEN SmallA.IntNum > ? THEN SmallA.IntNum ELSE SmallA.IntKey END) AS Average FROM SmallA";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testQuantifiedCompareSOMEorANY() throws Exception {
+ String input = "SELECT INTKEY, BYTENUM FROM BQT1.SmallA WHERE BYTENUM = ANY (SELECT BYTENUM FROM BQT1.SmallA WHERE BYTENUM >= '-108')";
+ String output = "SELECT SmallA.IntKey, SmallA.ByteNum FROM SmallA WHERE SmallA.ByteNum = SOME (SELECT SmallA.ByteNum FROM SmallA WHERE SmallA.ByteNum >= ?)";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testQuantifiedCompareALL() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY FROM BQT1.SMALLA WHERE STRINGKEY = ALL (SELECT STRINGKEY FROM BQT1.SMALLA WHERE INTKEY = 40)";
+ String output = "SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA WHERE SmallA.StringKey = ALL (SELECT SmallA.StringKey FROM SmallA WHERE SmallA.IntKey = ?)";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testSelfJoin() throws Exception {
+ String input = "SELECT x.intnum, y.intkey FROM bqt1.smalla x, bqt1.smalla y WHERE x.stringnum = y.intnum;";
+ String output = "SELECT x.IntNum, y.IntKey FROM SmallA AS x, SmallA AS y WHERE x.StringNum = cast(y.IntNum AS varchar(4000))";
+
+ helpTestVisitor(
+ input,
+ output);
+ }
+
+ @Test public void testLimitWithNestedInlineView() throws Exception {
+ String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by stringkey";
+ String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY SmallA.IntKey LIMIT 100) AS x GROUP BY x.stringkey";
+
+ helpTestVisitor( input, output);
+ }
+
+ @Test public void testAggregatesAndEnhancedNumeric() throws Exception {
+ String input = "select count(*), min(intkey), max(intkey), sum(intkey), avg(intkey), count(intkey), STDDEV_SAMP(intkey), STDDEV_POP(intkey), VAR_SAMP(intkey), VAR_POP(intkey) from bqt1.smalla";
+ String output = "SELECT COUNT(*), MIN(SmallA.IntKey), MAX(SmallA.IntKey), SUM(SmallA.IntKey), AVG(SmallA.IntKey), COUNT(SmallA.IntKey), STDDEV_SAMP(SmallA.IntKey), STDDEV_POP(SmallA.IntKey), VAR_SAMP(SmallA.IntKey), VAR_POP(SmallA.IntKey) FROM SmallA";
+
+ helpTestVisitor( input, output);
+ }
+ @Test public void testAggregatesDistinct() throws Exception {
+ String input = "select avg(DISTINCT intnum) from bqt1.smalla";
+ String output = "SELECT AVG(DISTINCT SmallA.IntNum) FROM SmallA";
+
+ helpTestVisitor( input, output);
+ }
+
+
+ @Test public void testExceptAsMinus() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla except select intnum, intkey from bqt1.smallb";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA EXCEPT SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB";
+
+ helpTestVisitor( input, output);
+ }
+
+ @Test public void testUnionAsPlus() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla union select intnum, intkey from bqt1.smallb";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA UNION SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB";
+
+ helpTestVisitor( input, output);
+ }
+ @Test public void testUnionAllAsPlus() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla union all select intnum, intkey from bqt1.smallb";
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA UNION ALL SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB";
+
+ helpTestVisitor( input, output);
+ }
+
+ @Test public void testUnionAllAsPlusWithAggregates() throws Exception {
+ String input = "select intkey, Sum(intnum) from bqt1.smalla group by intkey union all select intnum, intkey from bqt1.smallb";
+ String output = "SELECT SmallA.IntKey, SUM(SmallA.IntNum) FROM SmallA GROUP BY SmallA.IntKey UNION ALL SELECT SmallB.IntNum, SmallB.IntKey AS IntKey FROM SmallB";
+
+ helpTestVisitor( input, output);
+ }
+
+
+ @Test public void testintersect() throws Exception {
+ String input = "select intkey from bqt1.smalla where intkey < 20 INTERSECT select intkey from bqt1.smalla where intkey > 10";
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE SmallA.IntKey < ? INTERSECT SELECT SmallA.IntKey FROM SmallA WHERE SmallA.IntKey > ?";
+
+
+ helpTestVisitor( input, output);
+ }
+
+
+ @Test public void testUnionOrderBy() throws Exception {
+ String input = "(select intkey from bqt1.smalla) union select intnum from bqt1.smalla order by intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA UNION SELECT SmallA.IntNum FROM SmallA ORDER BY intkey";
+
+ helpTestVisitor( input, output);
+
+ }
+
+ @Test public void testIntersectOrderBy() throws Exception {
+ String input = "(select intkey from bqt1.smalla) intersect select intnum from bqt1.smalla order by intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA INTERSECT SELECT SmallA.IntNum FROM SmallA ORDER BY intkey";
+
+ helpTestVisitor( input, output);
+
+ }
+
+ @Test public void testExceptOrderBy() throws Exception {
+ String input = "(select intkey from bqt1.smalla) except select intnum from bqt1.smalla order by intkey";
+ String output = "SELECT SmallA.IntKey FROM SmallA EXCEPT SELECT SmallA.IntNum FROM SmallA ORDER BY intkey";
+
+ helpTestVisitor( input, output);
+
+ }
+
+
+ @Test public void testRowLimitOFFSET() throws Exception {
+ String input = "select intkey from bqt1.smalla limit 20, 30";
+ String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 30 OFFSET 20";
+
+ helpTestVisitor( input, output);
+ }
+
+
+ @Test public void testOrderByNullsFirstLast() throws Exception {
+ String input = "select intkey, longnum from bqt1.smalla order by longnum NULLS LAST";
+ String output = "SELECT SmallA.IntKey, SmallA.LongNum FROM SmallA ORDER BY SmallA.LongNum NULLS LAST";
+
+ helpTestVisitor( input, output);
+ }
+
+ @Test public void testOrderByUnRelated() throws Exception {
+ String input = "select intkey, longnum from bqt1.smalla order by floatnum";
+ String output = "SELECT SmallA.IntKey, SmallA.LongNum FROM SmallA ORDER BY SmallA.FloatNum";
+
+ helpTestVisitor( input, output);
+ }
+
+
+ @Test public void testInnerJoin() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT2.SmallB WHERE BQT1.SmallA.IntKey = BQT2.SmallB.IntKey AND BQT1.SmallA.IntKey >= 0 AND BQT2.SmallB.IntKey >= 0 ORDER BY BQT1.SmallA.IntKey";
+ String output = "SELECT SmallA.IntKey FROM SmallA, SmallB WHERE SmallA.IntKey = SmallB.IntKey AND SmallA.IntKey >= ? AND SmallB.IntKey >= ? ORDER BY SmallA.IntKey";
+
+ helpTestVisitor( input, output);
+ }
+
+
+ @Test public void testOuterJoin() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT2.SmallB WHERE BQT1.SmallA.IntKey = BQT2.SmallB.IntKey AND BQT1.SmallA.IntKey >= 0 AND BQT2.SmallB.IntKey >= 0 ORDER BY BQT1.SmallA.IntKey";
+ String output = "SELECT SmallA.IntKey FROM SmallA, SmallB WHERE SmallA.IntKey = SmallB.IntKey AND SmallA.IntKey >= ? AND SmallB.IntKey >= ? ORDER BY SmallA.IntKey";
+
+ helpTestVisitor( input, output);
+ }
+
+ @Test public void testFullOuterJoin() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntNum, BQT2.SmallB.IntNum FROM BQT1.SmallA FULL OUTER JOIN BQT2.SmallB ON BQT1.SmallA.IntNum = BQT2.SmallB.IntNum ORDER BY BQT1.SmallA.IntNum";
+ String output = "SELECT SmallA.IntNum, SmallB.IntNum FROM SmallA FULL OUTER JOIN SmallB ON SmallA.IntNum = SmallB.IntNum ORDER BY SmallA.IntNum";
+
+ helpTestVisitor( input, output);
+ }
+
+ @Test public void testRightOuterJoin() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntNum, BQT2.SmallB.IntNum FROM BQT1.SmallA RIGHT OUTER JOIN BQT2.SmallB ON BQT1.SmallA.IntNum = BQT2.SmallB.IntNum ORDER BY BQT2.SmallB.IntNum";
+ String output= "SELECT SmallA.IntNum, SmallB.IntNum FROM SmallB LEFT OUTER JOIN SmallA ON SmallA.IntNum = SmallB.IntNum ORDER BY SmallB.IntNum";
+
+ helpTestVisitor( input, output);
+ }
+ @Test
+ public void testLeftOuterJoin() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntNum, BQT2.SmallB.IntNum FROM BQT1.SmallA LEFT OUTER JOIN BQT2.SmallB ON BQT1.SmallA.IntNum = BQT2.SmallB.IntNum ORDER BY BQT1.SmallA.IntNum";
+ String output = "SELECT SmallA.IntNum, SmallB.IntNum FROM SmallA LEFT OUTER JOIN SmallB ON SmallA.IntNum = SmallB.IntNum ORDER BY SmallA.IntNum";
+
+ helpTestVisitor( input, output);
+ }
+
+
+
+}
Added: branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorDatetimeConversion.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorDatetimeConversion.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorDatetimeConversion.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,141 @@
+/*
+ * 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.netezza;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+/**
+ */
+public class TestNetezzaTranslatorDatetimeConversion {
+
+ private static NetezzaExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass public static void oneTimeSetup() throws TranslatorException {
+ TRANSLATOR = new NetezzaExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+
+
+ }
+
+ /////////////////UTILLITY FUNCTIONS/////////
+ ////////////////////////////////////////////
+
+ private String getTestVDB() {
+ //return TranslationHelper.NETEZZA_VDB;
+ return TranslationHelper.PARTS_VDB;
+ }
+
+ private String getTestBQTVDB() {
+ return TranslationHelper.BQT_VDB;
+ }
+
+ 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();
+ }
+
+
+ ///////////////DATE/TIME CONVERSION TESTCASES///////
+ ////////////////////////////////////////////////////
+
+ @Test public void testdayofmonth() throws Exception {
+ String input = "SELECT dayofmonth(datevalue) FROM BQT1.SMALLA";
+ String output = "SELECT extract(DAY from SmallA.DateValue) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+
+
+ ///BEGIN--FROM TIMESTAMP->DATE, TIME, STRING////////
+ @Test public void testTimestampToDate() throws Exception {
+ String input = "SELECT convert(convert(TIMESTAMPVALUE, date), string) FROM BQT1.SMALLA";
+ String output = "SELECT cast(cast(SmallA.TimestampValue AS DATE) AS varchar(4000)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+ @Test public void testTimestampToTime() throws Exception {
+ String input = "SELECT convert(convert(TIMESTAMPVALUE, time), string) FROM BQT1.SMALLA";
+ String output = "SELECT cast(cast(SmallA.TimestampValue AS TIME) AS varchar(4000)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+
+ @Test public void testTimestampToString() throws Exception {
+ String input = "SELECT convert(timestampvalue, string) FROM BQT1.SMALLA";
+ String output = "SELECT to_char(SmallA.TimestampValue, 'YYYY-MM-DD HH24:MI:SS.MS') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+ ///END--FROM TIMESTAMP->DATE, TIME, STRING////////
+
+ ///BEGIN--FROM DATE->TIMESTAMP////////
+ @Test public void testDateToTimestamp() throws Exception {
+ String input = "SELECT convert(convert(datevalue, timestamp), string) FROM BQT1.SMALLA";
+ String output = "SELECT to_char(cast(SmallA.DateValue AS TIMESTAMP), 'YYYY-MM-DD HH24:MI:SS.MS') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+ ///END--FROM DATE->TIMESTAMP////////
+
+ ///BEGIN--FROM TIME->TIMESTAMP////////
+ @Test public void testTimeToTimestamp() throws Exception {
+ String input = "SELECT convert(convert(TIMEVALUE, timestamp), string) FROM BQT1.SMALLA";
+ //String output = "SELECT to_char(cast(SmallA.TimeValue AS timestamp), 'YYYY-MM-DD HH24:MI:SS.FF') FROM SmallA";
+ String output = "SELECT to_char(SmallA.TimeValue, 'YYYY-MM-DD HH24:MI:SS.MS') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+ ///END--FROM TIME->TIMESTAMP////////
+
+
+// @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)");
+// }
+
+
+
+
+}
Added: branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorSourceSystemFunctions.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,243 @@
+/*
+ * 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.netezza;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+/**
+ */
+public class TestNetezzaTranslatorSourceSystemFunctions {
+
+ private static NetezzaExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass public static void oneTimeSetup() throws TranslatorException {
+ TRANSLATOR = new NetezzaExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+
+
+ }
+
+
+ /////////////////UTILLITY FUNCTIONS/////////
+ ////////////////////////////////////////////
+
+
+ private String getTestBQTVDB() {
+ return TranslationHelper.BQT_VDB;
+ }
+
+
+ /////SOURCESYSTEM FUNCTION TESTCASES//////////////
+ ///////////////////////////////////////////////
+
+
+ //////////////////BEGIN---STRING FUNCTIONS TESTCASES///////////////////
+
+ @Test
+ public void testLcaseUcase() throws Exception {
+ String input = "select lcase(StringKey), ucase(StringKey) FROM BQT1.SmallA";
+ String output = "SELECT lower(SmallA.StringKey), upper(SmallA.StringKey) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output,TRANSLATOR);
+ }
+ @Test public void testPad() throws Exception {
+ String input = "select lpad(smalla.stringkey, 18), rpad(smalla.stringkey, 12) from bqt1.smalla"; //$NON-NLS-1$
+ String output = "SELECT lpad(SmallA.StringKey, 18), rpad(SmallA.StringKey, 12) FROM SmallA"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test
+ public void testIFNull() throws Exception {
+ String input = "SELECT ifnull(StringKey, 'otherString') FROM BQT1.SmallA";
+ String output = "SELECT NVL(SmallA.StringKey, 'otherString') FROM SmallA";
+ //SELECT IFNULL(GL_ACTG_APPL_ID, 'otherString') FROM ACTG_UNIT_BAL_FACT
+ //SELECT nvl(GL_ACTG_APPL_ID, 'otherString') FROM ACTG_UNIT_BAL_FACT
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+
+
+ @Test public void testSubstring1() throws Exception {
+
+ //////////BOTH SUBSTRING AND SUBSTR work in NETEZZA//
+ //////////////////////////////////////////////////////
+ String input = "SELECT substring(StringKey, 1) FROM BQT1.SmallA";
+ String output = "SELECT substring(SmallA.StringKey, 1) FROM SmallA";
+ //SELECT substring(FDL_PMF_ACCT, 3) FROM ACTG_UNIT_BAL_FACT
+ //SELECT substr(FDL_PMF_ACCT, 3) FROM ACTG_UNIT_BAL_FACT
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+ @Test public void testSubstring2() throws Exception {
+
+ //////////BOTH SUBSTRING AND SUBSTR work in NETEZZA//
+ //////////////////////////////////////////////////////
+ String input = "SELECT substring(StringKey, 1, 5) FROM BQT1.SmallA";
+ String output = "SELECT substring(SmallA.StringKey, 1, 5) FROM SmallA";
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+
+
+
+ @Test public void testConcat_withLiteral() throws Exception {
+// String sql = "select stringnum || '1' from BQT1.Smalla";
+// String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(SmallA.StringNum, '1') END FROM SmallA";
+// helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+ String input = "select stringnum || '1' from BQT1.Smalla";
+ String output = "SELECT (SmallA.StringNum || '1') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(), input, output, TRANSLATOR);
+ }
+
+
+
+ ////BEGIN-LOCATE FUNCTION
+ @Test public void testLocate() throws Exception {
+ String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA";
+ String output = "SELECT INSTR('chimp', cast(SmallA.IntNum AS varchar(4000)), 1) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input, output,
+ TRANSLATOR);
+ }
+
+ @Test public void testLocate2() throws Exception {
+ String input = "SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA";
+ String output = "SELECT INSTR('chimp', SmallA.StringNum) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input, output,
+ TRANSLATOR);
+ }
+
+ @Test public void testLocate3() throws Exception {
+ String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26";
+ String output = "SELECT INSTR('234567890', cast(SmallA.IntNum AS varchar(4000)), 1) FROM SmallA WHERE SmallA.IntKey = 26";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate4() throws Exception {
+ String input = "SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA";
+ String output = "SELECT 1 FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate5() throws Exception {
+ String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA";
+ String output = "SELECT INSTR('chimp', SmallA.StringNum, 1) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate6() throws Exception {
+ String input = "SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA";
+ String output = "SELECT INSTR('chimp', SmallA.StringNum, CASE WHEN SmallA.IntNum < 1 THEN 1 ELSE SmallA.IntNum END) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testLocate7() throws Exception {
+ String input = "SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA";
+ String output = "SELECT INSTR('chimp', SmallA.StringNum, CASE WHEN (INSTR('chimp', SmallA.StringNum) + 1) < 1 THEN 1 ELSE (INSTR('chimp', SmallA.StringNum) + 1) END) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+ ////END-LOCATE FUNCTION
+
+
+
+
+ //////////////////BEGIN---NUMERIC FUNCTIONS TESTCASES///////////////////
+ @Test public void testCeil() throws Exception {
+ //select ceiling(sqrt(MEAS_PRD_ID)) from ACTG_UNIT_BAL_FACT
+ //select ceil(sqrt(MEAS_PRD_ID)) from ACTG_UNIT_BAL_FACT
+ String input = "SELECT ceiling(sqrt(INTKEY)) FROM BQT1.SMALLA";
+ String output = "SELECT ceil(sqrt(SmallA.IntKey)) FROM SmallA";
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testPower() throws Exception {
+
+ //select power(MEAS_PRD_ID, 2) from ACTG_UNIT_BAL_FACT
+ //select pow(MEAS_PRD_ID, 2) from ACTG_UNIT_BAL_FACT
+ String input = "SELECT power(INTKEY, 2) FROM BQT1.SMALLA";
+ String output = "SELECT pow(SmallA.IntKey, 2) FROM SmallA";
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ //////////////////END---NUMERIC FUNCTIONS TESTCASES///////////////////
+
+
+ //////////////////BEGIN---BIT FUNCTIONS CONVERSION TESTCASES///////////////////
+ ///////////////////////////////////////////////////////////////////
+
+ @Test public void testBitAnd() throws Exception {
+ String input = "select bitand(intkey, intnum) from bqt1.smalla";
+ String output = "SELECT intNand(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testBitNot() throws Exception {
+ String input = "select bitnot(intkey) from bqt1.smalla";
+ String output = "SELECT intNnot(SmallA.IntKey) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testBitOr() throws Exception {
+ String input = "select bitor(intkey, intnum) from bqt1.smalla";
+ String output = "SELECT intNor(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testBitXor() throws Exception {
+ String input = "select bitxor(intkey, intnum) from bqt1.smalla";
+ String output = "SELECT intNxor(SmallA.IntKey, SmallA.IntNum) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input,
+ output, TRANSLATOR);
+ }
+ //////////////////END---BIT FUNCTIONS CONVERSION TESTCASES///////////////////
+ /////////////////////////////////////////////////////////////////////////////
+
+
+}
Added: branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorTypeMapping.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorTypeMapping.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestNetezzaTranslatorTypeMapping.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,246 @@
+/*
+ * 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.netezza;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+
+public class TestNetezzaTranslatorTypeMapping {
+
+ private static NetezzaExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass public static void oneTimeSetup() throws TranslatorException {
+ TRANSLATOR = new NetezzaExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+
+
+ }
+
+
+ /////////////////UTILLITY FUNCTIONS/////////
+ ////////////////////////////////////////////
+
+ private String getTestBQTVDB() {
+
+ return TranslationHelper.BQT_VDB;
+ }
+
+
+ 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();
+ }
+
+
+ /////////TYPE MAPPING TESTS/////////
+ ///////////////////////////////////
+
+ @Test public void testCHARtoChar1() throws Exception {
+ String input = "SELECT convert(StringKey, CHAR) FROM BQT1.SmallA";
+ String output = "SELECT cast(SmallA.StringKey AS char(1)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testLongToBigInt() throws Exception {
+ String input = "SELECT convert(convert(StringKey, long), string) FROM BQT1.SmallA";
+ String output = "SELECT cast(cast(SmallA.StringKey AS bigint) AS varchar(4000)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToByte() throws Exception {
+ String input = "SELECT char(convert(stringnum, byte) + 100) FROM BQT1.SMALLA";
+ String output = "SELECT chr((cast(SmallA.StringNum AS byteint) + 100)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToShort() throws Exception {
+ String input = "SELECT char(convert(stringnum, short) + 100) FROM BQT1.SMALLA";
+ String output = "SELECT chr((cast(SmallA.StringNum AS smallint) + 100)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToLong() throws Exception {
+// String input = "SELECT char(convert(PART_WEIGHT, long) + 100) FROM PARTS";
+// String output = "SELECT chr((cast(PARTS.PART_WEIGHT AS bigint) + 100)) FROM PARTS";
+ String input = "SELECT convert(stringnum, long) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.StringNum AS bigint) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToBiginteger() throws Exception {
+ String input = "SELECT convert(stringnum, BIGINTEGER) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.StringNum AS numeric(38)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testStringToBigdecimal() throws Exception {
+ String input = "SELECT convert(stringnum, BIGDECIMAL) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.StringNum AS numeric(38,18)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testStringToVarchar() throws Exception {
+ String input = "SELECT convert(intkey, STRING) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.IntKey AS varchar(4000)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+
+
+
+ ////NON-MAPPED TYPES TEST/////////////
+ //////////////////////////////////////
+
+ @Test public void testStringToInteger() throws Exception {
+ String input = "SELECT char(convert(stringnum, integer) + 100) FROM BQT1.SMALLA";
+ String output = "SELECT chr((cast(SmallA.StringNum AS integer) + 100)) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+ @Test public void testStringToFloat() throws Exception {
+ String input = "SELECT convert(stringnum, float) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.StringNum AS float) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToReal() throws Exception {
+ String input = "SELECT convert(stringnum, real) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.StringNum AS float) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToDouble() throws Exception {
+ String input = "SELECT convert(stringnum, double) FROM BQT1.SMALLA";
+ String output = "SELECT cast(SmallA.StringNum AS double) FROM SmallA";
+ //SELECT cast(MEAS_PRD_ID AS DOUBLE) from ACTG_UNIT_BAL_FACT
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToBoolean() throws Exception {
+ String input = "SELECT convert(stringnum, boolean) FROM BQT1.SMALLA";
+ String output = "SELECT CASE WHEN SmallA.StringNum IN ('false', '0') THEN '0' WHEN SmallA.StringNum IS NOT NULL THEN '1' END FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToDate() throws Exception {
+ String input = "SELECT convert(stringnum, date) FROM BQT1.SMALLA";
+ String output = "SELECT to_date(SmallA.StringNum, 'YYYY-MM-DD') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToTime() throws Exception {
+ String input = "SELECT convert(stringnum, time) FROM BQT1.SMALLA";
+ String output = "SELECT to_timestamp(SmallA.StringNum, 'HH24:MI:SS') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+ @Test public void testStringToTimestamp() throws Exception {
+ String input = "SELECT convert(stringnum, timestamp) FROM BQT1.SMALLA";
+ String output = "SELECT to_timestamp(SmallA.StringNum, 'YYYY-MM-DD HH24:MI:SS.MS') FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+ }
+
+
+ @Test public void testbooleanToIntegerConversion() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntNum, BQT2.SmallB.BooleanValue FROM BQT1.SmallA, BQT2.SmallB WHERE BQT1.SmallA.IntNum = convert(BQT2.SmallB.booleanvalue, integer)";
+ String output = "SELECT SmallA.IntNum, SmallB.BooleanValue FROM SmallA, SmallB WHERE SmallA.IntNum = (CASE WHEN SmallB.BooleanValue IN ( '0', 'FALSE') THEN 0 WHEN SmallB.BooleanValue IS NOT NULL THEN 1 END)";
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+
+
+ }
+
+ @Test public void testIntegerToBooleanconversion() throws Exception {
+ String input = "SELECT BQT1.SmallA.IntNum, BQT2.SmallB.BooleanValue FROM BQT1.SmallA, BQT2.SmallB WHERE BQT1.SmallA.booleanvalue = convert(BQT2.SmallB.IntNum, boolean) AND BQT1.SmallA.IntKey >= 0 AND BQT2.SmallB.IntKey >= 0 ORDER BY BQT1.SmallA.IntNum";
+ String output = "SELECT SmallA.IntNum, SmallB.BooleanValue FROM SmallA, SmallB WHERE SmallA.BooleanValue = CASE WHEN SmallB.IntNum = 0 THEN '0' WHEN SmallB.IntNum IS NOT NULL THEN '1' END AND SmallA.IntKey >= 0 AND SmallB.IntKey >= 0 ORDER BY SmallA.IntNum";
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
+ input,
+ output, TRANSLATOR);
+
+
+ }
+
+
+}
Added: branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestSubstringFunctionModifier.java
===================================================================
--- branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestSubstringFunctionModifier.java (rev 0)
+++ branches/7.1.x/connectors/translator-netezza/src/test/java/org/teiid/translator/jdbc/netezza/TestSubstringFunctionModifier.java 2011-11-10 17:48:21 UTC (rev 3631)
@@ -0,0 +1,98 @@
+/*
+ * 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.netezza;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+/**
+ */
+public class TestSubstringFunctionModifier extends TestCase {
+
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+
+ /**
+ * Constructor for TestSubstringFunctionModifier.
+ * @param name
+ */
+ public TestSubstringFunctionModifier(String name) {
+ super(name);
+ }
+
+ public void helpTestMod(Expression[] args, String expectedStr) throws Exception {
+ Function func = LANG_FACTORY.createFunction("substring",
+ Arrays.asList(args), TypeFacility.RUNTIME_TYPES.STRING);
+
+ NetezzaExecutionFactory trans = new NetezzaExecutionFactory();
+ trans.start();
+
+ SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
+ sqlVisitor.append(func);
+
+ assertEquals(expectedStr, sqlVisitor.toString());
+ }
+
+ public void testTwoArgs() throws Exception {
+ Expression[] args = new Expression[] {
+ LANG_FACTORY.createLiteral("a.b.c", String.class),
+ LANG_FACTORY.createLiteral(new Integer(1), Integer.class)
+ };
+ helpTestMod(args, "substring('a.b.c', 1)");
+ }
+
+ public void testThreeArgsWithConstant() throws Exception {
+ Expression[] args = new Expression[] {
+ LANG_FACTORY.createLiteral("a.b.c", String.class),
+ LANG_FACTORY.createLiteral(new Integer(3), Integer.class),
+ LANG_FACTORY.createLiteral(new Integer(1), Integer.class)
+ };
+ helpTestMod(args, "substring('a.b.c', 3, 1)");
+ }
+
+ public void testThreeArgsWithElement() throws Exception {
+ Expression[] args = new Expression[] {
+ LANG_FACTORY.createLiteral("a.b.c", String.class),
+ LANG_FACTORY.createColumnReference("e1", null, null, Integer.class),
+ LANG_FACTORY.createLiteral(new Integer(1), Integer.class)
+ };
+ helpTestMod(args, "substring('a.b.c', e1, 1)");
+ }
+
+ public void testThreeArgsWithNull() throws Exception {
+ Expression[] args = new Expression[] {
+ LANG_FACTORY.createLiteral("a.b.c", String.class),
+ LANG_FACTORY.createLiteral(null, Integer.class),
+ LANG_FACTORY.createLiteral(new Integer(5), Integer.class)
+ };
+ helpTestMod(args, "substring('a.b.c', NULL, 5)");
+ }
+
+}
13 years, 1 month
teiid SVN: r3630 - in branches/as7/build/kits/jboss-as7: standalone/configuration and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-11-10 12:02:42 -0500 (Thu, 10 Nov 2011)
New Revision: 3630
Modified:
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
Log:
TEIID-1720: Correcting the SF addition
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml 2011-11-10 16:48:57 UTC (rev 3629)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml 2011-11-10 17:02:42 UTC (rev 3630)
@@ -12,6 +12,6 @@
<module name="org.apache.log4j"/>
<module name="org.jboss.teiid.common-core" />
<module name="org.jboss.teiid.api" />
- <module name="org.jboss.teiid.transalator.salesforce.api"/>
+ <module name="org.jboss.teiid.translator.salesforce.api"/>
</dependencies>
</module>
\ No newline at end of file
Modified: branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-11-10 16:48:57 UTC (rev 3629)
+++ branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-11-10 17:02:42 UTC (rev 3630)
@@ -476,6 +476,7 @@
<translator name="loopback" module="org.jboss.teiid.translator.loopback"/>
<translator name="olap" module="org.jboss.teiid.translator.olap"/>
<translator name="ws" module="org.jboss.teiid.translator.ws"/>
+ <translator name="salesforce" module="org.jboss.teiid.translator.salesforce"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:threads:1.0">
13 years, 1 month
teiid SVN: r3629 - in trunk/engine/src: main/java/org/teiid/query/validator and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-10 11:48:57 -0500 (Thu, 10 Nov 2011)
New Revision: 3629
Modified:
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1821 fix for default expression resolving/validation
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2011-11-10 16:29:43 UTC (rev 3628)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2011-11-10 16:48:57 UTC (rev 3629)
@@ -349,7 +349,7 @@
if (column.getDefaultExpression() == null) {
continue;
}
- ResolverVisitor.resolveLanguageObject(column.getDefaultExpression(), metadata);
+ visitNode(column.getDefaultExpression());
Expression ex = ResolverUtil.convertExpression(column.getDefaultExpression(), DataTypeManager.getDataTypeName(column.getSymbol().getType()), metadata);
column.setDefaultExpression(ex);
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-11-10 16:29:43 UTC (rev 3628)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-11-10 16:48:57 UTC (rev 3629)
@@ -1385,7 +1385,7 @@
boolean hasOrdinal = false;
for (XMLColumn xc : obj.getColumns()) {
if (!xc.isOrdinal()) {
- if (xc.getDefaultExpression() != null && !EvaluatableVisitor.isFullyEvaluatable(obj, false)) {
+ if (xc.getDefaultExpression() != null && !EvaluatableVisitor.isFullyEvaluatable(xc.getDefaultExpression(), false)) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_default", xc.getDefaultExpression()), obj); //$NON-NLS-1$
}
continue;
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-11-10 16:29:43 UTC (rev 3628)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-11-10 16:48:57 UTC (rev 3629)
@@ -1791,6 +1791,10 @@
@Test public void testXMLTablePassingMultipleContext() {
helpValidate("select * from pm1.g1, xmltable('/' passing xmlparse(DOCUMENT '<a/>'), xmlparse(DOCUMENT '<b/>')) as x", new String[] {"XMLTABLE('/' PASSING XMLPARSE(DOCUMENT '<a/>'), XMLPARSE(DOCUMENT '<b/>')) AS x"}, RealMetadataFactory.example1Cached());
}
+
+ @Test public void testInvalidDefault() {
+ helpValidate("select * from pm1.g1, xmltable('/' passing xmlparse(DOCUMENT '<a/>') columns y string default 'a', x string default (select e1 from pm1.g1)) as x", new String[] {"XMLTABLE('/' PASSING XMLPARSE(DOCUMENT '<a/>') COLUMNS y string DEFAULT 'a', x string DEFAULT (SELECT e1 FROM pm1.g1)) AS x"}, RealMetadataFactory.example1Cached());
+ }
@Ignore("this is actually handled by saxon and will show up during resolving")
@Test public void testXMLTablePassingSameName() {
13 years, 1 month
teiid SVN: r3628 - in trunk/engine/src: main/java/org/teiid/query/sql/lang and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-10 11:29:43 -0500 (Thu, 10 Nov 2011)
New Revision: 3628
Modified:
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestCriteriaEvaluator.java
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
Log:
TEIID-1820 updating the match logic to use find and optimizing generated regex
Modified: trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2011-11-10 02:29:40 UTC (rev 3627)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2011-11-10 16:29:43 UTC (rev 3628)
@@ -435,7 +435,7 @@
}
Matcher matcher = patternRegex.matcher(search);
- return matcher.matches();
+ return matcher.find();
}
private Boolean evaluate(AbstractSetCriteria criteria, List<?> tuple)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java 2011-11-10 02:29:40 UTC (rev 3627)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java 2011-11-10 16:29:43 UTC (rev 3628)
@@ -292,11 +292,17 @@
public String getPatternString(String pattern, char escape)
throws ExpressionEvaluationException {
- StringBuffer newPattern = new StringBuffer("^"); //$NON-NLS-1$
+ int startChar = 0;
+ StringBuffer newPattern = new StringBuffer(pattern.length());
+ if (pattern.length() > 0 && pattern.charAt(0) == '%') {
+ startChar = 1;
+ } else {
+ newPattern.append('^');
+ }
boolean escaped = false;
-
- for (int i = 0; i < pattern.length(); i++) {
+ boolean endsWithMatchAny = false;
+ for (int i = startChar; i < pattern.length(); i++) {
char character = pattern.charAt(i);
if (character == escape && character != NULL_ESCAPE_CHAR) {
@@ -313,6 +319,10 @@
appendCharacter(newPattern, character);
escaped = false;
} else {
+ if (character == '%' && i == pattern.length() - 1) {
+ endsWithMatchAny = true;
+ continue;
+ }
newPattern.append(replacements[index]);
}
} else {
@@ -328,7 +338,9 @@
throw new ExpressionEvaluationException(QueryPlugin.Util.getString("MatchCriteria.invalid_escape", new Object[] {pattern, new Character(escape)})); //$NON-NLS-1$
}
- newPattern.append('$');
+ if (!endsWithMatchAny) {
+ newPattern.append('$');
+ }
return newPattern.toString();
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/eval/TestCriteriaEvaluator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/eval/TestCriteriaEvaluator.java 2011-11-10 02:29:40 UTC (rev 3627)
+++ trunk/engine/src/test/java/org/teiid/query/processor/eval/TestCriteriaEvaluator.java 2011-11-10 16:29:43 UTC (rev 3628)
@@ -156,10 +156,6 @@
helpTestMatch("xx", "%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testMatch6() throws Exception {
- helpTestMatch("xx", "%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
@Test public void testMatch7() throws Exception {
helpTestMatch("a", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -172,10 +168,6 @@
helpTestMatch("a.", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testMatch10() throws Exception {
- helpTestMatch("a.", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
@Test public void testMatch11() throws Exception {
helpTestMatch("ax.", "a%", MatchCriteria.NULL_ESCAPE_CHAR, true); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2011-11-10 02:29:40 UTC (rev 3627)
+++ trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2011-11-10 16:29:43 UTC (rev 3628)
@@ -504,6 +504,11 @@
assertEquals(Boolean.FALSE, Evaluator.evaluate(ex));
}
+ @Test public void testLikeRegex4() throws Exception {
+ Expression ex = TestFunctionResolving.getExpression("'xay' like_regex 'a'");
+ assertEquals(Boolean.TRUE, Evaluator.evaluate(ex));
+ }
+
@Test public void testLikePlus() throws Exception {
Expression ex = TestFunctionResolving.getExpression("'+' like '+'");
assertEquals(Boolean.TRUE, Evaluator.evaluate(ex));
13 years, 1 month
teiid SVN: r3627 - trunk/documentation/admin-guide/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-09 21:29:40 -0500 (Wed, 09 Nov 2011)
New Revision: 3627
Modified:
trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
Log:
TEIID-1816 clarifications to the security chapter
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-11-10 02:10:03 UTC (rev 3626)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/security.xml 2011-11-10 02:29:40 UTC (rev 3627)
@@ -10,8 +10,9 @@
<section>
<title>Authentication</title>
<para>JDBC clients may use simple passwords to authenticate a user.</para>
+
<para>Typically a user name is required, however user names may be considered optional if the
- identity of the user can be discerned by the password credential alone. In
+ identity of the user can be discerned by the password credential alone. In
any case it is up to the configured security domain to determine whether a user can be
authenticated. If you need authentication, the administrator must configure a LoginModule to be used with Teiid.
See below for more information on how configure the Login module in JBoss AS.</para>
@@ -25,25 +26,26 @@
<section>
<title>Pass-through Authentication</title>
<para>If your client application (web application or Web service) resides in the same JBoss AS instance as Teiid and
- client application uses a security-domain to handle the security concerns, then you can configure Teiid to use the
- same security-domain and not force the user to re-authenticate for using Teiid. In this case Teiid looks for a authenticated
- subject in the calling thread context and uses for its session and authorization purposes. To configure Teiid for this
- pass-through authentication mechanism, you need change the Teiid's security-domain name to same name as your
+ the client application uses a security-domain, then you can configure Teiid to use the
+ same security-domain and not force the user to re-authenticate. In this case Teiid looks for an authenticated
+ subject in the calling thread context and uses it for sessioning and authorization. To configure Teiid for
+ pass-through authentication, change the Teiid security-domain name to the same name as your
application's security domain name in the "teiid-jboss-beans.xml" file in the SessionService section.
Please note that for this to work, the security-domain
- must be a JAAS based Login Module and your client application MUST obtain Teiid connection
- using <emphasis>Local</emphasis> Connection, with <emphasis>PassthroughAuthentication=true</emphasis> flag set.</para>
+ must be a JAAS based Login Module and your client application MUST obtain its Teiid connection
+ using a <emphasis>local/embedded</emphasis> connection with the<emphasis>PassthroughAuthentication=true</emphasis> connection flag set.</para>
</section>
</section>
<section>
<title>Authorization</title>
<para>Authorization covers both administrative activities and data
- roles. A data role is a collection of permissions (also referred to as entitlements) and a
+ roles. A data role is a collection of permissions (also referred to as entitlements) and a
collection of entitled principals or groups. With the deployment of a VDB
the deployer can choose which principals and groups have which data roles.</para>
</section>
<section>
<title>Encryption</title>
+
<para>At a transport level Teiid provides built-in support for JDBC
over SSL or just sensitive message encryption when SSL is not in use.
</para>
@@ -57,6 +59,7 @@
</section>
<section>
<title>LoginModules</title>
+
<para>
LoginModules are an essential part of the JAAS security
framework and provide Teiid customizable user authentication and the
@@ -69,7 +72,7 @@
that group together relevant LoginModules. Each of these application
policy (or domains) names can be used to fully
qualify user names to
- authenticate only against that domain. The format for a qualified
+ authenticate only against that domain. The format for a qualified
name is username@domainname.
</para>
<para>If a user name is not fully qualified, then the installed
@@ -77,6 +80,7 @@
successfully or unsuccessfully authenticates the
user.
</para>
+
<para>If no domain can authenticate the user, the login
attempt will fail.
Details of the failed attempt including invalid users, which
@@ -94,18 +98,20 @@
<section>
<title>Built-in LoginModules</title>
<para>JBossAS provides several LoginModules for common authentication needs, such as authenticating from a <xref linkend="text-login"/> or a <xref linkend="ldap-login"/>.</para>
+
<para>You can install multiple login modules as part of single security domain configuration and configure them
to part of login process. For example, for "teiid-security" domain, you can configure a file based and also LDAP based login modules,
- and have your user authenticated with either or both login modules. If you want to write your own custom login module, check out the Developer's Guide for instructions.
+ and have your user authenticated with either or both login modules. If you want to write your own custom login module, refer to the Developer's Guide for instructions.
</para>
<section id="text-login">
<title>Text Based LoginModule</title>
- <para>The UsersRolesLoginModule utilizes simple text files to authenticate users and to define their groups.
+ <para>The UsersRolesLoginModule utilizes simple text files to authenticate users and to define their groups.
The teiid-jboss-beans.xml configuration file contains an example of how to use UsersRolesLoginModule.
-<note><para>The UsersRolesLoginModule is not recommended for production use and is strongly recommended that you replace this login module.</para></note>
+<note><para>The UsersRolesLoginModule is not recommended for production use and it is strongly recommended that you replace this login module.</para></note>
</para>
<para>User names and passwords are stored in the <profile>conf/props/teiid-security-users.properties file.
+
<example><title>Example user.properties file</title>
<programlisting><![CDATA[# A users.properties file for use with the UsersRolesLoginModule
# username=password
@@ -144,6 +150,7 @@
<para>Reuse the jmx-console (or whatever name you choose) security domain for Teiid by changing the teiid configuration &jboss-beans; to point to jmx-console, rather than teiid-security.
</para>
</listitem>
+
<listitem>
<para>Follow the same steps to configure an LDAP security domain named teiid-security.
</para>
@@ -154,8 +161,9 @@
</listitem>
</itemizedlist>
</para></listitem>
+
<listitem><para>Obscure the LDAP Password</para><para>Finally, protect the password following <ulink url="http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/5...">these instructions.</ulink>
- Note that the salt must be 8 chars andd see also http://community.jboss.org/message/137756#137756 for more on securing passwords.
+ Note that the salt must be 8 chars and see also http://community.jboss.org/message/137756#137756 for more on securing passwords.
</para></listitem>
</orderedlist>
</para>
@@ -163,6 +171,7 @@
</section>
<section>
+
<title>Kerberos support through GSSAPI</title>
<para>Teiid supports kerberos authentication using GSSAPI, to be used with single sign-on applications.
This service ticket negotiation based authentication is supported through remote JDBC and ODBC drivers and LocalConnections.
@@ -175,6 +184,7 @@
authentication of your web-application with kerberos. When the web application authenticates with the provided
kerberos token, the same subject authenticated will be used in Teiid. For details about configuration, check the
JBoss Negotiation documentation.</para>
+
</section>
<section>
@@ -218,6 +228,7 @@
</login-module>
</authentication>
</application-policy>]]></programlisting>
+
Edit the "run.conf" or "run.conf.bat" file depending upon the environment in the "${jboss-as}/bin" directory
and add the following JVM options (changing the realm and KDC settings according to your environment)
<programlisting><![CDATA[JAVA_OPTS = "$JAVA_OPTS -Djava.security.krb5.realm=EXAMPLE.COM -Djava.security.krb5.kdc=kerberos.example.com -Djavax.security.auth.useSubjectCredsOnly=false"]]></programlisting>
@@ -250,10 +261,11 @@
Add the following URL connection properties to Teiid JDBC connection string
<programlisting><![CDATA[authenticationType=KRB5;jaasName=Client;kerberosServicePrincipleName=demo(a)EXAMPLE.COM]]></programlisting>
- There is no need to provide the user name and password, when the application is trying to make JDBC connection it
- will authenticate locally and use the same user credetinals to neogitiate service token with server and grant the
+ There is no need to provide the user name and password. When the application makes a JDBC connection, it
+ will authenticate locally and use the same user credentials to negotiate a service token with server and grant the
connection. See Client Developer's guide for information on connection properties and how to configure data sources.
</para>
+
</section>
</section>
@@ -265,9 +277,10 @@
</section>
<section>
+
<title>Security at Data Source level</title>
- <para>In some use cases, user might need to pass-in different credentials to their data sources based on the logged in user
- than using the shared credentials for all the logged users. To support this feature, JBoss AS and Teiid provide multiple different
+ <para>In some use cases, the user might need to pass-in different credentials to their data sources based on the logged in user
+ rather than using the shared credentials for all the logged users. To support this feature, JBoss AS and Teiid provide multiple different
login modules to be used in conjunction with Teiid's main security domain. See this
<ulink url="http://community.jboss.org/docs/DOC-9350">document</ulink> for details on configuration. Note that the below
directions need to be used in conjunction with this document.</para>
@@ -302,27 +315,28 @@
<programlisting><![CDATA[<security-domain>teiid-security</security-domain>]]></programlisting>
- <para>In the above configuration example, in the primary login module "UsersRolesLoginModule" is setup to hold the
+ <para>In the above configuration example, in the primary login module "UsersRolesLoginModule" is set up to hold the
passwords in the file, and when user logs in with password, the same password will be also set on the logged in Subject after
- authentication. This credentials can be extracted by the data source by asking for Subject's private credentials.</para>
+ authentication. These credentials can be extracted by the data source by asking for Subject's private credentials.</para>
- <para>To use a certificate or serialized object instead of plain password as the token, simply replace the simple text password
- with Base64 encoded contents of the serialized object. Please note that, encoding and decoding of this object
- is strictly up to the user as JBoss AS and Teiid will only act like carrier of the information from
+ <para>To use a certificate or serialized object instead of plain password as the token, replace the simple text password
+ with Base64 encoded contents of the serialized object. Please note that encoding and decoding of this object
+ is strictly up to the user as JBoss AS and Teiid will only act as a carrier of the information from
login module to connection factory. Using this CallerIdentity module, the connection pool for data source is segmented
by Subject.</para>
</section>
<section>
+
<title>Role Based Credential Map</title>
- <para>In some use cases, the users are divided by their functionality and they have varied level of security access to
+ <para>In some use cases, the users are divided by their functionality and they have varied levels of security access to
data sources. These types of users are identified by their roles as to what they have access to. In the above "CallerIdentity"
login scenario, that may be too fine-grained security at data sources, that can lead resource exhaustion as every user has
their own separate connection.
Using Role based security gives a balance, where the users with same role are treated equally
for authentication purposes at the data source. Teiid provides a login module called "RoleBasedCredentialMap"
- for this purposes, where administrator can define a role based authentication module, where given the role of the user
- from the primary login module, this module will hold credentail to that role. So, it is container of credentials that
- map to different roles. If a user has multiple roles, the first role that has the credential will be chosen.
+ for this purposes, where administrator can define a role-based authentication module, where given the role of the user
+ from the primary login module, this module will hold a credential to that role. So, it is the container of credentials that
+ maps to different roles. If a user has multiple roles, the first role that has the credential will be chosen.
Below find the sample configuration.</para>
<programlisting><![CDATA[<application-policy xmlns="urn:jboss:security-beans:1.0" name="teiid-security">
@@ -347,7 +361,7 @@
<programlisting><![CDATA[<security-domain>teiid-security</security-domain>]]></programlisting>
- <para>In the above configuration example, in the primary login module "UsersRolesLoginModule" is setup for logging in
+ <para>In the above configuration example, in the primary login module "UsersRolesLoginModule" is set up for logging in
the primary user and assign some roles. The "RoleBasedCredentialMap" login module is configured to hold
role to password information in the file defined by "credentialMap" property. When user logs in, the role information
from the primary login module is taken, and extracts the role's passsword and attaches as
@@ -383,8 +397,9 @@
<para>The Teiid's configuration file
<code><jboss-install>/server/<profile>/deploy/teiid/teiid-jboss-beans.xml</code>,
contains the properties to configure SSL per socket transport.</para>
+
<itemizedlist>
- <para>There are three socket transports, each with it's own SSL configuration:</para>
+ <para>There are three socket transports, each with its own SSL configuration:</para>
<listitem><para>JDBC Connections - uses the <code>JdbcSslConfiguration</code> bean configuration. Defaults to only encrypt login traffic, none of the other properties are used.</para></listitem>
<listitem><para>Admin Connections - uses the <code>AdminSslConfiguration</code> bean configuration. Defaults to encrypting all traffic with anonymous SSL, none of the other properties are used.</para></listitem>
<listitem><para>ODBC Connections - uses the <code>OdbcSslConfiguration</code> bean configuration. Defaults to no SSL.</para></listitem>
@@ -407,6 +422,7 @@
</example>
<itemizedlist>
<title>Properties</title>
+
<listitem><para>mode - diabled|login|enabled, disabled = no transport or message level security will be used.
login = only the login traffic will be encrypted at a message level using 128 bit AES with an ephemerial DH key exchange. No other config values are needed in this mode.
enabled = traffic will be secured using the other configuration properties.</para></listitem>
@@ -415,8 +431,10 @@
<listitem><para>authenticationMode - anonymous|1-way|2-way, Type of <link linkend="ssl_auth">SSL Authentication Mode</link>.</para></listitem>
<listitem><para>keymanagementAlgorithm - Type of key algorithm used. Default
is based upon the VM, e.g. "SunX509"</para></listitem>
+
<listitem><para>keystoreFilename - The file name of the keystore, which contains the
- private key of the Server. This must be available in the classpath of Teiid Server.</para></listitem>
+ private key of the Server. The file name can be relative resource path available to the Teiid deployer classloader or an absolute file system path.
+ A typical installation would place the keystore file in the conf directory of the profile where Teiid is deployed with a file name relative to the conf path.</para></listitem>
<listitem><para>keystorePassword - password for the keystore.</para></listitem>
<listitem><para>truststoreFilename - if "authenticationMode" is chosen
as "2-way", then this property must be provided. This is the truststore that contains the
@@ -426,6 +444,7 @@
<listitem><para>enabledCipherSuites - A comma separated list of cipher suites allowed for encryption between server and client. The values must be valid supported cipher suites otherwise SSL connections will fail.</para></listitem>
</itemizedlist>
<section id="ssl_auth">
+
<title>SSL Authentication Modes</title>
<para>SSL supports multiple authentication modes. In most secure intranet environments, anonymous is suitable to just bulk encrypt traffic without the need
to setup SSL certificates.
@@ -437,6 +456,7 @@
<listitem><para><emphasis>1-way</emphasis> - the server will present a certificate, which is obtained from the keystore related properties.
The client should have a truststore configured to accept the server certificate.
</para></listitem>
+
<listitem><para><emphasis>2-way</emphasis> - the server will present a certificate, which is obtained from the keystore related properties.
The client should have a truststore configured to accept the server certificate. The client is also expected to present a certificate, which is obtained from its
keystore. The client certificate should be accepted by the trust store configured by the truststore related properties.
@@ -449,6 +469,7 @@
1-way and 2-way SSL allow for cipher suite negotiation based upon the default cipher suites supported by the respective Java platforms of the client and server.
User can restrict the cipher suites used for encryption by specifying the <emphasis>enabledCipherSuites</emphasis> property above in ssl configuration.
</para>
+
</section>
</section>
-</chapter>
\ No newline at end of file
+</chapter>
13 years, 1 month
teiid SVN: r3625 - in trunk: documentation/developer-guide/src/main/docbook/en-US/content and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-09 15:55:17 -0500 (Wed, 09 Nov 2011)
New Revision: 3625
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
Log:
TEIID-1726 adding the ability to pass source hints through the teiid system
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-11-09 20:06:24 UTC (rev 3624)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-11-09 20:55:17 UTC (rev 3625)
@@ -38,6 +38,7 @@
<LI><B>View removal hint</B> - the NO_UNNEST hint now also applies to from clause views and subqueries. It will instruct the planner to not perform view flattening.
<LI><B>Non-blocking statement execution</B> - Teiid JDBC extensions TeiidStatement and TeiidPreparedStatement can be used to submit queries against embedded connections with a callback to process results in a non-blocking manner.
<LI><B>NON_STRICT limit hint</B> - the NON_STRICT hint can be used with unordered limits to tell the optimizer to not inhibit push operations even if the results will not be consistent with the logical application of the limit.
+ <LI><B>Source Hints</B> - user and transformation queries can specify a meta source hint, e.g. SELECT /*+ sh my-oracle:'leading' */ * FROM TBL. The hint information will be passed to the passed to the translator. The Oracle translator will by default treat the source hint as an Oracle hint.
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-11-09 20:06:24 UTC (rev 3624)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-11-09 20:55:17 UTC (rev 3625)
@@ -227,21 +227,37 @@
interface that defines how executions are
cancelled and closed. ProcedureExecution also extends ResultSetExecution, since procedures may also return resultsets.</para>
</section>
+
<section>
+ <title>ExecutionContext</title>
+ <para>The <code>org.teiid.translator.ExecutionContext</code> provides a considerable amount of information related to the current execution.
+ An <code>ExecutionContext</code> instance is made available to each <code>Execution</code>. Specific usage is highlighted in this guide where applicable, but you may use any informational getter method as desired.
+ Example usage would include calling <code>ExecutionContext.getRequestIdentifier()</code>, <code>ExecutionContext.getSession()</code>, etc. for logging purposes.</para>
+
+ <section>
+ <title>Source Hints</title>
+ <para>The Teiid source meta-hint is used to provide hints directly to source executions via user or transformation queries. See the reference for more on source hints. If specified and applicable, the general and source specific
+ hint will be supplied via the ExecutionContext methods <code>getGeneralHint</code> and <code>getSourceHint</code>. See the source for the <code>OracleExecutionFactory</code> for an example of how this source hint information
+ can be utilized.</para>
+ </section>
+
+ </section>
+
+ <section>
<title>ResultSetExecution</title>
<para>
Typically most commands executed against translators are QueryExpression.
While the command is being executed, the translator provides results via the
ResultSetExecution's "next" method. The "next" method should return null to indicate the end
of results. Note: the expected batch size can be obtained from the
- ExecutionContext and used as a hint in fetching results from the EIS.
+ <code>ExecutionContext.getBatchSize()</code> method and used as a hint in fetching results from the EIS.
</para>
</section>
<section>
<title>Update Execution</title>
<para>Each execution returns the update count(s) expected by the update command.
If possible BatchedUpdates should be executed atomically.
- The ExecutionContext can be used to determine if the execution is already under a transaction.</para>
+ The <code>ExecutionContext.isTransactional()</code> method can be used to determine if the execution is already under a transaction.</para>
</section>
<section>
<title>Procedure Execution</title>
@@ -271,7 +287,7 @@
The
<code>DataNotAvailableException.NO_POLLING</code>
exception (or any DataNotAvailableException with a negative delay) can be thrown to indicate that
- the execution will call <code>ExecutionContext.dataAvailable</code> to indicate processing should resume.
+ the execution will call <code>ExecutionContext.dataAvailable()</code> to indicate processing should resume.
</para>
</note>
</para>
@@ -320,6 +336,7 @@
termination of queries being processed and may allow the underlying data source to terminate its operations
faster as well.</para>
</section>
+
</section>
<section id="command_language">
@@ -1497,8 +1514,8 @@
connection is either closed/released as soon as all rows for that
execution have been retrieved. However, LOB objects may need to be
read after their initial retrieval of results. When LOBs are detected
- the default closing behavior is prevented by setting a flag on the
- ExecutionContext. See ExecutionContext.keepAlive() method. </para>
+ the default closing behavior is prevented by setting a flag via the
+ <code>ExecutionContext.keepAlive</code> method. </para>
<para>When the "keepAlive" alive flag is set, then the execution object is only closed when user's Statement is closed.</para>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2011-11-09 20:06:24 UTC (rev 3624)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2011-11-09 20:55:17 UTC (rev 3625)
@@ -712,9 +712,20 @@
</tbody>
</tgroup>
</informaltable>
- <para />
</section>
</section>
+ <section>
+ <title>Source Hints</title>
+ <para>Teiid user and transformation queries can contain a meta source hint that can provide additional information to source queries.
+ The source hint has the form /*+ sh(:'arg') source-name:'arg1' ... */ and is expected to appear after the query keyword, e.g. "SELECT /*+ sh:'general hint' my-oracle:'oracle hint' */.
+ The sh arg is optional and is passed to all source queries via the <code>ExecutionContext.getGeneralHint</code> method. See the Developer's Guide for more onThe additional args should have source-name that matches
+ the source name assigned to the translator in the VDB. If the source-name matches the hint value will be supplied via the <code>ExecutionContext.getSourceHint</code> method.
+ See the Developer's Guide for more on using an ExecutionContext.
+ Each of the arg values has the form of a string literal - it must be surrounded in single quotes and a single quote can be escaped with another signle quote.
+ Only the Oracle translator does anything with source hints by default. The Oracle translator will use either the source hint or the general hint (in that order) if available to form an Oracle hint enclosed in
+ /*+ ... */. Source hints in views will not be passed to the source if the view is used as a pushdown subquery, is joined, or is in a set operation.
+ </para>
+ </section>
</section>
<section id="query_planner">
<title>Query Planner</title>
13 years, 1 month
teiid SVN: r3624 - in trunk: api/src/main/java/org/teiid/translator and 24 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-11-09 15:06:24 -0500 (Wed, 09 Nov 2011)
New Revision: 3624
Added:
trunk/engine/src/main/java/org/teiid/query/sql/lang/SourceHint.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java
Modified:
trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
trunk/common-core/src/main/java/org/teiid/core/util/SqlUtil.java
trunk/common-core/src/test/java/org/teiid/core/util/TestSqlUtil.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java
trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
Log:
TEIID-1726 adding the ability to pass source hints through the teiid system
Modified: trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -97,6 +97,7 @@
protected static final String UNDEFINED_PARAM = "?"; //$NON-NLS-1$
protected StringBuilder buffer = new StringBuilder();
+ private boolean appendedSourceComment;
/**
* Gets the name of a group or element from the RuntimeMetadata
@@ -230,7 +231,7 @@
public void visit(Delete obj) {
buffer.append(DELETE)
.append(Tokens.SPACE);
- buffer.append(getSourceComment(obj));
+ appendSourceComment(obj);
buffer.append(FROM)
.append(Tokens.SPACE);
append(obj.getTable());
@@ -242,6 +243,14 @@
}
}
+ private void appendSourceComment(Command obj) {
+ if (appendedSourceComment) {
+ return;
+ }
+ appendedSourceComment = true;
+ buffer.append(getSourceComment(obj));
+ }
+
/**
* Take the specified derived group and element short names and determine a
* replacement element name to use instead. Most commonly, this is used to strip
@@ -502,7 +511,7 @@
public void visit(Insert obj) {
buffer.append(INSERT).append(Tokens.SPACE);
- buffer.append(getSourceComment(obj));
+ appendSourceComment(obj);
buffer.append(INTO).append(Tokens.SPACE);
append(obj.getTable());
buffer.append(Tokens.SPACE).append(Tokens.LPAREN);
@@ -725,7 +734,7 @@
append(obj.getWith());
}
buffer.append(SELECT).append(Tokens.SPACE);
- buffer.append(getSourceComment(obj));
+ appendSourceComment(obj);
if (obj.isDistinct()) {
buffer.append(DISTINCT).append(Tokens.SPACE);
}
@@ -851,7 +860,7 @@
public void visit(Update obj) {
buffer.append(UPDATE)
.append(Tokens.SPACE);
- buffer.append(getSourceComment(obj));
+ appendSourceComment(obj);
append(obj.getTable());
buffer.append(Tokens.SPACE)
.append(SET)
@@ -912,7 +921,7 @@
protected void appendSetQuery(SetQuery parent, QueryExpression obj, boolean right) {
if((!(obj instanceof SetQuery) && useParensForSetQueries())
- || (right && ((obj instanceof SetQuery
+ || (!useSelectLimit() && (obj.getLimit() != null || obj.getOrderBy() != null)) || (right && ((obj instanceof SetQuery
&& ((parent.isAll() && !((SetQuery)obj).isAll())
|| parent.getOperation() != ((SetQuery)obj).getOperation())) || obj.getLimit() != null || obj.getOrderBy() != null))) {
buffer.append(Tokens.LPAREN);
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -100,6 +100,18 @@
* @since 4.2
*/
Serializable getExecutionPayload();
+
+ /**
+ * Get the general hint passed to all executions under the user query.
+ * @return the general hint or null if none was specified
+ */
+ String getGeneralHint();
+
+ /**
+ * Get the hint designated for this source.
+ * @return the source hint or null if none was specified
+ */
+ String getSourceHint();
/**
* Get the identifier for the connection through which
Modified: trunk/common-core/src/main/java/org/teiid/core/util/SqlUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/SqlUtil.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/common-core/src/main/java/org/teiid/core/util/SqlUtil.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -23,9 +23,9 @@
package org.teiid.core.util;
import java.sql.SQLException;
-
import java.sql.SQLFeatureNotSupportedException;
-
+import java.util.TreeSet;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
@@ -36,8 +36,17 @@
public static final char NL_CHAR = StringUtil.Constants.NEW_LINE_CHAR;
public static final char SPACE_CHAR = StringUtil.Constants.SPACE_CHAR;
public static final char TAB_CHAR = StringUtil.Constants.TAB_CHAR;
- private static Pattern PATTERN = Pattern.compile("^([\\s]|(/\\*.*\\*/))*(insert|update|delete|create|drop|(select([\\s]|(/\\*.*\\*/))+.*into([\\s]|(/\\*.*\\*/))+)).*", Pattern.CASE_INSENSITIVE|Pattern.MULTILINE); //$NON-NLS-1$
-
+ private static TreeSet<String> updateKeywords = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ static {
+ updateKeywords.add("insert"); //$NON-NLS-1$
+ updateKeywords.add("update"); //$NON-NLS-1$
+ updateKeywords.add("delete"); //$NON-NLS-1$
+ updateKeywords.add("drop"); //$NON-NLS-1$
+ updateKeywords.add("create"); //$NON-NLS-1$
+ }
+ private static Pattern PATTERN = Pattern.compile("^(?:\\s|(?:/\\*.*\\*/))*(\\w*)\\s", Pattern.CASE_INSENSITIVE|Pattern.DOTALL); //$NON-NLS-1$
+ private static Pattern INTO_PATTERN = Pattern.compile("(?:'[^']*')|(\\sinto\\s)", Pattern.CASE_INSENSITIVE|Pattern.DOTALL); //$NON-NLS-1$
+
private SqlUtil() {
super();
}
@@ -52,10 +61,29 @@
* query or an update
*/
public static boolean isUpdateSql(String sql) throws IllegalArgumentException {
- ArgCheck.isNotNull(sql);
- return PATTERN.matcher(sql).matches();
+ String keyWord = getKeyword(sql);
+ return updateKeywords.contains(keyWord);
}
+ public static String getKeyword(String sql) {
+ Matcher matcher = PATTERN.matcher(sql);
+ if (!matcher.find()) {
+ return sql; //shouldn't happen
+ }
+ String keyword = matcher.group(1);
+ if (keyword.equalsIgnoreCase("select")) { //$NON-NLS-1$
+ int end = matcher.end();
+ Matcher intoMatcher = INTO_PATTERN.matcher(sql);
+ while (intoMatcher.find(end)) {
+ if (intoMatcher.group(1) != null) {
+ return "insert"; //$NON-NLS-1$
+ }
+ end = intoMatcher.end();
+ }
+ }
+ return keyword;
+ }
+
public static SQLException createFeatureNotSupportedException() {
return new SQLFeatureNotSupportedException();
}
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestSqlUtil.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestSqlUtil.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestSqlUtil.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -22,72 +22,71 @@
package org.teiid.core.util;
-import org.teiid.core.util.SqlUtil;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
-
+import org.junit.Test;
/**
*/
-public class TestSqlUtil extends TestCase {
+public class TestSqlUtil {
- public TestSqlUtil(String name) {
- super(name);
- }
-
public void helpTest(String sql, boolean isUpdate) {
boolean actual = SqlUtil.isUpdateSql(sql);
assertEquals(isUpdate, actual);
}
- public void testSelect() {
+ @Test public void testSelect() {
helpTest("SELECT x FROM y", false); //$NON-NLS-1$
}
- public void testInsert() {
+ @Test public void testInsert() {
helpTest("Insert INTO g (a) VALUES (1)", true); //$NON-NLS-1$
}
- public void testUpdate() {
+ @Test public void testUpdate() {
helpTest("upDate x set a=5", true); //$NON-NLS-1$
}
- public void testDelete() {
+ @Test public void testDelete() {
helpTest("delete FROM x", true); //$NON-NLS-1$
}
- public void testInsertWithWhitespace() {
+ @Test public void testInsertWithWhitespace() {
helpTest("\nINSERT INTO g (a) VALUES (1)", true); //$NON-NLS-1$
}
- public void testExec() {
+ @Test public void testExec() {
helpTest("exec sq1()", false); //$NON-NLS-1$
}
- public void testXquery() {
+ @Test public void testXquery() {
helpTest("<i/>", false); //$NON-NLS-1$
}
- public void testSelectInto1() {
+ @Test public void testSelectInto1() {
helpTest("SELECT x INTO z FROM y", true); //$NON-NLS-1$
}
- public void testSelectInto2() {
+ @Test public void testSelectInto2() {
helpTest("SELECT x, INTOz FROM y", false); //$NON-NLS-1$
}
- public void testSelectInto3() {
+ @Test public void testSelectInto3() {
helpTest("SELECT x into z FROM y", true); //$NON-NLS-1$
}
- public void testSelectInto4() {
+ @Test public void testSelectInto4() {
helpTest("SELECT x into z", true); //$NON-NLS-1$
}
- public void testCreate() {
+ @Test public void testSelectInto5() {
+ helpTest("SELECT x, ' into ' from z", false); //$NON-NLS-1$
+ }
+
+ @Test public void testCreate() {
helpTest(" create table x", true); //$NON-NLS-1$
}
- public void testDrop() {
+ @Test public void testDrop() {
helpTest("/* */ drop table x", true); //$NON-NLS-1$
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -54,6 +54,8 @@
import org.teiid.language.SQLConstants.Tokens;
import org.teiid.language.SetQuery.Operation;
import org.teiid.language.visitor.CollectorVisitor;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -66,6 +68,7 @@
import org.teiid.translator.jdbc.ExtractFunctionModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.JDBCPlugin;
import org.teiid.translator.jdbc.LocateFunctionModifier;
import org.teiid.translator.jdbc.TranslatedCommand;
@@ -79,6 +82,7 @@
private static final String TIMESTAMP_FORMAT = DATETIME_FORMAT + ".FF"; //$NON-NLS-1$
public final static String HINT_PREFIX = "/*+"; //$NON-NLS-1$
+ public static final String HINT_SUFFIX = "*/"; //$NON-NLS-1$
public final static String DUAL = "DUAL"; //$NON-NLS-1$
public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
@@ -345,17 +349,44 @@
public String getSourceComment(ExecutionContext context, Command command) {
String comment = super.getSourceComment(context, command);
+ boolean usingPayloadComment = false;
if (context != null) {
// Check for db hints
Object payload = context.getExecutionPayload();
if (payload instanceof String) {
String payloadString = (String)payload;
if (payloadString.startsWith(HINT_PREFIX)) {
- comment += payloadString + " "; //$NON-NLS-1$
+ int i = payloadString.indexOf(HINT_SUFFIX);
+ if (i > 0 && payloadString.substring(i + 2).trim().length() == 0) {
+ comment += payloadString + " "; //$NON-NLS-1$
+ usingPayloadComment = true;
+ } else {
+ String msg = JDBCPlugin.Util.getString("OraleExecutionFactory.invalid_hint", "Execution Payload", payloadString); //$NON-NLS-1$ //$NON-NLS-2$
+ context.addWarning(new TranslatorException(msg));
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
+ }
}
}
}
+ if (!usingPayloadComment && context != null) {
+ String hint = null;
+ hint = context.getSourceHint();
+ if (hint == null) {
+ hint = context.getGeneralHint();
+ }
+ if (hint != null) {
+ //append a source hint
+ if (!hint.contains(HINT_PREFIX)) {
+ comment += HINT_PREFIX + ' ' + hint + ' ' + HINT_SUFFIX + ' ';
+ } else {
+ String msg = JDBCPlugin.Util.getString("OraleExecutionFactory.invalid_hint", "Source Hint", hint); //$NON-NLS-1$ //$NON-NLS-2$
+ context.addWarning(new TranslatorException(msg));
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
+ }
+ }
+ }
+
if (command instanceof Select) {
//
// This simple algorithm determines the hint which will be added to the
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -77,6 +77,18 @@
helpTestVisitor(getOracleSpecificMetadata(), input, EMPTY_CONTEXT, null, expectedOutput);
}
+ @Test public void testSourceHint() throws Exception {
+ ExecutionContextImpl impl = new FakeExecutionContextImpl();
+ impl.setHint("hello world");
+ helpTestVisitor(getTestVDB(), "select part_name from parts", impl, null, "SELECT /*+ hello world */ g_0.PART_NAME FROM PARTS g_0", true);
+ }
+
+ @Test public void testSourceHint1() throws Exception {
+ ExecutionContextImpl impl = new FakeExecutionContextImpl();
+ impl.setHint("hello world");
+ helpTestVisitor(getTestVDB(), "select part_name from parts union select part_id from parts", impl, null, "SELECT /*+ hello world */ g_1.PART_NAME AS c_0 FROM PARTS g_1 UNION SELECT g_0.PART_ID AS c_0 FROM PARTS g_0", true);
+ }
+
@Test public void testInsertWithSequnce() throws Exception {
helpTestVisitor("insert into smalla (doublenum) values (1)", "INSERT INTO SmallishA (DoubleNum, ID) VALUES (1.0, MYSEQUENCE.nextVal)"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -702,6 +714,21 @@
false);
}
+ @Test public void testOracleCommentPayload1() throws Exception {
+ String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
+ String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
+
+ String hint = "/*+ ALL_ROWS */ something else"; //$NON-NLS-1$
+ ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", null, null, null); //$NON-NLS-1$
+
+ helpTestVisitor(getTestVDB(),
+ input,
+ context,
+ null,
+ output,
+ false);
+ }
+
/**
* reproducing this case relies on the name in source for the table being different from
* the name
@@ -788,7 +815,7 @@
@Test public void testRowLimitWithUnionOrderBy() throws Exception {
String input = "(select intkey from bqt1.smalla limit 50, 100) union select intnum from bqt1.smalla order by intkey"; //$NON-NLS-1$
- String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0"; //$NON-NLS-1$
+ String output = "(SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50) UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0"; //$NON-NLS-1$
CommandBuilder commandBuilder = new CommandBuilder(RealMetadataFactory.exampleBQTCached());
Command obj = commandBuilder.getCommand(input, true, true);
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -331,9 +331,11 @@
} catch (SizeLimitExceededException e) {
if (resultCount != searchDetails.getCountLimit()) {
String msg = "LDAP Search results exceeded size limit. Results may be incomplete."; //$NON-NLS-1$
+ TranslatorException te = new TranslatorException(e, msg);
if (executionFactory.isExceptionOnSizeLimitExceeded()) {
- throw new TranslatorException(e, msg);
+ throw te;
}
+ this.executionContext.addWarning(te);
LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, msg);
}
return null; // GHH 20080326 - if size limit exceeded don't try to read more results
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -98,6 +98,8 @@
Integer.toString(requestID.getNodeID()),
Integer.toString(requestID.getExecutionId())
);
+ this.securityContext.setGeneralHint(message.getGeneralHint());
+ this.securityContext.setHint(message.getHint());
this.securityContext.setUser(requestMsg.getWorkContext().getSubject());
this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
this.securityContext.setSession(requestMsg.getWorkContext().getSession());
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -69,6 +69,8 @@
private Session session;
private RequestWorkItem worktItem;
private boolean dataAvailable;
+ private String generalHint;
+ private String hint;
public ExecutionContextImpl(String vdbName, int vdbVersion, Serializable executionPayload,
String originalConnectionID, String connectorName, String requestId, String partId, String execCount) {
@@ -237,4 +239,22 @@
dataAvailable = false;
return result;
}
+
+ @Override
+ public String getGeneralHint() {
+ return generalHint;
+ }
+
+ @Override
+ public String getSourceHint() {
+ return hint;
+ }
+
+ public void setGeneralHint(String generalHint) {
+ this.generalHint = generalHint;
+ }
+
+ public void setHint(String hint) {
+ this.hint = hint;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -84,6 +84,7 @@
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.UnaryFromClause;
import org.teiid.query.sql.symbol.Constant;
@@ -192,6 +193,11 @@
}
AtomicRequestMessage aqr = createRequest(context.getProcessorID(), command, modelName, connectorBindingId, nodeID);
+ SourceHint sh = context.getSourceHint();
+ if (sh != null) {
+ aqr.setGeneralHint(sh.getGeneralHint());
+ aqr.setHint(sh.getSourceHint(aqr.getConnectorName()));
+ }
if (limit > 0) {
aqr.setFetchSize(Math.min(limit, aqr.getFetchSize()));
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -227,7 +227,7 @@
private static final long serialVersionUID = 8261905111156764744L;
private String sql;
private VDBKey vdbInfo;
- private ParseInfo pi;
+ private boolean ansiIdentifiers;
private String sessionId;
private String originalSessionId;
private List<Serializable> parameters;
@@ -242,7 +242,7 @@
Assertion.isNotNull(sql);
this.sql = sql;
this.vdbInfo = new VDBKey(vdbName, vdbVersion);
- this.pi = pi;
+ this.ansiIdentifiers = pi.ansiQuotedIdentifiers;
this.originalSessionId = sessionId;
this.originalUserName = userName;
}
@@ -303,14 +303,14 @@
return false;
}
CacheID that = (CacheID)obj;
- return EquivalenceUtil.areEqual(this.pi, that.pi) && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
+ return ansiIdentifiers == that.ansiIdentifiers && this.vdbInfo.equals(that.vdbInfo) && this.sql.equals(that.sql)
&& EquivalenceUtil.areEqual(this.userName, that.userName)
&& EquivalenceUtil.areEqual(this.sessionId, that.sessionId)
&& EquivalenceUtil.areEqual(this.parameters, that.parameters);
}
public int hashCode() {
- return HashCodeUtil.hashCode(0, vdbInfo, sql, pi, this.userName, sessionId, parameters);
+ return HashCodeUtil.hashCode(0, vdbInfo, sql, this.userName, sessionId, parameters);
}
@Override
Modified: trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -84,6 +84,8 @@
private boolean serial;
private DQPWorkContext workContext;
+ private String generalHint;
+ private String hint;
public AtomicRequestMessage() {
// This is only to honor the externalizable interface..
@@ -214,5 +216,21 @@
public DQPWorkContext getWorkContext() {
return workContext;
}
+
+ public String getGeneralHint() {
+ return generalHint;
+ }
+
+ public void setGeneralHint(String generalHint) {
+ this.generalHint = generalHint;
+ }
+
+ public String getHint() {
+ return hint;
+ }
+
+ public void setHint(String hint) {
+ this.hint = hint;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -100,6 +100,7 @@
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.Select;
import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.lang.SubqueryFromClause;
@@ -157,6 +158,7 @@
private QueryMetadataInterface metadata;
private PlanHints hints = new PlanHints();
private Option option;
+ private SourceHint sourceHint;
public ProcessorPlan optimize(
Command command)
@@ -220,7 +222,7 @@
PlanNode plan;
try {
- plan = generatePlan(command);
+ plan = generatePlan(command, true);
} catch (TeiidProcessingException e) {
throw new QueryPlannerException(e, e.getMessage());
}
@@ -259,7 +261,7 @@
result.setWith(withList);
}
result.setOutputElements(topCols);
-
+ result.setSourceHint(sourceHint);
return result;
}
@@ -483,7 +485,10 @@
return plan;
}
- public PlanNode generatePlan(Command cmd) throws TeiidComponentException, TeiidProcessingException {
+ public PlanNode generatePlan(Command cmd, boolean useSourceHint) throws TeiidComponentException, TeiidProcessingException {
+ if (useSourceHint && cmd.getSourceHint() != null && sourceHint == null) {
+ sourceHint = cmd.getSourceHint();
+ }
//cascade the option clause nocache
Option savedOption = option;
option = cmd.getOption();
@@ -564,7 +569,7 @@
if(!usingTriggerAction && command instanceof Insert){
Insert insert = (Insert)command;
if (insert.getQueryExpression() != null) {
- PlanNode plan = generatePlan(insert.getQueryExpression());
+ PlanNode plan = generatePlan(insert.getQueryExpression(), true);
attachLast(sourceNode, plan);
mergeTempMetadata(insert.getQueryExpression(), insert);
projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
@@ -699,9 +704,12 @@
} else {
hints.hasSetQuery = true;
SetQuery query = (SetQuery)command;
+ boolean hasSourceHint = sourceHint != null;
PlanNode leftPlan = createQueryPlan( query.getLeftQuery());
PlanNode rightPlan = createQueryPlan( query.getRightQuery());
-
+ if (!hasSourceHint) {
+ sourceHint = null;
+ }
node = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
node.setProperty(NodeConstants.Info.SET_OPERATION, query.getOperation());
node.setProperty(NodeConstants.Info.USE_ALL, query.isAll());
@@ -848,6 +856,9 @@
if (info != null && info.getPartitionInfo() != null && !info.getPartitionInfo().isEmpty()) {
node.setProperty(NodeConstants.Info.PARTITION_INFO, info.getPartitionInfo());
}
+ if (parent.getType() != NodeConstants.Types.JOIN && nestedCommand.getSourceHint() != null && sourceHint == null) {
+ sourceHint = nestedCommand.getSourceHint();
+ }
addNestedCommand(node, group, nestedCommand, nestedCommand, true);
}
parent.addLastChild(node);
@@ -984,7 +995,7 @@
if (merge) {
mergeTempMetadata(nestedCommand, parentCommand);
- PlanNode childRoot = generatePlan(nestedCommand);
+ PlanNode childRoot = generatePlan(nestedCommand, false);
node.addFirstChild(childRoot);
List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
SymbolMap map = SymbolMap.createSymbolMap(group, projectCols, metadata);
Modified: trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -23,25 +23,23 @@
package org.teiid.query.parser;
import java.io.Serializable;
-import java.util.HashMap;
import java.util.Map;
-import org.teiid.query.sql.lang.CacheHint;
+import org.teiid.core.util.PropertiesUtils;
public class ParseInfo implements Serializable{
private static final long serialVersionUID = -7323683731955992888L;
+ private static final boolean ANSI_QUOTED_DEFAULT = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.ansiQuotedIdentifiers", true); //$NON-NLS-1$
- public Map<String, Integer> nameCounts = new HashMap<String, Integer>();
+ public Map<String, Integer> nameCounts = null;
public int referenceCount = 0;
// treat a double quoted variable as variable instead of string
- public boolean ansiQuotedIdentifiers=Boolean.valueOf(System.getProperty("org.teiid.ansiQuotedIdentifiers", Boolean.TRUE.toString())).booleanValue(); //$NON-NLS-1$
+ public boolean ansiQuotedIdentifiers=ANSI_QUOTED_DEFAULT;
- public CacheHint cacheHint;
-
public ParseInfo() { }
public boolean useAnsiQuotedIdentifiers() {
Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -22,6 +22,7 @@
package org.teiid.query.parser;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -40,6 +41,7 @@
import org.teiid.query.sql.lang.Option;
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.lang.ExistsCriteria.SubqueryHint;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.CriteriaSelector;
@@ -207,13 +209,42 @@
if (optToken == null) {
return ""; //$NON-NLS-1$
}
- String hint = optToken.image.substring(2, optToken.image.length() - 2);
+ //handle nested comments
+ String image = optToken.image;
+ while (optToken.specialToken != null) {
+ optToken = optToken.specialToken;
+ image = optToken.image + image;
+ }
+ String hint = image.substring(2, image.length() - 2);
if (hint.startsWith("+")) { //$NON-NLS-1$
hint = hint.substring(1);
}
return hint;
}
+ private static Pattern SOURCE_HINT = Pattern.compile("\\s*sh(?::((?:'[^']*')+))?\\s*", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
+ private static Pattern SOURCE_HINT_ARG = Pattern.compile("\\s*([^:]+):((?:'[^']*')+)", Pattern.CASE_INSENSITIVE | Pattern.DOTALL); //$NON-NLS-1$
+
+ SourceHint getSourceHint(Token t) {
+ String comment = getComment(t);
+ Matcher matcher = SOURCE_HINT.matcher(comment);
+ if (!matcher.find()) {
+ return null;
+ }
+ SourceHint sourceHint = new SourceHint();
+ String generalHint = matcher.group(1);
+ if (generalHint != null) {
+ sourceHint.setGeneralHint(normalizeStringLiteral(generalHint));
+ }
+ int end = matcher.end();
+ matcher = SOURCE_HINT_ARG.matcher(comment);
+ while (matcher.find(end)) {
+ end = matcher.end();
+ sourceHint.setSourceHint(matcher.group(1), normalizeStringLiteral(matcher.group(2)));
+ }
+ return sourceHint;
+ }
+
boolean isNonStrictHint(Token t) {
String[] parts = getComment(t).split("\\s"); //$NON-NLS-1$
for (int i = 0; i < parts.length; i++) {
@@ -294,6 +325,9 @@
} else {
functionType = functionType.toLowerCase();
}
+ if (info.nameCounts == null) {
+ info.nameCounts = new HashMap<String, Integer>();
+ }
Integer num = info.nameCounts.get(functionType);
if (num == null) {
num = 0;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -44,6 +44,7 @@
import org.teiid.query.sql.lang.Create;
import org.teiid.query.sql.lang.Insert;
import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.lang.WithQueryCommand;
import org.teiid.query.tempdata.TempTableStore;
import org.teiid.query.tempdata.TempTableStore.TransactionMode;
@@ -62,6 +63,7 @@
private QueryProcessor withProcessor;
private TempTableStore tempTableStore;
private boolean multisourceUpdate;
+ private SourceHint sourceHint;
/**
* Constructor for RelationalPlan.
@@ -82,10 +84,21 @@
this.with = with;
}
+ public void setSourceHint(SourceHint sourceHint) {
+ this.sourceHint = sourceHint;
+ }
+
+ public SourceHint getSourceHint() {
+ return sourceHint;
+ }
+
/**
* @see ProcessorPlan#connectDataManager(ProcessorDataManager)
*/
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
+ if (sourceHint != null && context.getSourceHint() == null) {
+ context.setSourceHint(sourceHint);
+ }
if (this.with != null) {
context = context.clone();
tempTableStore = new TempTableStore(context.getConnectionID(), TransactionMode.NONE);
@@ -207,6 +220,7 @@
public RelationalPlan clone(){
RelationalPlan plan = new RelationalPlan((RelationalNode)root.clone());
+ plan.sourceHint = this.sourceHint;
plan.setOutputElements(outputCols);
if (with != null) {
List<WithQueryCommand> newWith = LanguageObject.Util.deepClone(this.with, WithQueryCommand.class);
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -754,13 +754,6 @@
return true;
}
- /**
- * Converts a group by with expressions into a group by with only element symbols and an inline view
- * @param query
- * @return
- * @throws TeiidProcessingException
- * @throws TeiidComponentException
- */
private Query rewriteGroupBy(Query query) throws TeiidComponentException, TeiidProcessingException {
if (query.getGroupBy() == null) {
rewriteAggs = false;
@@ -880,6 +873,8 @@
try {
List<ElementSymbol> allIntoElements = Util.deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class);
Insert insert = new Insert(into.getGroup(), allIntoElements, Collections.emptyList());
+ insert.setSourceHint(query.getSourceHint());
+ query.setSourceHint(null);
query.setInto(null);
insert.setQueryExpression(query);
return rewriteInsert(correctDatatypes(insert));
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -130,6 +130,7 @@
private SymbolMap correlatedReferences;
private CacheHint cacheHint;
+ private SourceHint sourceHint;
/**
* Return type of command to make it easier to build switch statements by command type.
@@ -231,6 +232,7 @@
copy.setOption( (Option) this.getOption().clone() );
}
copy.cacheHint = this.cacheHint;
+ copy.sourceHint = this.sourceHint;
}
/**
@@ -324,6 +326,14 @@
this.cacheHint = cacheHint;
}
+ public SourceHint getSourceHint() {
+ return sourceHint;
+ }
+
+ public void setSourceHint(SourceHint sourceHint) {
+ this.sourceHint = sourceHint;
+ }
+
/**
* Returns a string representation of an instance of this class.
* @return String representation of object
@@ -333,7 +343,8 @@
}
protected boolean sameOptionAndHint(Command cmd) {
- return EquivalenceUtil.areEqual(this.cacheHint, cmd.cacheHint) &&
+ return EquivalenceUtil.areEqual(this.cacheHint, cmd.cacheHint) &&
+ EquivalenceUtil.areEqual(this.cacheHint, cmd.cacheHint) &&
EquivalenceUtil.areEqual(this.option, cmd.option);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -161,6 +161,7 @@
Delete other = (Delete) obj;
return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) &&
+ sameOptionAndHint(other) &&
EquivalenceUtil.areEqual(getCriteria(), other.getCriteria());
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -223,6 +223,7 @@
return EquivalenceUtil.areEqual(getGroup(), other.getGroup()) &&
EquivalenceUtil.areEqual(getValues(), other.getValues()) &&
EquivalenceUtil.areEqual(getVariables(), other.getVariables()) &&
+ sameOptionAndHint(other) &&
EquivalenceUtil.areEqual(getQueryExpression(), other.getQueryExpression());
}
Added: trunk/engine/src/main/java/org/teiid/query/sql/lang/SourceHint.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/SourceHint.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SourceHint.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -0,0 +1,74 @@
+/*
+ * 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.query.sql.lang;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.teiid.core.util.EquivalenceUtil;
+
+public class SourceHint {
+
+ private String generalHint;
+ private Map<String, String> sourceHints;
+
+ public String getGeneralHint() {
+ return generalHint;
+ }
+
+ public void setGeneralHint(String generalHint) {
+ this.generalHint = generalHint;
+ }
+
+ public void setSourceHint(String translatorName, String hint) {
+ if (this.sourceHints == null) {
+ this.sourceHints = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
+ }
+ this.sourceHints.put(translatorName, hint);
+ }
+
+ public String getSourceHint(String sourceName) {
+ if (this.sourceHints == null) {
+ return null;
+ }
+ return this.sourceHints.get(sourceName);
+ }
+
+ public Map<String, String> getSourceHints() {
+ return sourceHints;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof SourceHint)) {
+ return false;
+ }
+ SourceHint other = (SourceHint)obj;
+ return EquivalenceUtil.areEqual(generalHint, other.generalHint)
+ && EquivalenceUtil.areEqual(this.sourceHints, other.sourceHints);
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/sql/lang/SourceHint.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -206,12 +206,9 @@
Update other = (Update) obj;
return
- // Compare the groups
EquivalenceUtil.areEqual(getGroup(), other.getGroup()) &&
- // Compare the changeList by checking to see if
- // both objects contains exactly the same CompareCriteria objects.
getChangeList().equals(other.getChangeList()) &&
- // Compare the criteria clauses
+ sameOptionAndHint(other) &&
EquivalenceUtil.areEqual(getCriteria(), other.getCriteria());
}
@@ -261,12 +258,12 @@
LinkedHashMap<ElementSymbol, Expression> map = new LinkedHashMap<ElementSymbol, Expression>();
- for (Iterator iter = getChangeList().getClauses().iterator(); iter.hasNext();) {
- SetClause setClause = (SetClause)iter.next();
- ElementSymbol symbol = (ElementSymbol)(setClause.getSymbol()).clone();
+ for (Iterator<SetClause> iter = getChangeList().getClauses().iterator(); iter.hasNext();) {
+ SetClause setClause = iter.next();
+ ElementSymbol symbol = setClause.getSymbol().clone();
symbol.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.INPUTS));
map.put( symbol, setClause.getValue() );
- } // for
+ }
return map;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -28,6 +28,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.StringUtil;
@@ -78,6 +79,7 @@
import org.teiid.query.sql.lang.SetClauseList;
import org.teiid.query.sql.lang.SetCriteria;
import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.lang.SubqueryCompareCriteria;
import org.teiid.query.sql.lang.SubqueryFromClause;
@@ -347,7 +349,7 @@
beginClause(2);
// Columns clause
- List vars = obj.getVariables();
+ List<ElementSymbol> vars = obj.getVariables();
if (vars != null) {
append("("); //$NON-NLS-1$
registerNodes(vars, 0);
@@ -632,10 +634,10 @@
append(MAKENOTDEP);
append(" "); //$NON-NLS-1$
- Iterator iter = groups.iterator();
+ Iterator<String> iter = groups.iterator();
while (iter.hasNext()) {
- outputDisplayName((String)iter.next());
+ outputDisplayName(iter.next());
if (iter.hasNext()) {
append(", ");//$NON-NLS-1$
@@ -649,10 +651,10 @@
append(NOCACHE);
append(" "); //$NON-NLS-1$
- Iterator iter = groups.iterator();
+ Iterator<String> iter = groups.iterator();
while (iter.hasNext()) {
- outputDisplayName((String)iter.next());
+ outputDisplayName(iter.next());
if (iter.hasNext()) {
append(", ");//$NON-NLS-1$
@@ -777,7 +779,9 @@
public void visit( Query obj ) {
addCacheHint(obj.getCacheHint());
addWithClause(obj);
- visitNode(obj.getSelect());
+ if (obj.getSelect() != null) {
+ visitDirect(obj.getSelect(), obj);
+ }
if (obj.getInto() != null) {
beginClause(1);
@@ -864,23 +868,55 @@
}
public void visit( Select obj ) {
+ visitDirect(obj, null);
+ }
+
+ private void visitDirect(Select obj, Query query) {
append(SELECT);
- if (obj.isDistinct()) {
+
+ if (query != null) {
+ SourceHint sh = query.getSourceHint();
+ if (sh != null) {
+ append(SPACE);
+ append(BEGIN_HINT);
+ append("sh"); //$NON-NLS-1$
+ if (sh.getGeneralHint() != null) {
+ appendSourceHintValue(sh.getGeneralHint());
+ }
+ if (sh.getSourceHints() != null) {
+ for (Map.Entry<String, String> entry : sh.getSourceHints().entrySet()) {
+ append(entry.getKey());
+ appendSourceHintValue(entry.getValue());
+ }
+ }
+ append(END_HINT);
+ }
+ }
+
+ if (obj.isDistinct()) {
append(SPACE);
append(DISTINCT);
}
beginClause(2);
- Iterator iter = obj.getSymbols().iterator();
+ Iterator<SelectSymbol> iter = obj.getSymbols().iterator();
while (iter.hasNext()) {
- SelectSymbol symbol = (SelectSymbol)iter.next();
+ SelectSymbol symbol = iter.next();
visitNode(symbol);
if (iter.hasNext()) {
append(", "); //$NON-NLS-1$
}
}
- }
+ }
+ private void appendSourceHintValue(String sh) {
+ append(Tokens.COLON);
+ append('\'');
+ append(escapeStringValue(sh, "'")); //$NON-NLS-1$
+ append('\'');
+ append(SPACE);
+ }
+
public void visit( SetCriteria obj ) {
// variable
visitNode(obj.getExpression());
@@ -950,8 +986,8 @@
protected void appendSetQuery( SetQuery parent,
QueryCommand obj,
boolean right ) {
- if (right && ((obj instanceof SetQuery
- && ((parent.isAll() && !((SetQuery)obj).isAll()) || parent.getOperation() != ((SetQuery)obj).getOperation())) || obj.getLimit() != null || obj.getOrderBy() != null)) {
+ if (obj.getLimit() != null || obj.getOrderBy() != null || (right && ((obj instanceof SetQuery
+ && ((parent.isAll() && !((SetQuery)obj).isAll()) || parent.getOperation() != ((SetQuery)obj).getOperation()))))) {
append(Tokens.LPAREN);
visitNode(obj);
append(Tokens.RPAREN);
@@ -1415,6 +1451,9 @@
}
}
+ /**
+ * @param level
+ */
protected void addTabs( int level ) {
}
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -56,6 +56,7 @@
import org.teiid.query.optimizer.relational.PlanToProcessConverter;
import org.teiid.query.parser.ParseInfo;
import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.lang.SourceHint;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.util.VariableContext;
@@ -133,6 +134,7 @@
private DQPWorkContext dqpWorkContext;
private TransactionContext transactionContext;
private TransactionService transactionService;
+ private SourceHint sourceHint;
}
private GlobalState globalState = new GlobalState();
@@ -629,4 +631,12 @@
globalState.transactionService = transactionService;
}
+ public SourceHint getSourceHint() {
+ return this.globalState.sourceHint;
+ }
+
+ public void setSourceHint(SourceHint hint) {
+ this.globalState.sourceHint = hint;
+ }
+
}
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2011-11-09 20:06:24 UTC (rev 3624)
@@ -38,6 +38,11 @@
PARSER_END(SQLParser)
+TOKEN_MGR_DECLS :
+{
+ int commentNestingDepth;
+}
+
SKIP :
{
" " | "\t" | "\n" | "\r"
@@ -45,16 +50,25 @@
MORE :
{
- "/*" : IN_MULTI_LINE_COMMENT
+ "/*" { commentNestingDepth = 1 ; } : IN_MULTI_LINE_COMMENT
}
<IN_MULTI_LINE_COMMENT>
-SPECIAL_TOKEN :
-{
- <MULTI_LINE_COMMENT: "*/" > : DEFAULT
-}
+MORE :
+{
+ "/*" { commentNestingDepth += 1 ; }
+}
<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+ "*/" {
+ commentNestingDepth -= 1;
+ SwitchTo( commentNestingDepth==0 ? DEFAULT : IN_MULTI_LINE_COMMENT ) ;
+ }
+}
+
+<IN_MULTI_LINE_COMMENT>
MORE :
{
< ~[] >
@@ -596,8 +610,18 @@
Command userCommand(ParseInfo info) :
{
Command command = null;
+ SourceHint sourceHint = null;
}
{
+ {int index = 1;
+ Token t = null;
+ do
+ t = getToken(index++);
+ while (t != null && t.kind == LPAREN);
+ t = getToken(index);
+ if (t != null)
+ sourceHint = getSourceHint(t);
+ }
(command = queryExpression(info) |
command = storedProcedure(info, new StoredProcedure()) |
command = insert(info) |
@@ -609,6 +633,13 @@
command = createTrigger(info)
)
{
+ if (sourceHint != null) {
+ if (command instanceof SetQuery) {
+ ((SetQuery)command).getProjectedQuery().setSourceHint(sourceHint);
+ } else {
+ command.setSourceHint(sourceHint);
+ }
+ }
return command;
}
}
@@ -1590,7 +1621,6 @@
String group = null;
SetClauseList setClauseList = null;
Criteria criteria = null;
- ElementSymbol elementID = null;
Option option = null;
}
{
@@ -1650,9 +1680,6 @@
}
}
-/**
- * Currently just a place holder to keep consistency with the spec
- */
QueryCommand queryExpression(ParseInfo info) :
{
QueryCommand query = null;
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -22,17 +22,16 @@
package org.teiid.query.optimizer;
+import org.junit.Test;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.unittest.RealMetadataFactory;
-import junit.framework.TestCase;
-
-public class TestRuleRemoveSorts extends TestCase {
+public class TestRuleRemoveSorts {
/** Tests an order by in a query transformation */
- public void testRemovedOrderByFromQueryTransform() {
+ @Test public void testRemovedOrderByFromQueryTransform() {
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1, e2 FROM vm1.g14", RealMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1"}); //$NON-NLS-1$
@@ -43,7 +42,7 @@
* Tests an order by in a query transformation, where the
* physical model does not support pushing order bys
*/
- public void testRemovedOrderByFromQueryTransform2() {
+ @Test public void testRemovedOrderByFromQueryTransform2() {
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e, e2 FROM vm1.g8", RealMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT e1, e2 FROM pm1.g1"}); //$NON-NLS-1$
@@ -69,7 +68,7 @@
* Tests an order by in a query transformation, where the
* query transformation contains a function
*/
- public void testRemovedOrderByFromQueryTransform3() {
+ @Test public void testRemovedOrderByFromQueryTransform3() {
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e, e2 FROM vm1.g16", RealMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT e1, e2 FROM pm3.g1"}); //$NON-NLS-1$
@@ -92,7 +91,7 @@
}
/** Tests an order by in a query transformation */
- public void testRemovedOrderByFromQueryTransform4() {
+ @Test public void testRemovedOrderByFromQueryTransform4() {
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1, e2 FROM vm1.g13", RealMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1"}); //$NON-NLS-1$
@@ -115,7 +114,7 @@
}
/** Order by is not removed */
- public void testOrderByWithLimit() throws Exception {
+ @Test public void testOrderByWithLimit() throws Exception {
ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT e1, e2 FROM pm1.g1 order by e1 limit 10) x", RealMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -85,7 +85,7 @@
//Generate canonical plan
RelationalPlanner p = new RelationalPlanner();
p.initialize(query, null, METADATA, FINDER, null, new CommandContext());
- PlanNode planNode = p.generatePlan(query);
+ PlanNode planNode = p.generatePlan(query, false);
RelationalPlanner planner = new RelationalPlanner();
final RuleStack rules = planner.buildRules();
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -73,8 +73,8 @@
RelationalPlanner p = new RelationalPlanner();
CommandContext cc = new CommandContext();
p.initialize(command, null, metadata, null, null, cc);
- PlanNode root = p.generatePlan(command);
- PlanNode child = p.generatePlan(subCommand);
+ PlanNode root = p.generatePlan(command, false);
+ PlanNode child = p.generatePlan(subCommand, false);
PlanNode sourceNode = NodeEditor.findNodePreOrder(root, NodeConstants.Types.SOURCE);
sourceNode.addFirstChild(child);
sourceNode.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(sourceNode.getGroups().iterator().next(), (List<SingleElementSymbol>)child.getFirstChild().getProperty(Info.PROJECT_COLS), metadata));
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -425,6 +425,7 @@
option.setNoCache(true);
Criteria crit = new CompareCriteria(new ElementSymbol("b"), CompareCriteria.EQ, new Reference(1)); //$NON-NLS-1$
update.setCriteria(crit);
+ update.setOption(option);
TestParser.helpTest("UPDATE m.g SET a = ? WHERE b = ? OPTION NOCACHE", //$NON-NLS-1$
"UPDATE m.g SET a = ? WHERE b = ? OPTION NOCACHE", //$NON-NLS-1$
update);
@@ -1173,4 +1174,17 @@
assertEquals("SELECT a FROM x /*+ NON_STRICT */ LIMIT 1", QueryParser.getQueryParser().parseCommand(sql, new ParseInfo()).toString()); //$NON-NLS-1$
}
+ @Test public void testNestedComments() throws QueryParserException {
+ String sql = "/*+ /*nested*/ */ SELECT a FROM x limit 1"; //$NON-NLS-1$
+ assertEquals("SELECT a FROM x LIMIT 1", QueryParser.getQueryParser().parseCommand(sql, new ParseInfo()).toString()); //$NON-NLS-1$
+ }
+
+ @Test public void testSourceHint() throws QueryParserException {
+ String sql = "SELECT /*+ sh:'foo' oracle:'leading' */ a FROM x limit 1"; //$NON-NLS-1$
+ assertEquals("SELECT /*+sh:'foo' oracle:'leading' */ a FROM x LIMIT 1", QueryParser.getQueryParser().parseCommand(sql, new ParseInfo()).toString()); //$NON-NLS-1$
+
+ sql = "(SELECT /*+ sh:'foo' oracle:'leading' */ a FROM x limit 1) union all select 1"; //$NON-NLS-1$
+ assertEquals("(SELECT /*+sh:'foo' oracle:'leading' */ a FROM x LIMIT 1) UNION ALL SELECT 1", QueryParser.getQueryParser().parseCommand(sql, new ParseInfo()).toString());
+ }
+
}
Added: trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -0,0 +1,108 @@
+/*
+ * 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.query.processor;
+
+import static org.junit.Assert.*;
+import static org.teiid.query.processor.TestProcessor.*;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.query.util.CommandContext;
+
+@SuppressWarnings("nls")
+public class TestSourceHints {
+
+ @Test public void testUserQueryHint() {
+ String sql = "SELECT /*+ sh:'foo' bar:'leading' */ e1 from pm1.g1 order by e1 limit 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+
+ List<?>[] expected = new List[] {};
+ helpProcess(plan, manager("foo", "leading"), expected);
+ }
+
+ @Test public void testHintInView() {
+ MetadataStore metadataStore = new MetadataStore();
+ Schema p1 = RealMetadataFactory.createPhysicalModel("p1", metadataStore); //$NON-NLS-1$
+ Table t1 = RealMetadataFactory.createPhysicalGroup("t", p1); //$NON-NLS-1$
+ RealMetadataFactory.createElements(t1, new String[] {"a", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ Schema v1 = RealMetadataFactory.createVirtualModel("v1", metadataStore); //$NON-NLS-1$
+ QueryNode n1 = new QueryNode("SELECT /*+ sh:'x' */ a as c, b FROM p1.t"); //$NON-NLS-1$ //$NON-NLS-2$
+ Table vt1 = RealMetadataFactory.createVirtualGroup("t1", v1, n1); //$NON-NLS-1$
+ RealMetadataFactory.createElements(vt1, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(metadataStore, "metadata");
+
+ //top level applies
+ HardcodedDataManager manager = manager("foo", "leading");
+
+ String sql = "SELECT /*+ sh:'foo' bar:'leading' */ c from t1 order by c limit 1"; //$NON-NLS-1$
+ ProcessorPlan plan = helpGetPlan(sql, metadata);
+
+ List<?>[] expected = new List[] {};
+ helpProcess(plan, manager, expected);
+
+ //use the underlying hint
+ manager = manager("x", null);
+ sql = "SELECT c from t1 order by c limit 1"; //$NON-NLS-1$
+ plan = helpGetPlan(sql, metadata);
+ helpProcess(plan, manager, expected);
+
+ //use no hints
+ manager = manager(null, null);
+ sql = "SELECT c from t1 union all select c from t1"; //$NON-NLS-1$
+ plan = helpGetPlan(sql, metadata);
+ helpProcess(plan, manager, expected);
+ }
+
+ private HardcodedDataManager manager(final String general, final String hint) {
+ HardcodedDataManager manager = new HardcodedDataManager() {
+ @Override
+ public TupleSource registerRequest(CommandContext context,
+ Command command, String modelName,
+ String connectorBindingId, int nodeID, int limit)
+ throws TeiidComponentException {
+ if (general == null && hint == null) {
+ assertNull(context.getSourceHint());
+ } else {
+ assertEquals(general, context.getSourceHint().getGeneralHint()); //$NON-NLS-1$
+ assertEquals(hint, context.getSourceHint().getSourceHint("bar")); //$NON-NLS-1$
+ }
+ return CollectionTupleSource.createNullTupleSource();
+ }
+ };
+ return manager;
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestSourceHints.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -42,12 +42,14 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.parser.QueryParser;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.resolver.TestFunctionResolving;
import org.teiid.query.sql.lang.CollectionValueIterator;
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.SubqueryContainer;
import org.teiid.query.sql.symbol.CaseExpression;
import org.teiid.query.sql.symbol.Constant;
@@ -294,7 +296,7 @@
}
@Test public void testScalarSubqueryFails() throws Exception{
- ScalarSubquery expr = new ScalarSubquery(new Query());
+ ScalarSubquery expr = new ScalarSubquery((QueryCommand) QueryParser.getQueryParser().parseCommand("select x from y"));
ArrayList values = new ArrayList(2);
values.add("a"); //$NON-NLS-1$
values.add("b"); //$NON-NLS-1$
@@ -303,7 +305,7 @@
helpTestWithValueIterator(expr, values, null);
fail("Expected ExpressionEvaluationException but got none"); //$NON-NLS-1$
} catch (ExpressionEvaluationException e) {
- assertEquals("Error Code:ERR.015.006.0058 Message:Unable to evaluate (<undefined>): Error Code:ERR.015.006.0058 Message:The command of this scalar subquery returned more than one value: <undefined>", e.getMessage()); //$NON-NLS-1$
+ assertEquals("Error Code:ERR.015.006.0058 Message:Unable to evaluate (SELECT x FROM y): Error Code:ERR.015.006.0058 Message:The command of this scalar subquery returned more than one value: SELECT x FROM y", e.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -80,7 +80,7 @@
void sendMoveCursor(ResultSetImpl rs, int rowCount, ResultsFuture<Integer> results);
- void sendCommandComplete(String sql, int updateCount);
+ void sendCommandComplete(String sql, Integer count);
// CommandComplete (B)
void sendUpdateCount(String sql, int updateCount);
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -268,7 +268,7 @@
try {
List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
cursorMap.put(cursorName, new Cursor(cursorName, sql, stmt, null, stmt.getResultSet(), cols));
- client.sendCommandComplete("DECLARE CURSOR", 0); //$NON-NLS-1$
+ client.sendCommandComplete("DECLARE CURSOR", null); //$NON-NLS-1$
completion.getResultsReceiver().receiveResults(0);
} catch (Throwable e) {
completion.getResultsReceiver().exceptionOccurred(e);
@@ -336,7 +336,7 @@
if (cursor != null) {
cursor.rs.close();
cursor.stmt.close();
- this.client.sendCommandComplete("CLOSE CURSOR", 0); //$NON-NLS-1$
+ this.client.sendCommandComplete("CLOSE CURSOR", null); //$NON-NLS-1$
}
}
@@ -941,7 +941,7 @@
String plan_name = m.group(1);
plan_name = SQLParserUtil.normalizeId(plan_name);
closePreparedStatement(plan_name);
- client.sendCommandComplete("DEALLOCATE", 0); //$NON-NLS-1$
+ client.sendCommandComplete("DEALLOCATE", null); //$NON-NLS-1$
results.getResultsReceiver().receiveResults(1);
}
else {
Modified: trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -56,6 +56,7 @@
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.core.util.SqlUtil;
import org.teiid.core.util.StringUtil;
import org.teiid.jdbc.ResultSetImpl;
import org.teiid.jdbc.TeiidSQLException;
@@ -155,7 +156,7 @@
} else {
sendContents();
if (sql != null) {
- sendCommandComplete(sql, 0);
+ sendCommandComplete(sql, rowsSent);
}
result.getResultsReceiver().receiveResults(rowsSent);
processNext = false;
@@ -417,42 +418,28 @@
}
@Override
- public void sendCommandComplete(String sql, int updateCount) {
+ public void sendCommandComplete(String sql, Integer count) {
startMessage('C');
- // TODO remove remarks at the beginning
String tag;
- if (StringUtil.startsWithIgnoreCase(sql, "INSERT")) {
- tag = "INSERT 0 " + updateCount;
- } else if (StringUtil.startsWithIgnoreCase(sql, "DELETE")) {
- tag = "DELETE " + updateCount;
- } else if (StringUtil.startsWithIgnoreCase(sql, "UPDATE")) {
- tag = "UPDATE " + updateCount;
- } else if (StringUtil.startsWithIgnoreCase(sql, "SELECT") || StringUtil.startsWithIgnoreCase(sql, "CALL")) {
- tag = "SELECT";
- } else if (StringUtil.startsWithIgnoreCase(sql, "BEGIN") || StringUtil.startsWithIgnoreCase(sql, "START TRANSACTION")) {
+ if (StringUtil.startsWithIgnoreCase(sql, "BEGIN") || StringUtil.startsWithIgnoreCase(sql, "START TRANSACTION")) {
tag = "BEGIN";
- } else if (StringUtil.startsWithIgnoreCase(sql, "COMMIT")) {
- tag = "COMMIT";
- } else if (StringUtil.startsWithIgnoreCase(sql, "ROLLBACK")) {
- tag = "ROLLBACK";
+ } else if (sql.indexOf(' ') == -1) {
+ //should already be a completion tag
+ tag = sql.toUpperCase();
+ if (count != null) {
+ tag += " " + count;
+ }
} else if (StringUtil.startsWithIgnoreCase(sql, "SET ")) {
tag = "SET";
- } else if (StringUtil.startsWithIgnoreCase(sql, "DECLARE CURSOR")) {
- tag = "DECLARE CURSOR";
- } else if (StringUtil.startsWithIgnoreCase(sql, "CLOSE CURSOR")) {
- tag = "CLOSE CURSOR";
- } else if (StringUtil.startsWithIgnoreCase(sql, "FETCH")) {
- tag = "FETCH "+ updateCount;
- } else if (StringUtil.startsWithIgnoreCase(sql, "MOVE")) {
- tag = "MOVE "+ updateCount;
- } else if (StringUtil.startsWithIgnoreCase(sql, "RELEASE")) {
- tag = "RELEASE "+ updateCount;
- } else if (StringUtil.startsWithIgnoreCase(sql, "SAVEPOINT")) {
- tag = "SAVEPOINT "+ updateCount;
+ } else {
+ tag = SqlUtil.getKeyword(sql).toUpperCase();
+ if (tag.equals("EXEC") || tag.equals("CALL")) {
+ tag = "SELECT";
+ }
+ if (count != null) {
+ tag += " " + count;
+ }
}
- else {
- tag = sql;
- }
writeString(tag);
sendMessage();
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2011-11-09 18:09:23 UTC (rev 3623)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2011-11-09 20:06:24 UTC (rev 3624)
@@ -352,7 +352,7 @@
}
@Test public void testVisitIUnion1() throws Exception {
- String expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC UNION (SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC) ORDER BY e1, e2 DESC, e3, e4 DESC";//$NON-NLS-1$
+ String expected = "(SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC) UNION (SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC) ORDER BY e1, e2 DESC, e3, e4 DESC";//$NON-NLS-1$
assertEquals(expected, getString(TestSetQueryImpl.example()));
}
13 years, 1 month